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