Git fork

Merge branch 'ep/maint-equals-null-cocci' into ep/equals-null-cocci

* ep/maint-equals-null-cocci:
tree-wide: apply equals-null.cocci
tree-wide: apply equals-null.cocci
contrib/coccinnelle: add equals-null.cocci

+180 -150
+3 -3
apply.c
··· 3274 3274 { 3275 3275 struct string_list_item *item; 3276 3276 3277 - if (name == NULL) 3277 + if (!name) 3278 3278 return NULL; 3279 3279 3280 3280 item = string_list_lookup(&state->fn_table, name); 3281 - if (item != NULL) 3281 + if (item) 3282 3282 return (struct patch *)item->util; 3283 3283 3284 3284 return NULL; ··· 3318 3318 * This should cover the cases for normal diffs, 3319 3319 * file creations and copies 3320 3320 */ 3321 - if (patch->new_name != NULL) { 3321 + if (patch->new_name) { 3322 3322 item = string_list_insert(&state->fn_table, patch->new_name); 3323 3323 item->util = patch; 3324 3324 }
+1 -1
archive.c
··· 465 465 } 466 466 467 467 tree = parse_tree_indirect(&oid); 468 - if (tree == NULL) 468 + if (!tree) 469 469 die(_("not a tree object: %s"), oid_to_hex(&oid)); 470 470 471 471 if (prefix) {
+3 -3
blame.c
··· 1072 1072 if (p1->s_lno <= p2->s_lno) { 1073 1073 do { 1074 1074 tail = &p1->next; 1075 - if ((p1 = *tail) == NULL) { 1075 + if (!(p1 = *tail)) { 1076 1076 *tail = p2; 1077 1077 return list1; 1078 1078 } ··· 1082 1082 *tail = p2; 1083 1083 do { 1084 1084 tail = &p2->next; 1085 - if ((p2 = *tail) == NULL) { 1085 + if (!(p2 = *tail)) { 1086 1086 *tail = p1; 1087 1087 return list1; 1088 1088 } ··· 1090 1090 *tail = p1; 1091 1091 do { 1092 1092 tail = &p1->next; 1093 - if ((p1 = *tail) == NULL) { 1093 + if (!(p1 = *tail)) { 1094 1094 *tail = p2; 1095 1095 return list1; 1096 1096 }
+1 -1
branch.c
··· 466 466 break; 467 467 } 468 468 469 - if ((commit = lookup_commit_reference(r, &oid)) == NULL) 469 + if (!(commit = lookup_commit_reference(r, &oid))) 470 470 die(_("not a valid branch point: '%s'"), start_name); 471 471 if (out_real_ref) { 472 472 *out_real_ref = real_ref;
+1 -1
builtin/bisect--helper.c
··· 433 433 if (get_terms(terms)) 434 434 return error(_("no terms defined")); 435 435 436 - if (option == NULL) { 436 + if (!option) { 437 437 printf(_("Your current terms are %s for the old state\n" 438 438 "and %s for the new state.\n"), 439 439 terms->term_good, terms->term_bad);
+1 -1
builtin/checkout.c
··· 834 834 if (ret) 835 835 return ret; 836 836 o.ancestor = old_branch_info->name; 837 - if (old_branch_info->name == NULL) { 837 + if (!old_branch_info->name) { 838 838 strbuf_add_unique_abbrev(&old_commit_shortname, 839 839 &old_branch_info->commit->object.oid, 840 840 DEFAULT_ABBREV);
+2 -2
builtin/clone.c
··· 1106 1106 * apply the remote name provided by --origin only after this second 1107 1107 * call to git_config, to ensure it overrides all config-based values. 1108 1108 */ 1109 - if (option_origin != NULL) 1109 + if (option_origin) 1110 1110 remote_name = xstrdup(option_origin); 1111 1111 1112 - if (remote_name == NULL) 1112 + if (!remote_name) 1113 1113 remote_name = xstrdup("origin"); 1114 1114 1115 1115 if (!valid_remote_name(remote_name))
+1 -1
builtin/commit.c
··· 861 861 } 862 862 863 863 s->fp = fopen_for_writing(git_path_commit_editmsg()); 864 - if (s->fp == NULL) 864 + if (!s->fp) 865 865 die_errno(_("could not open '%s'"), git_path_commit_editmsg()); 866 866 867 867 /* Ignore status.displayCommentPrefix: we do need comments in COMMIT_EDITMSG. */
+1 -1
builtin/diff.c
··· 352 352 othercount++; 353 353 continue; 354 354 } 355 - if (map == NULL) 355 + if (!map) 356 356 map = bitmap_new(); 357 357 bitmap_set(map, i); 358 358 }
+3 -3
builtin/gc.c
··· 446 446 fscanf(fp, scan_fmt, &pid, locking_host) == 2 && 447 447 /* be gentle to concurrent "gc" on remote hosts */ 448 448 (strcmp(locking_host, my_host) || !kill(pid, 0) || errno == EPERM); 449 - if (fp != NULL) 449 + if (fp) 450 450 fclose(fp); 451 451 if (should_exit) { 452 452 if (fd >= 0) ··· 2238 2238 goto error; 2239 2239 } 2240 2240 file = fopen_or_warn(filename, "w"); 2241 - if (file == NULL) 2241 + if (!file) 2242 2242 goto error; 2243 2243 2244 2244 unit = "# This file was created and is maintained by Git.\n" ··· 2267 2267 2268 2268 filename = xdg_config_home_systemd("git-maintenance@.service"); 2269 2269 file = fopen_or_warn(filename, "w"); 2270 - if (file == NULL) 2270 + if (!file) 2271 2271 goto error; 2272 2272 2273 2273 unit = "# This file was created and is maintained by Git.\n"
+3 -3
builtin/index-pack.c
··· 1942 1942 free(objects); 1943 1943 strbuf_release(&index_name_buf); 1944 1944 strbuf_release(&rev_index_name_buf); 1945 - if (pack_name == NULL) 1945 + if (!pack_name) 1946 1946 free((void *) curr_pack); 1947 - if (index_name == NULL) 1947 + if (!index_name) 1948 1948 free((void *) curr_index); 1949 - if (rev_index_name == NULL) 1949 + if (!rev_index_name) 1950 1950 free((void *) curr_rev_index); 1951 1951 1952 1952 /*
+1 -1
builtin/log.c
··· 1012 1012 if (!quiet) 1013 1013 printf("%s\n", filename.buf + outdir_offset); 1014 1014 1015 - if ((rev->diffopt.file = fopen(filename.buf, "w")) == NULL) { 1015 + if (!(rev->diffopt.file = fopen(filename.buf, "w"))) { 1016 1016 error_errno(_("cannot open patch file %s"), filename.buf); 1017 1017 strbuf_release(&filename); 1018 1018 return -1;
+1 -1
builtin/ls-remote.c
··· 114 114 } 115 115 116 116 transport = transport_get(remote, NULL); 117 - if (uploadpack != NULL) 117 + if (uploadpack) 118 118 transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack); 119 119 if (server_options.nr) 120 120 transport->server_options = &server_options;
+1 -1
builtin/mailsplit.c
··· 120 120 for (sub = subs; *sub; ++sub) { 121 121 free(name); 122 122 name = xstrfmt("%s/%s", path, *sub); 123 - if ((dir = opendir(name)) == NULL) { 123 + if (!(dir = opendir(name))) { 124 124 if (errno == ENOENT) 125 125 continue; 126 126 error_errno("cannot opendir %s", name);
+5 -5
builtin/pack-redundant.c
··· 101 101 oidread(&new_item->oid, oid); 102 102 new_item->next = NULL; 103 103 104 - if (after != NULL) { 104 + if (after) { 105 105 new_item->next = after->next; 106 106 after->next = new_item; 107 107 if (after == list->back) ··· 157 157 if (cmp > 0) /* not in list, since sorted */ 158 158 return prev; 159 159 if (!cmp) { /* found */ 160 - if (prev == NULL) { 160 + if (!prev) { 161 161 if (hint != NULL && hint != list->front) { 162 162 /* we don't know the previous element */ 163 163 hint = NULL; ··· 219 219 struct pack_list *ret; 220 220 const struct pack_list *pl; 221 221 222 - if (A == NULL) 222 + if (!A) 223 223 return NULL; 224 224 225 225 pl = B; ··· 317 317 struct pack_list *subset; 318 318 size_t ret = 0; 319 319 320 - if (pl == NULL) 320 + if (!pl) 321 321 return 0; 322 322 323 323 while ((subset = pl->next)) { ··· 611 611 while (*(argv + i) != NULL) 612 612 add_pack_file(*(argv + i++)); 613 613 614 - if (local_packs == NULL) 614 + if (!local_packs) 615 615 die("Zero packs found!"); 616 616 617 617 load_all_objects();
+2 -2
builtin/receive-pack.c
··· 1664 1664 } 1665 1665 dst_name = strip_namespace(dst_name); 1666 1666 1667 - if ((item = string_list_lookup(list, dst_name)) == NULL) 1667 + if (!(item = string_list_lookup(list, dst_name))) 1668 1668 return; 1669 1669 1670 1670 cmd->skip_update = 1; ··· 2538 2538 PACKET_READ_CHOMP_NEWLINE | 2539 2539 PACKET_READ_DIE_ON_ERR_PACKET); 2540 2540 2541 - if ((commands = read_head_info(&reader, &shallow)) != NULL) { 2541 + if ((commands = read_head_info(&reader, &shallow))) { 2542 2542 const char *unpack_status = NULL; 2543 2543 struct string_list push_options = STRING_LIST_INIT_DUP; 2544 2544
+1 -1
builtin/replace.c
··· 72 72 { 73 73 struct show_data data; 74 74 75 - if (pattern == NULL) 75 + if (!pattern) 76 76 pattern = "*"; 77 77 data.pattern = pattern; 78 78
+1 -1
builtin/rev-parse.c
··· 476 476 477 477 /* name(s) */ 478 478 s = strpbrk(sb.buf, flag_chars); 479 - if (s == NULL) 479 + if (!s) 480 480 s = help; 481 481 482 482 if (s - sb.buf == 1) /* short option only */
+1 -1
builtin/shortlog.c
··· 81 81 format_subject(&subject, oneline, " "); 82 82 buffer = strbuf_detach(&subject, NULL); 83 83 84 - if (item->util == NULL) 84 + if (!item->util) 85 85 item->util = xcalloc(1, sizeof(struct string_list)); 86 86 string_list_append(item->util, buffer); 87 87 }
+2 -2
builtin/tag.c
··· 364 364 strbuf_addstr(sb, "object of unknown type"); 365 365 break; 366 366 case OBJ_COMMIT: 367 - if ((buf = read_object_file(oid, &type, &size)) != NULL) { 367 + if ((buf = read_object_file(oid, &type, &size))) { 368 368 subject_len = find_commit_subject(buf, &subject_start); 369 369 strbuf_insert(sb, sb->len, subject_start, subject_len); 370 370 } else { ··· 372 372 } 373 373 free(buf); 374 374 375 - if ((c = lookup_commit_reference(the_repository, oid)) != NULL) 375 + if ((c = lookup_commit_reference(the_repository, oid))) 376 376 strbuf_addf(sb, ", %s", show_date(c->date, 0, DATE_MODE(SHORT))); 377 377 break; 378 378 case OBJ_TREE:
+2 -2
combine-diff.c
··· 195 195 struct lline *baseend, *newend = NULL; 196 196 int i, j, origbaselen = *lenbase; 197 197 198 - if (newline == NULL) 198 + if (!newline) 199 199 return base; 200 200 201 - if (base == NULL) { 201 + if (!base) { 202 202 *lenbase = lennew; 203 203 return newline; 204 204 }
+2 -2
commit-graph.c
··· 2567 2567 odb_parents = odb_commit->parents; 2568 2568 2569 2569 while (graph_parents) { 2570 - if (odb_parents == NULL) { 2570 + if (!odb_parents) { 2571 2571 graph_report(_("commit-graph parent list for commit %s is too long"), 2572 2572 oid_to_hex(&cur_oid)); 2573 2573 break; ··· 2590 2590 odb_parents = odb_parents->next; 2591 2591 } 2592 2592 2593 - if (odb_parents != NULL) 2593 + if (odb_parents) 2594 2594 graph_report(_("commit-graph parent list for commit %s terminates early"), 2595 2595 oid_to_hex(&cur_oid)); 2596 2596
+3 -3
compat/mingw.c
··· 1060 1060 int mkstemp(char *template) 1061 1061 { 1062 1062 char *filename = mktemp(template); 1063 - if (filename == NULL) 1063 + if (!filename) 1064 1064 return -1; 1065 1065 return open(filename, O_RDWR | O_CREAT, 0600); 1066 1066 } ··· 2332 2332 static const struct timeval zero; 2333 2333 static int atexit_done; 2334 2334 2335 - if (out != NULL) 2335 + if (out) 2336 2336 return errno = EINVAL, 2337 2337 error("setitimer param 3 != NULL not implemented"); 2338 2338 if (!is_timeval_eq(&in->it_interval, &zero) && ··· 2361 2361 if (sig != SIGALRM) 2362 2362 return errno = EINVAL, 2363 2363 error("sigaction only implemented for SIGALRM"); 2364 - if (out != NULL) 2364 + if (out) 2365 2365 return errno = EINVAL, 2366 2366 error("sigaction: param 3 != NULL not implemented"); 2367 2367
+1 -1
compat/mkdir.c
··· 9 9 size_t len = strlen(dir); 10 10 11 11 if (len && dir[len-1] == '/') { 12 - if ((tmp_dir = strdup(dir)) == NULL) 12 + if (!(tmp_dir = strdup(dir))) 13 13 return -1; 14 14 tmp_dir[len-1] = '\0'; 15 15 }
+1 -1
compat/mmap.c
··· 13 13 } 14 14 15 15 start = malloc(length); 16 - if (start == NULL) { 16 + if (!start) { 17 17 errno = ENOMEM; 18 18 return MAP_FAILED; 19 19 }
+4 -4
config.c
··· 3190 3190 goto out_free; 3191 3191 } 3192 3192 /* if nothing to unset, error out */ 3193 - if (value == NULL) { 3193 + if (!value) { 3194 3194 ret = CONFIG_NOTHING_SET; 3195 3195 goto out_free; 3196 3196 } ··· 3206 3206 int i, new_line = 0; 3207 3207 struct config_options opts; 3208 3208 3209 - if (value_pattern == NULL) 3209 + if (!value_pattern) 3210 3210 store.value_pattern = NULL; 3211 3211 else if (value_pattern == CONFIG_REGEX_NONE) 3212 3212 store.value_pattern = CONFIG_REGEX_NONE; ··· 3346 3346 } 3347 3347 3348 3348 /* write the pair (value == NULL means unset) */ 3349 - if (value != NULL) { 3349 + if (value) { 3350 3350 if (!store.section_seen) { 3351 3351 if (write_section(fd, key, &store) < 0) 3352 3352 goto write_err_out; ··· 3567 3567 offset = section_name_match(&buf[i], old_name); 3568 3568 if (offset > 0) { 3569 3569 ret++; 3570 - if (new_name == NULL) { 3570 + if (!new_name) { 3571 3571 remove = 1; 3572 3572 continue; 3573 3573 }
+30
contrib/coccinelle/equals-null.cocci
··· 1 + /* SPDX-License-Identifier: LGPL-2.1-or-later */ 2 + @@ 3 + expression e; 4 + statement s; 5 + @@ 6 + if ( 7 + ( 8 + !e 9 + | 10 + - e == NULL 11 + + !e 12 + ) 13 + ) 14 + {...} 15 + else s 16 + 17 + @@ 18 + expression e; 19 + statement s; 20 + @@ 21 + if ( 22 + ( 23 + e 24 + | 25 + - e != NULL 26 + + e 27 + ) 28 + ) 29 + {...} 30 + else s
+1 -1
daemon.c
··· 447 447 FILE *fp; 448 448 449 449 fp = fdopen(fd, "r"); 450 - if (fp == NULL) { 450 + if (!fp) { 451 451 logerror("fdopen of error channel failed"); 452 452 close(fd); 453 453 return;
+1 -1
dir.c
··· 3054 3054 * Skip scheme. 3055 3055 */ 3056 3056 start = strstr(repo, "://"); 3057 - if (start == NULL) 3057 + if (!start) 3058 3058 start = repo; 3059 3059 else 3060 3060 start += 3;
+1 -1
ewah/bitmap.c
··· 223 223 224 224 void bitmap_free(struct bitmap *bitmap) 225 225 { 226 - if (bitmap == NULL) 226 + if (!bitmap) 227 227 return; 228 228 229 229 free(bitmap->words);
+1 -1
ewah/ewah_bitmap.c
··· 451 451 452 452 void ewah_pool_free(struct ewah_bitmap *self) 453 453 { 454 - if (self == NULL) 454 + if (!self) 455 455 return; 456 456 457 457 if (bitmap_pool_size == BITMAP_POOL_MAX ||
+1 -1
http-fetch.c
··· 55 55 http_init(NULL, url, 0); 56 56 57 57 preq = new_direct_http_pack_request(packfile_hash->hash, xstrdup(url)); 58 - if (preq == NULL) 58 + if (!preq) 59 59 die("couldn't create http pack request"); 60 60 preq->slot->results = &results; 61 61 preq->index_pack_args = index_pack_args;
+6 -6
http-push.c
··· 253 253 struct http_object_request *obj_req; 254 254 255 255 obj_req = new_http_object_request(repo->url, &request->obj->oid); 256 - if (obj_req == NULL) { 256 + if (!obj_req) { 257 257 request->state = ABORTED; 258 258 return; 259 259 } ··· 318 318 fprintf(stderr, " which contains %s\n", oid_to_hex(&request->obj->oid)); 319 319 320 320 preq = new_http_pack_request(target->hash, repo->url); 321 - if (preq == NULL) { 321 + if (!preq) { 322 322 repo->can_update_info_refs = 0; 323 323 return; 324 324 } ··· 520 520 /* Keep locks active */ 521 521 check_locks(); 522 522 523 - if (request->headers != NULL) 523 + if (request->headers) 524 524 curl_slist_free_all(request->headers); 525 525 526 526 /* URL is reused for MOVE after PUT and used during FETCH */ ··· 783 783 const char *c = strchr(name, ':'); 784 784 int old_namelen, new_len; 785 785 786 - if (c == NULL) 786 + if (!c) 787 787 c = name; 788 788 else 789 789 c++; ··· 811 811 812 812 ctx->userFunc(ctx, 1); 813 813 814 - if (c == NULL) 814 + if (!c) 815 815 c = name; 816 816 else 817 817 c++; ··· 1893 1893 1894 1894 /* Lock remote branch ref */ 1895 1895 ref_lock = lock_remote(ref->name, LOCK_TIME); 1896 - if (ref_lock == NULL) { 1896 + if (!ref_lock) { 1897 1897 fprintf(stderr, "Unable to lock remote branch %s\n", 1898 1898 ref->name); 1899 1899 if (helper_status)
+7 -7
http-walker.c
··· 59 59 struct http_object_request *req; 60 60 61 61 req = new_http_object_request(obj_req->repo->base, &obj_req->oid); 62 - if (req == NULL) { 62 + if (!req) { 63 63 obj_req->state = ABORTED; 64 64 return; 65 65 } ··· 106 106 /* Use alternates if necessary */ 107 107 if (missing_target(obj_req->req)) { 108 108 fetch_alternates(walker, alt->base); 109 - if (obj_req->repo->next != NULL) { 109 + if (obj_req->repo->next) { 110 110 obj_req->repo = 111 111 obj_req->repo->next; 112 112 release_http_object_request(obj_req->req); ··· 225 225 alt_req->url->buf); 226 226 active_requests++; 227 227 slot->in_use = 1; 228 - if (slot->finished != NULL) 228 + if (slot->finished) 229 229 (*slot->finished) = 0; 230 230 if (!start_active_slot(slot)) { 231 231 cdata->got_alternates = -1; 232 232 slot->in_use = 0; 233 - if (slot->finished != NULL) 233 + if (slot->finished) 234 234 (*slot->finished) = 1; 235 235 } 236 236 return; ··· 443 443 } 444 444 445 445 preq = new_http_pack_request(target->hash, repo->base); 446 - if (preq == NULL) 446 + if (!preq) 447 447 goto abort; 448 448 preq->slot->results = &results; 449 449 ··· 489 489 if (hasheq(obj_req->oid.hash, hash)) 490 490 break; 491 491 } 492 - if (obj_req == NULL) 492 + if (!obj_req) 493 493 return error("Couldn't find request for %s in the queue", hex); 494 494 495 495 if (has_object_file(&obj_req->oid)) { 496 - if (obj_req->req != NULL) 496 + if (obj_req->req) 497 497 abort_http_object_request(obj_req->req); 498 498 abort_object_request(obj_req); 499 499 return 0;
+23 -23
http.c
··· 197 197 closedown_active_slot(slot); 198 198 curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE, &slot->http_code); 199 199 200 - if (slot->finished != NULL) 200 + if (slot->finished) 201 201 (*slot->finished) = 1; 202 202 203 203 /* Store slot results so they can be read after the slot is reused */ 204 - if (slot->results != NULL) { 204 + if (slot->results) { 205 205 slot->results->curl_result = slot->curl_result; 206 206 slot->results->http_code = slot->http_code; 207 207 curl_easy_getinfo(slot->curl, CURLINFO_HTTPAUTH_AVAIL, ··· 212 212 } 213 213 214 214 /* Run callback if appropriate */ 215 - if (slot->callback_func != NULL) 215 + if (slot->callback_func) 216 216 slot->callback_func(slot->callback_data); 217 217 } 218 218 ··· 234 234 while (slot != NULL && 235 235 slot->curl != curl_message->easy_handle) 236 236 slot = slot->next; 237 - if (slot != NULL) { 237 + if (slot) { 238 238 xmulti_remove_handle(slot); 239 239 slot->curl_result = curl_result; 240 240 finish_active_slot(slot); ··· 838 838 curl_easy_setopt(result, CURLOPT_SSL_CIPHER_LIST, 839 839 ssl_cipherlist); 840 840 841 - if (ssl_cert != NULL) 841 + if (ssl_cert) 842 842 curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert); 843 843 if (has_cert_password()) 844 844 curl_easy_setopt(result, CURLOPT_KEYPASSWD, cert_auth.password); 845 - if (ssl_key != NULL) 845 + if (ssl_key) 846 846 curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key); 847 - if (ssl_capath != NULL) 847 + if (ssl_capath) 848 848 curl_easy_setopt(result, CURLOPT_CAPATH, ssl_capath); 849 849 #ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY 850 - if (ssl_pinnedkey != NULL) 850 + if (ssl_pinnedkey) 851 851 curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey); 852 852 #endif 853 853 if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) && ··· 857 857 curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, NULL); 858 858 #endif 859 859 } else if (ssl_cainfo != NULL || http_proxy_ssl_ca_info != NULL) { 860 - if (ssl_cainfo != NULL) 860 + if (ssl_cainfo) 861 861 curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo); 862 862 #ifdef GIT_CURL_HAVE_CURLOPT_PROXY_CAINFO 863 - if (http_proxy_ssl_ca_info != NULL) 863 + if (http_proxy_ssl_ca_info) 864 864 curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, http_proxy_ssl_ca_info); 865 865 #endif 866 866 } ··· 1050 1050 1051 1051 { 1052 1052 char *http_max_requests = getenv("GIT_HTTP_MAX_REQUESTS"); 1053 - if (http_max_requests != NULL) 1053 + if (http_max_requests) 1054 1054 max_requests = atoi(http_max_requests); 1055 1055 } 1056 1056 ··· 1069 1069 set_from_env(&user_agent, "GIT_HTTP_USER_AGENT"); 1070 1070 1071 1071 low_speed_limit = getenv("GIT_HTTP_LOW_SPEED_LIMIT"); 1072 - if (low_speed_limit != NULL) 1072 + if (low_speed_limit) 1073 1073 curl_low_speed_limit = strtol(low_speed_limit, NULL, 10); 1074 1074 low_speed_time = getenv("GIT_HTTP_LOW_SPEED_TIME"); 1075 - if (low_speed_time != NULL) 1075 + if (low_speed_time) 1076 1076 curl_low_speed_time = strtol(low_speed_time, NULL, 10); 1077 1077 1078 1078 if (curl_ssl_verify == -1) ··· 1109 1109 1110 1110 while (slot != NULL) { 1111 1111 struct active_request_slot *next = slot->next; 1112 - if (slot->curl != NULL) { 1112 + if (slot->curl) { 1113 1113 xmulti_remove_handle(slot); 1114 1114 curl_easy_cleanup(slot->curl); 1115 1115 } ··· 1147 1147 free((void *)http_proxy_authmethod); 1148 1148 http_proxy_authmethod = NULL; 1149 1149 1150 - if (cert_auth.password != NULL) { 1150 + if (cert_auth.password) { 1151 1151 memset(cert_auth.password, 0, strlen(cert_auth.password)); 1152 1152 FREE_AND_NULL(cert_auth.password); 1153 1153 } 1154 1154 ssl_cert_password_required = 0; 1155 1155 1156 - if (proxy_cert_auth.password != NULL) { 1156 + if (proxy_cert_auth.password) { 1157 1157 memset(proxy_cert_auth.password, 0, strlen(proxy_cert_auth.password)); 1158 1158 FREE_AND_NULL(proxy_cert_auth.password); 1159 1159 } ··· 1179 1179 while (slot != NULL && slot->in_use) 1180 1180 slot = slot->next; 1181 1181 1182 - if (slot == NULL) { 1182 + if (!slot) { 1183 1183 newslot = xmalloc(sizeof(*newslot)); 1184 1184 newslot->curl = NULL; 1185 1185 newslot->in_use = 0; 1186 1186 newslot->next = NULL; 1187 1187 1188 1188 slot = active_queue_head; 1189 - if (slot == NULL) { 1189 + if (!slot) { 1190 1190 active_queue_head = newslot; 1191 1191 } else { 1192 1192 while (slot->next != NULL) ··· 1196 1196 slot = newslot; 1197 1197 } 1198 1198 1199 - if (slot->curl == NULL) { 1199 + if (!slot->curl) { 1200 1200 slot->curl = curl_easy_duphandle(curl_default); 1201 1201 curl_session_count++; 1202 1202 } ··· 1768 1768 slot = get_active_slot(); 1769 1769 curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1); 1770 1770 1771 - if (result == NULL) { 1771 + if (!result) { 1772 1772 curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1); 1773 1773 } else { 1774 1774 curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0); ··· 2100 2100 2101 2101 void release_http_pack_request(struct http_pack_request *preq) 2102 2102 { 2103 - if (preq->packfile != NULL) { 2103 + if (preq->packfile) { 2104 2104 fclose(preq->packfile); 2105 2105 preq->packfile = NULL; 2106 2106 } ··· 2391 2391 2392 2392 void process_http_object_request(struct http_object_request *freq) 2393 2393 { 2394 - if (freq->slot == NULL) 2394 + if (!freq->slot) 2395 2395 return; 2396 2396 freq->curl_result = freq->slot->curl_result; 2397 2397 freq->http_code = freq->slot->http_code; ··· 2448 2448 freq->localfile = -1; 2449 2449 } 2450 2450 FREE_AND_NULL(freq->url); 2451 - if (freq->slot != NULL) { 2451 + if (freq->slot) { 2452 2452 freq->slot->callback_func = NULL; 2453 2453 freq->slot->callback_data = NULL; 2454 2454 release_active_slot(freq->slot);
+2 -2
kwset.c
··· 477 477 next[i] = NULL; 478 478 treenext(kwset->trie->links, next); 479 479 480 - if ((trans = kwset->trans) != NULL) 480 + if ((trans = kwset->trans)) 481 481 for (i = 0; i < NCHAR; ++i) 482 482 kwset->next[i] = next[U(trans[i])]; 483 483 else ··· 485 485 } 486 486 487 487 /* Fix things up for any translation table. */ 488 - if ((trans = kwset->trans) != NULL) 488 + if ((trans = kwset->trans)) 489 489 for (i = 0; i < NCHAR; ++i) 490 490 kwset->delta[i] = delta[U(trans[i])]; 491 491 else
+1 -1
ll-merge.c
··· 207 207 dict[4].placeholder = "P"; dict[4].value = path_sq.buf; 208 208 dict[5].placeholder = NULL; dict[5].value = NULL; 209 209 210 - if (fn->cmdline == NULL) 210 + if (!fn->cmdline) 211 211 die("custom merge driver %s lacks command line.", fn->name); 212 212 213 213 result->ptr = NULL;
+1 -1
log-tree.c
··· 88 88 const struct string_list_item *item) 89 89 { 90 90 int matched = 0; 91 - if (item->util == NULL) { 91 + if (!item->util) { 92 92 if (!wildmatch(item->string, refname, 0)) 93 93 matched = 1; 94 94 } else {
+2 -2
mailinfo.c
··· 698 698 continue; 699 699 } 700 700 last_nonblank = c; 701 - if (first_nonblank == NULL) 701 + if (!first_nonblank) 702 702 first_nonblank = c; 703 703 if (*c == '-') { 704 704 in_perforation = 1; ··· 1094 1094 */ 1095 1095 lines = strbuf_split(line, '\n'); 1096 1096 for (it = lines; (sb = *it); it++) { 1097 - if (*(it + 1) == NULL) /* The last line */ 1097 + if (!*(it + 1)) /* The last line */ 1098 1098 if (sb->buf[sb->len - 1] != '\n') { 1099 1099 /* Partial line, save it for later. */ 1100 1100 strbuf_addbuf(&prev, sb);
+7 -7
mailmap.c
··· 77 77 struct mailmap_entry *me; 78 78 struct string_list_item *item; 79 79 80 - if (old_email == NULL) { 80 + if (!old_email) { 81 81 old_email = new_email; 82 82 new_email = NULL; 83 83 } ··· 92 92 item->util = me; 93 93 } 94 94 95 - if (old_name == NULL) { 95 + if (!old_name) { 96 96 debug_mm("mailmap: adding (simple) entry for '%s'\n", old_email); 97 97 98 98 /* Replace current name and new email for simple entry */ ··· 123 123 char *left, *right, *nstart, *nend; 124 124 *name = *email = NULL; 125 125 126 - if ((left = strchr(buffer, '<')) == NULL) 126 + if (!(left = strchr(buffer, '<'))) 127 127 return NULL; 128 - if ((right = strchr(left+1, '>')) == NULL) 128 + if (!(right = strchr(left + 1, '>'))) 129 129 return NULL; 130 130 if (!allow_empty_email && (left+1 == right)) 131 131 return NULL; ··· 153 153 if (buffer[0] == '#') 154 154 return; 155 155 156 - if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)) != NULL) 156 + if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0))) 157 157 parse_name_and_email(name2, &name2, &email2, 1); 158 158 159 159 if (email1) ··· 320 320 (int)*emaillen, debug_str(*email)); 321 321 322 322 item = lookup_prefix(map, *email, *emaillen); 323 - if (item != NULL) { 323 + if (item) { 324 324 me = (struct mailmap_entry *)item->util; 325 325 if (me->namemap.nr) { 326 326 /* ··· 334 334 item = subitem; 335 335 } 336 336 } 337 - if (item != NULL) { 337 + if (item) { 338 338 struct mailmap_info *mi = (struct mailmap_info *)item->util; 339 339 if (mi->name == NULL && mi->email == NULL) { 340 340 debug_mm("map_user: -- (no simple mapping)\n");
+2 -2
merge-ort.c
··· 2068 2068 * to ensure that's the case. 2069 2069 */ 2070 2070 c_info = strmap_get(collisions, new_path); 2071 - if (c_info == NULL) 2071 + if (!c_info) 2072 2072 BUG("c_info is NULL"); 2073 2073 2074 2074 /* ··· 4640 4640 } 4641 4641 4642 4642 merged_merge_bases = pop_commit(&merge_bases); 4643 - if (merged_merge_bases == NULL) { 4643 + if (!merged_merge_bases) { 4644 4644 /* if there is no common ancestor, use an empty tree */ 4645 4645 struct tree *tree; 4646 4646
+6 -6
merge-recursive.c
··· 82 82 { 83 83 struct dir_rename_entry key; 84 84 85 - if (dir == NULL) 85 + if (!dir) 86 86 return NULL; 87 87 hashmap_entry_init(&key.ent, strhash(dir)); 88 88 key.dir = dir; ··· 1990 1990 * renamed means the root directory can never be renamed -- because 1991 1991 * the root directory always exists). 1992 1992 */ 1993 - if (end_of_old == NULL) 1993 + if (!end_of_old) 1994 1994 return; /* Note: *old_dir and *new_dir are still NULL */ 1995 1995 1996 1996 /* 1997 1997 * If new_path contains no directory (end_of_new is NULL), then we 1998 1998 * have a rename of old_path's directory to the root directory. 1999 1999 */ 2000 - if (end_of_new == NULL) { 2000 + if (!end_of_new) { 2001 2001 *old_dir = xstrndup(old_path, end_of_old - old_path); 2002 2002 *new_dir = xstrdup(""); 2003 2003 return; ··· 2116 2116 * to ensure that's the case. 2117 2117 */ 2118 2118 collision_ent = collision_find_entry(collisions, new_path); 2119 - if (collision_ent == NULL) 2119 + if (!collision_ent) 2120 2120 BUG("collision_ent is NULL"); 2121 2121 2122 2122 /* ··· 2996 2996 const struct rename *re; 2997 2997 int i; 2998 2998 2999 - if (rename == NULL) 2999 + if (!rename) 3000 3000 return; 3001 3001 3002 3002 for (i = 0; i < rename->nr; i++) { ··· 3605 3605 } 3606 3606 3607 3607 merged_merge_bases = pop_commit(&merge_bases); 3608 - if (merged_merge_bases == NULL) { 3608 + if (!merged_merge_bases) { 3609 3609 /* if there is no common ancestor, use an empty tree */ 3610 3610 struct tree *tree; 3611 3611
+1 -1
object-file.c
··· 1728 1728 die(_("loose object %s (stored in %s) is corrupt"), 1729 1729 oid_to_hex(repl), path); 1730 1730 1731 - if ((p = has_packed_and_bad(r, repl)) != NULL) 1731 + if ((p = has_packed_and_bad(r, repl))) 1732 1732 die(_("packed object %s (stored in %s) is corrupt"), 1733 1733 oid_to_hex(repl), p->pack_name); 1734 1734 obj_read_unlock();
+7 -7
pack-bitmap.c
··· 111 111 struct ewah_bitmap *parent; 112 112 struct ewah_bitmap *composed; 113 113 114 - if (st->xor == NULL) 114 + if (!st->xor) 115 115 return st->root; 116 116 117 117 composed = ewah_pool_new(); ··· 279 279 if (xor_offset > 0) { 280 280 xor_bitmap = recent_bitmaps[(i - xor_offset) % MAX_XOR_OFFSET]; 281 281 282 - if (xor_bitmap == NULL) 282 + if (!xor_bitmap) 283 283 return error("Invalid XOR offset in bitmap pack index"); 284 284 } 285 285 ··· 728 728 if (!or_with) 729 729 return 0; 730 730 731 - if (*base == NULL) 731 + if (!*base) 732 732 *base = ewah_to_bitmap(or_with); 733 733 else 734 734 bitmap_or_ewah(*base, or_with); ··· 771 771 * Best case scenario: We found bitmaps for all the roots, 772 772 * so the resulting `or` bitmap has the full reachability analysis 773 773 */ 774 - if (not_mapped == NULL) 774 + if (!not_mapped) 775 775 return base; 776 776 777 777 roots = not_mapped; ··· 805 805 struct include_data incdata; 806 806 struct bitmap_show_data show_data; 807 807 808 - if (base == NULL) 808 + if (!base) 809 809 base = bitmap_new(); 810 810 811 811 incdata.bitmap_git = bitmap_git; ··· 1299 1299 reset_revision_walk(); 1300 1300 revs->ignore_missing_links = 0; 1301 1301 1302 - if (haves_bitmap == NULL) 1302 + if (!haves_bitmap) 1303 1303 BUG("failed to perform bitmap walk"); 1304 1304 } 1305 1305 ··· 1698 1698 result = ewah_to_bitmap(bm); 1699 1699 } 1700 1700 1701 - if (result == NULL) 1701 + if (!result) 1702 1702 die("Commit %s doesn't have an indexed bitmap", oid_to_hex(&root->oid)); 1703 1703 1704 1704 revs->tag_objects = 1;
+1 -1
packfile.c
··· 116 116 117 117 if (idx_size < 4 * 256 + hashsz + hashsz) 118 118 return error("index file %s is too small", path); 119 - if (idx_map == NULL) 119 + if (!idx_map) 120 120 return error("empty data"); 121 121 122 122 if (hdr->idx_signature == htonl(PACK_IDX_SIGNATURE)) {
+1 -1
path.c
··· 733 733 struct strbuf user_path = STRBUF_INIT; 734 734 const char *to_copy = path; 735 735 736 - if (path == NULL) 736 + if (!path) 737 737 goto return_null; 738 738 739 739 if (skip_prefix(path, "%(prefix)/", &path))
+1 -1
prio-queue.c
··· 19 19 { 20 20 int i, j; 21 21 22 - if (queue->compare != NULL) 22 + if (queue->compare) 23 23 BUG("prio_queue_reverse() on non-LIFO queue"); 24 24 for (i = 0; i < (j = (queue->nr - 1) - i); i++) 25 25 swap(queue, i, j);
+1 -1
promisor-remote.c
··· 84 84 struct promisor_remote *r, 85 85 struct promisor_remote *previous) 86 86 { 87 - if (r->next == NULL) 87 + if (!r->next) 88 88 return; 89 89 90 90 if (previous)
+3 -3
ref-filter.c
··· 1261 1261 * ":" means no format is specified, and use the default. 1262 1262 */ 1263 1263 formatp = strchr(atomname, ':'); 1264 - if (formatp != NULL) { 1264 + if (formatp) { 1265 1265 formatp++; 1266 1266 parse_date_format(formatp, &date_mode); 1267 1267 } ··· 1509 1509 int i; 1510 1510 for (i = 0; i < used_atom_cnt; i++) { 1511 1511 struct atom_value *v = &val[i]; 1512 - if (v->s == NULL) 1512 + if (!v->s) 1513 1513 v->s = xstrdup(""); 1514 1514 } 1515 1515 } ··· 1619 1619 1620 1620 while (remaining-- > 0) { 1621 1621 char *p = strrchr(start, '/'); 1622 - if (p == NULL) { 1622 + if (!p) { 1623 1623 free((char *)to_free); 1624 1624 return xstrdup(""); 1625 1625 } else
+1 -1
refs/ref-cache.c
··· 134 134 r = bsearch(&key, dir->entries, dir->nr, sizeof(*dir->entries), 135 135 ref_entry_cmp_sslice); 136 136 137 - if (r == NULL) 137 + if (!r) 138 138 return -1; 139 139 140 140 return r - dir->entries;
+1 -1
reftable/stack_test.c
··· 35 35 DIR *dir = opendir(dirname); 36 36 int len = 0; 37 37 struct dirent *d; 38 - if (dir == NULL) 38 + if (!dir) 39 39 return 0; 40 40 41 41 while ((d = readdir(dir))) {
+2 -2
reftable/tree.c
··· 16 16 int insert) 17 17 { 18 18 int res; 19 - if (*rootp == NULL) { 19 + if (!*rootp) { 20 20 if (!insert) { 21 21 return NULL; 22 22 } else { ··· 50 50 51 51 void tree_free(struct tree_node *t) 52 52 { 53 - if (t == NULL) { 53 + if (!t) { 54 54 return; 55 55 } 56 56 if (t->left) {
+6 -6
reftable/writer.c
··· 183 183 struct tree_node *node = tree_search(&want, &w->obj_index_tree, 184 184 &obj_index_tree_node_compare, 0); 185 185 struct obj_index_tree_node *key = NULL; 186 - if (node == NULL) { 186 + if (!node) { 187 187 struct obj_index_tree_node empty = OBJ_INDEX_TREE_NODE_INIT; 188 188 key = reftable_malloc(sizeof(struct obj_index_tree_node)); 189 189 *key = empty; ··· 222 222 223 223 strbuf_reset(&w->last_key); 224 224 strbuf_addbuf(&w->last_key, &key); 225 - if (w->block_writer == NULL) { 225 + if (!w->block_writer) { 226 226 writer_reinit_block_writer(w, reftable_record_type(rec)); 227 227 } 228 228 ··· 263 263 }; 264 264 int err = 0; 265 265 266 - if (ref->refname == NULL) 266 + if (!ref->refname) 267 267 return REFTABLE_API_ERROR; 268 268 if (ref->update_index < w->min_update_index || 269 269 ref->update_index > w->max_update_index) ··· 336 336 if (log->value_type == REFTABLE_LOG_DELETION) 337 337 return reftable_writer_add_log_verbatim(w, log); 338 338 339 - if (log->refname == NULL) 339 + if (!log->refname) 340 340 return REFTABLE_API_ERROR; 341 341 342 342 input_log_message = log->value.update.message; ··· 545 545 uint8_t typ = 0; 546 546 int err = 0; 547 547 548 - if (w->block_writer == NULL) 548 + if (!w->block_writer) 549 549 return 0; 550 550 551 551 typ = block_writer_type(w->block_writer); ··· 694 694 695 695 static int writer_flush_block(struct reftable_writer *w) 696 696 { 697 - if (w->block_writer == NULL) 697 + if (!w->block_writer) 698 698 return 0; 699 699 if (w->block_writer->entries == 0) 700 700 return 0;
+1 -1
rerere.c
··· 591 591 else if (conflict_type == RESOLVED) { 592 592 struct string_list_item *it; 593 593 it = string_list_lookup(merge_rr, (const char *)e->name); 594 - if (it != NULL) { 594 + if (it) { 595 595 free_rerere_id(it); 596 596 it->util = RERERE_RESOLVED; 597 597 }
+2 -2
revision.c
··· 2833 2833 } 2834 2834 strvec_clear(&prune_data); 2835 2835 2836 - if (revs->def == NULL) 2836 + if (!revs->def) 2837 2837 revs->def = opt ? opt->def : NULL; 2838 2838 if (opt && opt->tweak) 2839 2839 opt->tweak(revs, opt); ··· 3652 3652 return rewrite_one_ok; 3653 3653 if (!p->parents) 3654 3654 return rewrite_one_noparents; 3655 - if ((p = one_relevant_parent(revs, p->parents)) == NULL) 3655 + if (!(p = one_relevant_parent(revs, p->parents))) 3656 3656 return rewrite_one_ok; 3657 3657 *pp = p; 3658 3658 }
+1 -1
setup.c
··· 1470 1470 int i; 1471 1471 char *endptr; 1472 1472 1473 - if (value == NULL) 1473 + if (!value) 1474 1474 return PERM_GROUP; 1475 1475 1476 1476 if (!strcmp(value, "umask"))
+1 -1
sh-i18n--envsubst.c
··· 397 397 /* Substitute the variable's value from the environment. */ 398 398 const char *env_value = getenv (buffer); 399 399 400 - if (env_value != NULL) 400 + if (env_value) 401 401 fputs (env_value, stdout); 402 402 } 403 403 else
+1 -1
shallow.c
··· 560 560 else 561 561 c->object.flags |= SEEN; 562 562 563 - if (*refs == NULL) 563 + if (!*refs) 564 564 *refs = bitmap; 565 565 else { 566 566 memcpy(tmp, *refs, bitmap_size);
+1 -1
trailer.c
··· 1029 1029 1030 1030 /* Create temporary file in the same directory as the original */ 1031 1031 tail = strrchr(file, '/'); 1032 - if (tail != NULL) 1032 + if (tail) 1033 1033 strbuf_add(&filename_template, file, tail - file + 1); 1034 1034 strbuf_addstr(&filename_template, "git-interpret-trailers-XXXXXX"); 1035 1035
+1 -1
transport.c
··· 438 438 args.self_contained_and_connected; 439 439 data->options.connectivity_checked = args.connectivity_checked; 440 440 441 - if (refs == NULL) 441 + if (!refs) 442 442 ret = -1; 443 443 if (report_unmatched_refs(to_fetch, nr_heads)) 444 444 ret = -1;
+1 -1
wildmatch.c
··· 113 113 /* Trailing "**" matches everything. Trailing "*" matches 114 114 * only if there are no more slash characters. */ 115 115 if (!match_slash) { 116 - if (strchr((char*)text, '/') != NULL) 116 + if (strchr((char *)text, '/')) 117 117 return WM_NOMATCH; 118 118 } 119 119 return WM_MATCH;
+1 -1
worktree.c
··· 483 483 return 0; 484 484 485 485 d = readdir_skip_dot_and_dotdot(dir); 486 - if (d != NULL) 486 + if (d) 487 487 ret = 1; 488 488 closedir(dir); 489 489 return ret;
+1 -1
wrapper.c
··· 393 393 FILE *xfdopen(int fd, const char *mode) 394 394 { 395 395 FILE *stream = fdopen(fd, mode); 396 - if (stream == NULL) 396 + if (!stream) 397 397 die_errno("Out of memory? fdopen failed"); 398 398 return stream; 399 399 }
+1 -1
xdiff-interface.c
··· 159 159 160 160 if (stat(filename, &st)) 161 161 return error_errno("Could not stat %s", filename); 162 - if ((f = fopen(filename, "rb")) == NULL) 162 + if (!(f = fopen(filename, "rb"))) 163 163 return error_errno("Could not open %s", filename); 164 164 sz = xsize_t(st.st_size); 165 165 ptr->ptr = xmalloc(sz ? sz : 1);
+1 -1
xdiff/xemit.c
··· 65 65 *xscr = xch; 66 66 } 67 67 68 - if (*xscr == NULL) 68 + if (!*xscr) 69 69 return NULL; 70 70 71 71 lxch = *xscr;
+1 -1
xdiff/xprepare.c
··· 188 188 memset(rhash, 0, hsize * sizeof(xrecord_t *)); 189 189 190 190 nrec = 0; 191 - if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) { 191 + if ((cur = blk = xdl_mmfile_first(mf, &bsize))) { 192 192 for (top = blk + bsize; cur < top; ) { 193 193 prev = cur; 194 194 hav = xdl_hash_record(&cur, top, xpp->flags);
+1 -1
xdiff/xutils.c
··· 122 122 long nl = 0, size, tsize = 0; 123 123 char const *data, *cur, *top; 124 124 125 - if ((cur = data = xdl_mmfile_first(mf, &size)) != NULL) { 125 + if ((cur = data = xdl_mmfile_first(mf, &size))) { 126 126 for (top = data + size; nl < sample && cur < top; ) { 127 127 nl++; 128 128 if (!(cur = memchr(cur, '\n', top - cur)))