coccinelle: make use of the "type" FREE_AND_NULL() rule

Apply the result of the just-added coccinelle rule. This manually
excludes a few occurrences, mostly things that resulted in many
FREE_AND_NULL() on one line, that'll be manually fixed in a subsequent
change.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ævar Arnfjörð Bjarmason
2017-06-15 23:15:46 +00:00
committed by Junio C Hamano
parent cf9f49ea48
commit 6a83d90207
37 changed files with 71 additions and 142 deletions

15
http.c
View File

@ -1026,8 +1026,7 @@ void http_cleanup(void)
if (proxy_auth.password) {
memset(proxy_auth.password, 0, strlen(proxy_auth.password));
free(proxy_auth.password);
proxy_auth.password = NULL;
FREE_AND_NULL(proxy_auth.password);
}
free((void *)curl_proxyuserpwd);
@ -1038,13 +1037,11 @@ void http_cleanup(void)
if (cert_auth.password != NULL) {
memset(cert_auth.password, 0, strlen(cert_auth.password));
free(cert_auth.password);
cert_auth.password = NULL;
FREE_AND_NULL(cert_auth.password);
}
ssl_cert_password_required = 0;
free(cached_accept_language);
cached_accept_language = NULL;
FREE_AND_NULL(cached_accept_language);
}
struct active_request_slot *get_active_slot(void)
@ -1896,8 +1893,7 @@ static char *fetch_pack_index(unsigned char *sha1, const char *base_url)
if (http_get_file(url, tmp, NULL) != HTTP_OK) {
error("Unable to get pack index %s", url);
free(tmp);
tmp = NULL;
FREE_AND_NULL(tmp);
}
free(url);
@ -2328,8 +2324,7 @@ void release_http_object_request(struct http_object_request *freq)
freq->localfile = -1;
}
if (freq->url != NULL) {
free(freq->url);
freq->url = NULL;
FREE_AND_NULL(freq->url);
}
if (freq->slot != NULL) {
freq->slot->callback_func = NULL;