···466 break;
467 }
468469- 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 }
468469+ 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"));
435436- 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"));
435436+ 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);
···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);
11111112- if (remote_name == NULL)
1113 remote_name = xstrdup("origin");
11141115 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);
11111112+ if (!remote_name)
1113 remote_name = xstrdup("origin");
11141115 if (!valid_remote_name(remote_name))
+1-1
builtin/commit.c
···861 }
862863 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());
866867 /* Ignore status.displayCommentPrefix: we do need comments in COMMIT_EDITMSG. */
···861 }
862863 s->fp = fopen_for_writing(git_path_commit_editmsg());
864+ if (!s->fp)
865 die_errno(_("could not open '%s'"), git_path_commit_editmsg());
866867 /* Ignore status.displayCommentPrefix: we do need comments in COMMIT_EDITMSG. */
···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;
22432244 unit = "# This file was created and is maintained by Git.\n"
···22672268 filename = xdg_config_home_systemd("git-maintenance@.service");
2269 file = fopen_or_warn(filename, "w");
2270- if (file == NULL)
2271 goto error;
22722273 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;
22432244 unit = "# This file was created and is maintained by Git.\n"
···22672268 filename = xdg_config_home_systemd("git-maintenance@.service");
2269 file = fopen_or_warn(filename, "w");
2270+ if (!file)
2271 goto error;
22722273 unit = "# This file was created and is maintained by Git.\n"
···477 next[i] = NULL;
478 treenext(kwset->trie->links, next);
479480- if ((trans = kwset->trans) != NULL)
481 for (i = 0; i < NCHAR; ++i)
482 kwset->next[i] = next[U(trans[i])];
483 else
···485 }
486487 /* 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);
479480+ if ((trans = kwset->trans))
481 for (i = 0; i < NCHAR; ++i)
482 kwset->next[i] = next[U(trans[i])];
483 else
···485 }
486487 /* 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
···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;
7980- if (old_email == NULL) {
81 old_email = new_email;
82 new_email = NULL;
83 }
···92 item->util = me;
93 }
9495- if (old_name == NULL) {
96 debug_mm("mailmap: adding (simple) entry for '%s'\n", old_email);
9798 /* Replace current name and new email for simple entry */
···123 char *left, *right, *nstart, *nend;
124 *name = *email = NULL;
125126- 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;
155156- if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)) != NULL)
157 parse_name_and_email(name2, &name2, &email2, 1);
158159 if (email1)
···320 (int)*emaillen, debug_str(*email));
321322 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;
7980+ if (!old_email) {
81 old_email = new_email;
82 new_email = NULL;
83 }
···92 item->util = me;
93 }
9495+ if (!old_name) {
96 debug_mm("mailmap: adding (simple) entry for '%s'\n", old_email);
9798 /* Replace current name and new email for simple entry */
···123 char *left, *right, *nstart, *nend;
124 *name = *email = NULL;
125126+ 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;
155156+ if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)))
157 parse_name_and_email(name2, &name2, &email2, 1);
158159 if (email1)
···320 (int)*emaillen, debug_str(*email));
321322 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");
20732074 /*
···4640 }
46414642 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");
20732074 /*
···4640 }
46414642 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;
8485- 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 */
19951996 /*
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");
21212122 /*
···2996 const struct rename *re;
2997 int i;
29982999- if (rename == NULL)
3000 return;
30013002 for (i = 0; i < rename->nr; i++) {
···3605 }
36063607 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;
8485+ 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 */
19951996 /*
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");
21212122 /*
···2996 const struct rename *re;
2997 int i;
29982999+ if (!rename)
3000 return;
30013002 for (i = 0; i < rename->nr; i++) {
···3605 }
36063607 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);
17301731- 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);
17301731+ 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;
113114- if (st->xor == NULL)
115 return st->root;
116117 composed = ewah_pool_new();
···279 if (xor_offset > 0) {
280 xor_bitmap = recent_bitmaps[(i - xor_offset) % MAX_XOR_OFFSET];
281282- if (xor_bitmap == NULL)
283 return error("Invalid XOR offset in bitmap pack index");
284 }
285···728 if (!or_with)
729 return 0;
730731- 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;
776777 roots = not_mapped;
···805 struct include_data incdata;
806 struct bitmap_show_data show_data;
807808- if (base == NULL)
809 base = bitmap_new();
810811 incdata.bitmap_git = bitmap_git;
···1299 reset_revision_walk();
1300 revs->ignore_missing_links = 0;
13011302- if (haves_bitmap == NULL)
1303 BUG("failed to perform bitmap walk");
1304 }
1305···1698 result = ewah_to_bitmap(bm);
1699 }
17001701- if (result == NULL)
1702 die("Commit %s doesn't have an indexed bitmap", oid_to_hex(&root->oid));
17031704 revs->tag_objects = 1;
···111 struct ewah_bitmap *parent;
112 struct ewah_bitmap *composed;
113114+ if (!st->xor)
115 return st->root;
116117 composed = ewah_pool_new();
···279 if (xor_offset > 0) {
280 xor_bitmap = recent_bitmaps[(i - xor_offset) % MAX_XOR_OFFSET];
281282+ if (!xor_bitmap)
283 return error("Invalid XOR offset in bitmap pack index");
284 }
285···728 if (!or_with)
729 return 0;
730731+ 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;
776777 roots = not_mapped;
···805 struct include_data incdata;
806 struct bitmap_show_data show_data;
807808+ if (!base)
809 base = bitmap_new();
810811 incdata.bitmap_git = bitmap_git;
···1299 reset_revision_walk();
1300 revs->ignore_missing_links = 0;
13011302+ if (!haves_bitmap)
1303 BUG("failed to perform bitmap walk");
1304 }
1305···1698 result = ewah_to_bitmap(bm);
1699 }
17001701+ if (!result)
1702 die("Commit %s doesn't have an indexed bitmap", oid_to_hex(&root->oid));
17031704 revs->tag_objects = 1;
+1-1
packfile.c
···116117 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");
121122 if (hdr->idx_signature == htonl(PACK_IDX_SIGNATURE)) {
···116117 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");
121122 if (hdr->idx_signature == htonl(PACK_IDX_SIGNATURE)) {
···19{
20 int i, j;
2122- 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;
2122+ 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;
8990 if (previous)
···84 struct promisor_remote *r,
85 struct promisor_remote *previous)
86{
87+ if (!r->next)
88 return;
8990 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}
···16191620 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}
···16191620 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);
136137- if (r == NULL)
138 return -1;
139140 return r - dir->entries;
···134 r = bsearch(&key, dir->entries, dir->nr, sizeof(*dir->entries),
135 ref_entry_cmp_sslice);
136137+ if (!r)
138 return -1;
139140 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;
4041 while ((d = readdir(dir))) {
···35 DIR *dir = opendir(dirname);
36 int len = 0;
37 struct dirent *d;
38+ if (!dir)
39 return 0;
4041 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 {
···5051void 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 {
···5051void tree_free(struct tree_node *t)
52{
53+ if (!t) {
54 return;
55 }
56 if (t->left) {
···10291030 /* 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
···10291030 /* 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;
440441- 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;
440441+ 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;
484485 d = readdir_skip_dot_and_dotdot(dir);
486- if (d != NULL)
487 ret = 1;
488 closedir(dir);
489 return ret;
···483 return 0;
484485 d = readdir_skip_dot_and_dotdot(dir);
486+ if (d)
487 ret = 1;
488 closedir(dir);
489 return ret;