tree-wide: apply equals-null.cocci

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed May 2, 2022 at 09:50 UTC afe8a9070bc62db9cfde1e30147178c40d391d93
63 files changed +141 -141
apply.c
+3 -3
@@ -3267,11 +3267,11 @@ static struct patch *in_fn_table(struct apply_state *state, const char *name)
3267 {
3268 struct string_list_item *item;
3269
3270 - if (name == NULL)
3270 + if (!name)
3271 return NULL;
3272
3273 item = string_list_lookup(&state->fn_table, name);
3274 - if (item != NULL)
3274 + if (item)
3275 return (struct patch *)item->util;
3276
3277 return NULL;
@@ -3311,7 +3311,7 @@ static void add_to_fn_table(struct apply_state *state, struct patch *patch)
3311 * This should cover the cases for normal diffs,
3312 * file creations and copies
3313 */
3314 - if (patch->new_name != NULL) {
3314 + if (patch->new_name) {
3315 item = string_list_insert(&state->fn_table, patch->new_name);
3316 item->util = patch;
3317 }
archive.c
+1 -1
@@ -465,7 +465,7 @@ static void parse_treeish_arg(const char **argv,
465 }
466
467 tree = parse_tree_indirect(&oid);
468 - if (tree == NULL)
468 + if (!tree)
469 die(_("not a tree object: %s"), oid_to_hex(&oid));
470
471 if (prefix) {
blame.c
+3 -3
@@ -1072,7 +1072,7 @@ static struct blame_entry *blame_merge(struct blame_entry *list1,
1072 if (p1->s_lno <= p2->s_lno) {
1073 do {
1074 tail = &p1->next;
1075 - if ((p1 = *tail) == NULL) {
1075 + if (!(p1 = *tail)) {
1076 *tail = p2;
1077 return list1;
1078 }
@@ -1082,7 +1082,7 @@ static struct blame_entry *blame_merge(struct blame_entry *list1,
1082 *tail = p2;
1083 do {
1084 tail = &p2->next;
1085 - if ((p2 = *tail) == NULL) {
1085 + if (!(p2 = *tail)) {
1086 *tail = p1;
1087 return list1;
1088 }
@@ -1090,7 +1090,7 @@ static struct blame_entry *blame_merge(struct blame_entry *list1,
1090 *tail = p1;
1091 do {
1092 tail = &p1->next;
1093 - if ((p1 = *tail) == NULL) {
1093 + if (!(p1 = *tail)) {
1094 *tail = p2;
1095 return list1;
1096 }
branch.c
+1 -1
@@ -302,7 +302,7 @@ void create_branch(struct repository *r,
302 break;
303 }
304
305 - if ((commit = lookup_commit_reference(r, &oid)) == NULL)
305 + if (!(commit = lookup_commit_reference(r, &oid)))
306 die(_("Not a valid branch point: '%s'."), start_name);
307 oidcpy(&oid, &commit->object.oid);
308
builtin/bisect--helper.c
+1 -1
@@ -433,7 +433,7 @@ static int bisect_terms(struct bisect_terms *terms, const char *option)
433 if (get_terms(terms))
434 return error(_("no terms defined"));
435
436 - if (option == NULL) {
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);
builtin/checkout.c
+1 -1
@@ -811,7 +811,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
811 if (ret)
812 return ret;
813 o.ancestor = old_branch_info->name;
814 - if (old_branch_info->name == NULL) {
814 + if (!old_branch_info->name) {
815 strbuf_add_unique_abbrev(&old_commit_shortname,
816 &old_branch_info->commit->object.oid,
817 DEFAULT_ABBREV);
builtin/clone.c
+2 -2
@@ -1070,10 +1070,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1070 * apply the remote name provided by --origin only after this second
1071 * call to git_config, to ensure it overrides all config-based values.
1072 */
1073 - if (option_origin != NULL)
1073 + if (option_origin)
1074 remote_name = xstrdup(option_origin);
1075
1076 - if (remote_name == NULL)
1076 + if (!remote_name)
1077 remote_name = xstrdup("origin");
1078
1079 if (!valid_remote_name(remote_name))
builtin/commit.c
+1 -1
@@ -858,7 +858,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
858 }
859
860 s->fp = fopen_for_writing(git_path_commit_editmsg());
861 - if (s->fp == NULL)
861 + if (!s->fp)
862 die_errno(_("could not open '%s'"), git_path_commit_editmsg());
863
864 /* Ignore status.displayCommentPrefix: we do need comments in COMMIT_EDITMSG. */
builtin/diff.c
+1 -1
@@ -352,7 +352,7 @@ static void symdiff_prepare(struct rev_info *rev, struct symdiff *sym)
352 othercount++;
353 continue;
354 }
355 - if (map == NULL)
355 + if (!map)
356 map = bitmap_new();
357 bitmap_set(map, i);
358 }
builtin/gc.c
+3 -3
@@ -446,7 +446,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
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)
449 + if (fp)
450 fclose(fp);
451 if (should_exit) {
452 if (fd >= 0)
@@ -2236,7 +2236,7 @@ static int systemd_timer_write_unit_templates(const char *exec_path)
2236 goto error;
2237 }
2238 file = fopen_or_warn(filename, "w");
2239 - if (file == NULL)
2239 + if (!file)
2240 goto error;
2241
2242 unit = "# This file was created and is maintained by Git.\n"
@@ -2265,7 +2265,7 @@ static int systemd_timer_write_unit_templates(const char *exec_path)
2265
2266 filename = xdg_config_home_systemd("git-maintenance@.service");
2267 file = fopen_or_warn(filename, "w");
2268 - if (file == NULL)
2268 + if (!file)
2269 goto error;
2270
2271 unit = "# This file was created and is maintained by Git.\n"
builtin/index-pack.c
+3 -3
@@ -1935,11 +1935,11 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
1935 free(objects);
1936 strbuf_release(&index_name_buf);
1937 strbuf_release(&rev_index_name_buf);
1938 - if (pack_name == NULL)
1938 + if (!pack_name)
1939 free((void *) curr_pack);
1940 - if (index_name == NULL)
1940 + if (!index_name)
1941 free((void *) curr_index);
1942 - if (rev_index_name == NULL)
1942 + if (!rev_index_name)
1943 free((void *) curr_rev_index);
1944
1945 /*
builtin/log.c
+1 -1
@@ -978,7 +978,7 @@ static int open_next_file(struct commit *commit, const char *subject,
978 if (!quiet)
979 printf("%s\n", filename.buf + outdir_offset);
980
981 - if ((rev->diffopt.file = fopen(filename.buf, "w")) == NULL) {
981 + if (!(rev->diffopt.file = fopen(filename.buf, "w"))) {
982 error_errno(_("cannot open patch file %s"), filename.buf);
983 strbuf_release(&filename);
984 return -1;
builtin/ls-remote.c
+1 -1
@@ -116,7 +116,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
116 }
117
118 transport = transport_get(remote, NULL);
119 - if (uploadpack != NULL)
119 + if (uploadpack)
120 transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
121 if (server_options.nr)
122 transport->server_options = &server_options;
builtin/mailsplit.c
+1 -1
@@ -120,7 +120,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)
120 for (sub = subs; *sub; ++sub) {
121 free(name);
122 name = xstrfmt("%s/%s", path, *sub);
123 - if ((dir = opendir(name)) == NULL) {
123 + if (!(dir = opendir(name))) {
124 if (errno == ENOENT)
125 continue;
126 error_errno("cannot opendir %s", name);
builtin/pack-redundant.c
+5 -5
@@ -101,7 +101,7 @@ static inline struct llist_item *llist_insert(struct llist *list,
101 oidread(&new_item->oid, oid);
102 new_item->next = NULL;
103
104 - if (after != NULL) {
104 + if (after) {
105 new_item->next = after->next;
106 after->next = new_item;
107 if (after == list->back)
@@ -157,7 +157,7 @@ redo_from_start:
157 if (cmp > 0) /* not in list, since sorted */
158 return prev;
159 if (!cmp) { /* found */
160 - if (prev == NULL) {
160 + if (!prev) {
161 if (hint != NULL && hint != list->front) {
162 /* we don't know the previous element */
163 hint = NULL;
@@ -219,7 +219,7 @@ static struct pack_list * pack_list_difference(const struct pack_list *A,
219 struct pack_list *ret;
220 const struct pack_list *pl;
221
222 - if (A == NULL)
222 + if (!A)
223 return NULL;
224
225 pl = B;
@@ -317,7 +317,7 @@ static size_t get_pack_redundancy(struct pack_list *pl)
317 struct pack_list *subset;
318 size_t ret = 0;
319
320 - if (pl == NULL)
320 + if (!pl)
321 return 0;
322
323 while ((subset = pl->next)) {
@@ -611,7 +611,7 @@ int cmd_pack_redundant(int argc, const char **argv, const char *prefix)
611 while (*(argv + i) != NULL)
612 add_pack_file(*(argv + i++));
613
614 - if (local_packs == NULL)
614 + if (!local_packs)
615 die("Zero packs found!");
616
617 load_all_objects();
builtin/receive-pack.c
+2 -2
@@ -1678,7 +1678,7 @@ static void check_aliased_update_internal(struct command *cmd,
1678 }
1679 dst_name = strip_namespace(dst_name);
1680
1681 - if ((item = string_list_lookup(list, dst_name)) == NULL)
1681 + if (!(item = string_list_lookup(list, dst_name)))
1682 return;
1683
1684 cmd->skip_update = 1;
@@ -2542,7 +2542,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
2542 PACKET_READ_CHOMP_NEWLINE |
2543 PACKET_READ_DIE_ON_ERR_PACKET);
2544
2545 - if ((commands = read_head_info(&reader, &shallow)) != NULL) {
2545 + if ((commands = read_head_info(&reader, &shallow))) {
2546 const char *unpack_status = NULL;
2547 struct string_list push_options = STRING_LIST_INIT_DUP;
2548
builtin/replace.c
+1 -1
@@ -72,7 +72,7 @@ static int list_replace_refs(const char *pattern, const char *format)
72 {
73 struct show_data data;
74
75 - if (pattern == NULL)
75 + if (!pattern)
76 pattern = "*";
77 data.pattern = pattern;
78
builtin/rev-parse.c
+1 -1
@@ -476,7 +476,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
476
477 /* name(s) */
478 s = strpbrk(sb.buf, flag_chars);
479 - if (s == NULL)
479 + if (!s)
480 s = help;
481
482 if (s - sb.buf == 1) /* short option only */
builtin/shortlog.c
+1 -1
@@ -81,7 +81,7 @@ static void insert_one_record(struct shortlog *log,
81 format_subject(&subject, oneline, " ");
82 buffer = strbuf_detach(&subject, NULL);
83
84 - if (item->util == NULL)
84 + if (!item->util)
85 item->util = xcalloc(1, sizeof(struct string_list));
86 string_list_append(item->util, buffer);
87 }
builtin/tag.c
+2 -2
@@ -364,7 +364,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
364 strbuf_addstr(sb, "object of unknown type");
365 break;
366 case OBJ_COMMIT:
367 - if ((buf = read_object_file(oid, &type, &size)) != NULL) {
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,7 +372,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
372 }
373 free(buf);
374
375 - if ((c = lookup_commit_reference(the_repository, oid)) != NULL)
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:
combine-diff.c
+2 -2
@@ -195,10 +195,10 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,
195 struct lline *baseend, *newend = NULL;
196 int i, j, origbaselen = *lenbase;
197
198 - if (newline == NULL)
198 + if (!newline)
199 return base;
200
201 - if (base == NULL) {
201 + if (!base) {
202 *lenbase = lennew;
203 return newline;
204 }
commit-graph.c
+2 -2
@@ -2552,7 +2552,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2552 odb_parents = odb_commit->parents;
2553
2554 while (graph_parents) {
2555 - if (odb_parents == NULL) {
2555 + if (!odb_parents) {
2556 graph_report(_("commit-graph parent list for commit %s is too long"),
2557 oid_to_hex(&cur_oid));
2558 break;
@@ -2575,7 +2575,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
2575 odb_parents = odb_parents->next;
2576 }
2577
2578 - if (odb_parents != NULL)
2578 + if (odb_parents)
2579 graph_report(_("commit-graph parent list for commit %s terminates early"),
2580 oid_to_hex(&cur_oid));
2581
compat/mingw.c
+3 -3
@@ -1043,7 +1043,7 @@ char *mingw_mktemp(char *template)
1043 int mkstemp(char *template)
1044 {
1045 char *filename = mktemp(template);
1046 - if (filename == NULL)
1046 + if (!filename)
1047 return -1;
1048 return open(filename, O_RDWR | O_CREAT, 0600);
1049 }
@@ -2311,7 +2311,7 @@ int setitimer(int type, struct itimerval *in, struct itimerval *out)
2311 static const struct timeval zero;
2312 static int atexit_done;
2313
2314 - if (out != NULL)
2314 + if (out)
2315 return errno = EINVAL,
2316 error("setitimer param 3 != NULL not implemented");
2317 if (!is_timeval_eq(&in->it_interval, &zero) &&
@@ -2340,7 +2340,7 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out)
2340 if (sig != SIGALRM)
2341 return errno = EINVAL,
2342 error("sigaction only implemented for SIGALRM");
2343 - if (out != NULL)
2343 + if (out)
2344 return errno = EINVAL,
2345 error("sigaction: param 3 != NULL not implemented");
2346
compat/mkdir.c
+1 -1
@@ -9,7 +9,7 @@ int compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode)
9 size_t len = strlen(dir);
10
11 if (len && dir[len-1] == '/') {
12 - if ((tmp_dir = strdup(dir)) == NULL)
12 + if (!(tmp_dir = strdup(dir)))
13 return -1;
14 tmp_dir[len-1] = '\0';
15 }
compat/mmap.c
+1 -1
@@ -13,7 +13,7 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
13 }
14
15 start = malloc(length);
16 - if (start == NULL) {
16 + if (!start) {
17 errno = ENOMEM;
18 return MAP_FAILED;
19 }
config.c
+4 -4
@@ -2959,7 +2959,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2959 goto out_free;
2960 }
2961 /* if nothing to unset, error out */
2962 - if (value == NULL) {
2962 + if (!value) {
2963 ret = CONFIG_NOTHING_SET;
2964 goto out_free;
2965 }
@@ -2975,7 +2975,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
2975 int i, new_line = 0;
2976 struct config_options opts;
2977
2978 - if (value_pattern == NULL)
2978 + if (!value_pattern)
2979 store.value_pattern = NULL;
2980 else if (value_pattern == CONFIG_REGEX_NONE)
2981 store.value_pattern = CONFIG_REGEX_NONE;
@@ -3115,7 +3115,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
3115 }
3116
3117 /* write the pair (value == NULL means unset) */
3118 - if (value != NULL) {
3118 + if (value) {
3119 if (!store.section_seen) {
3120 if (write_section(fd, key, &store) < 0)
3121 goto write_err_out;
@@ -3322,7 +3322,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
3322 offset = section_name_match(&buf[i], old_name);
3323 if (offset > 0) {
3324 ret++;
3325 - if (new_name == NULL) {
3325 + if (!new_name) {
3326 remove = 1;
3327 continue;
3328 }
daemon.c
+1 -1
@@ -451,7 +451,7 @@ static void copy_to_log(int fd)
451 FILE *fp;
452
453 fp = fdopen(fd, "r");
454 - if (fp == NULL) {
454 + if (!fp) {
455 logerror("fdopen of error channel failed");
456 close(fd);
457 return;
dir.c
+1 -1
@@ -3049,7 +3049,7 @@ char *git_url_basename(const char *repo, int is_bundle, int is_bare)
3049 * Skip scheme.
3050 */
3051 start = strstr(repo, "://");
3052 - if (start == NULL)
3052 + if (!start)
3053 start = repo;
3054 else
3055 start += 3;
ewah/bitmap.c
+1 -1
@@ -223,7 +223,7 @@ void bitmap_reset(struct bitmap *bitmap)
223
224 void bitmap_free(struct bitmap *bitmap)
225 {
226 - if (bitmap == NULL)
226 + if (!bitmap)
227 return;
228
229 free(bitmap->words);
ewah/ewah_bitmap.c
+1 -1
@@ -451,7 +451,7 @@ struct ewah_bitmap *ewah_pool_new(void)
451
452 void ewah_pool_free(struct ewah_bitmap *self)
453 {
454 - if (self == NULL)
454 + if (!self)
455 return;
456
457 if (bitmap_pool_size == BITMAP_POOL_MAX ||
http-fetch.c
+1 -1
@@ -54,7 +54,7 @@ static void fetch_single_packfile(struct object_id *packfile_hash,
54 http_init(NULL, url, 0);
55
56 preq = new_direct_http_pack_request(packfile_hash->hash, xstrdup(url));
57 - if (preq == NULL)
57 + if (!preq)
58 die("couldn't create http pack request");
59 preq->slot->results = &results;
60 preq->index_pack_args = index_pack_args;
http-push.c
+6 -6
@@ -253,7 +253,7 @@ static void start_fetch_loose(struct transfer_request *request)
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) {
256 + if (!obj_req) {
257 request->state = ABORTED;
258 return;
259 }
@@ -318,7 +318,7 @@ static void start_fetch_packed(struct transfer_request *request)
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) {
321 + if (!preq) {
322 repo->can_update_info_refs = 0;
323 return;
324 }
@@ -520,7 +520,7 @@ static void finish_request(struct transfer_request *request)
520 /* Keep locks active */
521 check_locks();
522
523 - if (request->headers != NULL)
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,7 +783,7 @@ xml_start_tag(void *userData, const char *name, const char **atts)
783 const char *c = strchr(name, ':');
784 int old_namelen, new_len;
785
786 - if (c == NULL)
786 + if (!c)
787 c = name;
788 else
789 c++;
@@ -811,7 +811,7 @@ xml_end_tag(void *userData, const char *name)
811
812 ctx->userFunc(ctx, 1);
813
814 - if (c == NULL)
814 + if (!c)
815 c = name;
816 else
817 c++;
@@ -1893,7 +1893,7 @@ int cmd_main(int argc, const char **argv)
1893
1894 /* Lock remote branch ref */
1895 ref_lock = lock_remote(ref->name, LOCK_TIME);
1896 - if (ref_lock == NULL) {
1896 + if (!ref_lock) {
1897 fprintf(stderr, "Unable to lock remote branch %s\n",
1898 ref->name);
1899 if (helper_status)
http-walker.c
+7 -7
@@ -59,7 +59,7 @@ static void start_object_request(struct walker *walker,
59 struct http_object_request *req;
60
61 req = new_http_object_request(obj_req->repo->base, &obj_req->oid);
62 - if (req == NULL) {
62 + if (!req) {
63 obj_req->state = ABORTED;
64 return;
65 }
@@ -106,7 +106,7 @@ static void process_object_response(void *callback_data)
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) {
109 + if (obj_req->repo->next) {
110 obj_req->repo =
111 obj_req->repo->next;
112 release_http_object_request(obj_req->req);
@@ -225,12 +225,12 @@ static void process_alternates_response(void *callback_data)
225 alt_req->url->buf);
226 active_requests++;
227 slot->in_use = 1;
228 - if (slot->finished != NULL)
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 != NULL)
233 + if (slot->finished)
234 (*slot->finished) = 1;
235 }
236 return;
@@ -443,7 +443,7 @@ static int http_fetch_pack(struct walker *walker, struct alt_base *repo, unsigne
443 }
444
445 preq = new_http_pack_request(target->hash, repo->base);
446 - if (preq == NULL)
446 + if (!preq)
447 goto abort;
448 preq->slot->results = &results;
449
@@ -489,11 +489,11 @@ static int fetch_object(struct walker *walker, unsigned char *hash)
489 if (hasheq(obj_req->oid.hash, hash))
490 break;
491 }
492 - if (obj_req == NULL)
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 != NULL)
496 + if (obj_req->req)
497 abort_http_object_request(obj_req->req);
498 abort_object_request(obj_req);
499 return 0;
http.c
+23 -23
@@ -197,11 +197,11 @@ static void finish_active_slot(struct active_request_slot *slot)
197 closedown_active_slot(slot);
198 curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE, &slot->http_code);
199
200 - if (slot->finished != NULL)
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 != NULL) {
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,7 +212,7 @@ static void finish_active_slot(struct active_request_slot *slot)
212 }
213
214 /* Run callback if appropriate */
215 - if (slot->callback_func != NULL)
215 + if (slot->callback_func)
216 slot->callback_func(slot->callback_data);
217 }
218
@@ -234,7 +234,7 @@ static void process_curl_messages(void)
234 while (slot != NULL &&
235 slot->curl != curl_message->easy_handle)
236 slot = slot->next;
237 - if (slot != NULL) {
237 + if (slot) {
238 xmulti_remove_handle(slot);
239 slot->curl_result = curl_result;
240 finish_active_slot(slot);
@@ -838,16 +838,16 @@ static CURL *get_curl_handle(void)
838 curl_easy_setopt(result, CURLOPT_SSL_CIPHER_LIST,
839 ssl_cipherlist);
840
841 - if (ssl_cert != NULL)
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 != NULL)
845 + if (ssl_key)
846 curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key);
847 - if (ssl_capath != NULL)
847 + if (ssl_capath)
848 curl_easy_setopt(result, CURLOPT_CAPATH, ssl_capath);
849 #ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY
850 - if (ssl_pinnedkey != NULL)
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,10 +857,10 @@ static CURL *get_curl_handle(void)
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)
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 != NULL)
863 + if (http_proxy_ssl_ca_info)
864 curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, http_proxy_ssl_ca_info);
865 #endif
866 }
@@ -1050,7 +1050,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
1050
1051 {
1052 char *http_max_requests = getenv("GIT_HTTP_MAX_REQUESTS");
1053 - if (http_max_requests != NULL)
1053 + if (http_max_requests)
1054 max_requests = atoi(http_max_requests);
1055 }
1056
@@ -1069,10 +1069,10 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
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)
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 != NULL)
1075 + if (low_speed_time)
1076 curl_low_speed_time = strtol(low_speed_time, NULL, 10);
1077
1078 if (curl_ssl_verify == -1)
@@ -1109,7 +1109,7 @@ void http_cleanup(void)
1109
1110 while (slot != NULL) {
1111 struct active_request_slot *next = slot->next;
1112 - if (slot->curl != NULL) {
1112 + if (slot->curl) {
1113 xmulti_remove_handle(slot);
1114 curl_easy_cleanup(slot->curl);
1115 }
@@ -1147,13 +1147,13 @@ void http_cleanup(void)
1147 free((void *)http_proxy_authmethod);
1148 http_proxy_authmethod = NULL;
1149
1150 - if (cert_auth.password != NULL) {
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 != NULL) {
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,14 +1179,14 @@ struct active_request_slot *get_active_slot(void)
1179 while (slot != NULL && slot->in_use)
1180 slot = slot->next;
1181
1182 - if (slot == NULL) {
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 == NULL) {
1189 + if (!slot) {
1190 active_queue_head = newslot;
1191 } else {
1192 while (slot->next != NULL)
@@ -1196,7 +1196,7 @@ struct active_request_slot *get_active_slot(void)
1196 slot = newslot;
1197 }
1198
1199 - if (slot->curl == NULL) {
1199 + if (!slot->curl) {
1200 slot->curl = curl_easy_duphandle(curl_default);
1201 curl_session_count++;
1202 }
@@ -1768,7 +1768,7 @@ static int http_request(const char *url,
1768 slot = get_active_slot();
1769 curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
1770
1771 - if (result == NULL) {
1771 + if (!result) {
1772 curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);
1773 } else {
1774 curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
@@ -2100,7 +2100,7 @@ cleanup:
2100
2101 void release_http_pack_request(struct http_pack_request *preq)
2102 {
2103 - if (preq->packfile != NULL) {
2103 + if (preq->packfile) {
2104 fclose(preq->packfile);
2105 preq->packfile = NULL;
2106 }
@@ -2390,7 +2390,7 @@ abort:
2390
2391 void process_http_object_request(struct http_object_request *freq)
2392 {
2393 - if (freq->slot == NULL)
2393 + if (!freq->slot)
2394 return;
2395 freq->curl_result = freq->slot->curl_result;
2396 freq->http_code = freq->slot->http_code;
@@ -2447,7 +2447,7 @@ void release_http_object_request(struct http_object_request *freq)
2447 freq->localfile = -1;
2448 }
2449 FREE_AND_NULL(freq->url);
2450 - if (freq->slot != NULL) {
2450 + if (freq->slot) {
2451 freq->slot->callback_func = NULL;
2452 freq->slot->callback_data = NULL;
2453 release_active_slot(freq->slot);
kwset.c
+2 -2
@@ -477,7 +477,7 @@ kwsprep (kwset_t kws)
477 next[i] = NULL;
478 treenext(kwset->trie->links, next);
479
480 - if ((trans = kwset->trans) != NULL)
480 + if ((trans = kwset->trans))
481 for (i = 0; i < NCHAR; ++i)
482 kwset->next[i] = next[U(trans[i])];
483 else
@@ -485,7 +485,7 @@ kwsprep (kwset_t kws)
485 }
486
487 /* Fix things up for any translation table. */
488 - if ((trans = kwset->trans) != NULL)
488 + if ((trans = kwset->trans))
489 for (i = 0; i < NCHAR; ++i)
490 kwset->delta[i] = delta[U(trans[i])];
491 else
ll-merge.c
+1 -1
@@ -204,7 +204,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
204 dict[4].placeholder = "P"; dict[4].value = path_sq.buf;
205 dict[5].placeholder = NULL; dict[5].value = NULL;
206
207 - if (fn->cmdline == NULL)
207 + if (!fn->cmdline)
208 die("custom merge driver %s lacks command line.", fn->name);
209
210 result->ptr = NULL;
log-tree.c
+1 -1
@@ -84,7 +84,7 @@ static int match_ref_pattern(const char *refname,
84 const struct string_list_item *item)
85 {
86 int matched = 0;
87 - if (item->util == NULL) {
87 + if (!item->util) {
88 if (!wildmatch(item->string, refname, 0))
89 matched = 1;
90 } else {
mailinfo.c
+2 -2
@@ -698,7 +698,7 @@ static int is_scissors_line(const char *line)
698 continue;
699 }
700 last_nonblank = c;
701 - if (first_nonblank == NULL)
701 + if (!first_nonblank)
702 first_nonblank = c;
703 if (*c == '-') {
704 in_perforation = 1;
@@ -1094,7 +1094,7 @@ static void handle_body(struct mailinfo *mi, struct strbuf *line)
1094 */
1095 lines = strbuf_split(line, '\n');
1096 for (it = lines; (sb = *it); it++) {
1097 - if (*(it + 1) == NULL) /* The last line */
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);
mailmap.c
+7 -7
@@ -77,7 +77,7 @@ static void add_mapping(struct string_list *map,
77 struct mailmap_entry *me;
78 struct string_list_item *item;
79
80 - if (old_email == NULL) {
80 + if (!old_email) {
81 old_email = new_email;
82 new_email = NULL;
83 }
@@ -92,7 +92,7 @@ static void add_mapping(struct string_list *map,
92 item->util = me;
93 }
94
95 - if (old_name == NULL) {
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,9 +123,9 @@ static char *parse_name_and_email(char *buffer, char **name,
123 char *left, *right, *nstart, *nend;
124 *name = *email = NULL;
125
126 - if ((left = strchr(buffer, '<')) == NULL)
126 + if (!(left = strchr(buffer, '<')))
127 return NULL;
128 - if ((right = strchr(left+1, '>')) == NULL)
128 + if (!(right = strchr(left + 1, '>')))
129 return NULL;
130 if (!allow_empty_email && (left+1 == right))
131 return NULL;
@@ -153,7 +153,7 @@ static void read_mailmap_line(struct string_list *map, char *buffer)
153 if (buffer[0] == '#')
154 return;
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 parse_name_and_email(name2, &name2, &email2, 1);
158
159 if (email1)
@@ -319,7 +319,7 @@ int map_user(struct string_list *map,
319 (int)*emaillen, debug_str(*email));
320
321 item = lookup_prefix(map, *email, *emaillen);
322 - if (item != NULL) {
322 + if (item) {
323 me = (struct mailmap_entry *)item->util;
324 if (me->namemap.nr) {
325 /*
@@ -333,7 +333,7 @@ int map_user(struct string_list *map,
333 item = subitem;
334 }
335 }
336 - if (item != NULL) {
336 + if (item) {
337 struct mailmap_info *mi = (struct mailmap_info *)item->util;
338 if (mi->name == NULL && mi->email == NULL) {
339 debug_mm("map_user: -- (no simple mapping)\n");
merge-ort.c
+2 -2
@@ -2018,7 +2018,7 @@ static char *handle_path_level_conflicts(struct merge_options *opt,
2018 * to ensure that's the case.
2019 */
2020 c_info = strmap_get(collisions, new_path);
2021 - if (c_info == NULL)
2021 + if (!c_info)
2022 BUG("c_info is NULL");
2023
2024 /*
@@ -4574,7 +4574,7 @@ static void merge_ort_internal(struct merge_options *opt,
4574 }
4575
4576 merged_merge_bases = pop_commit(&merge_bases);
4577 - if (merged_merge_bases == NULL) {
4577 + if (!merged_merge_bases) {
4578 /* if there is no common ancestor, use an empty tree */
4579 struct tree *tree;
4580
merge-recursive.c
+6 -6
@@ -82,7 +82,7 @@ static struct dir_rename_entry *dir_rename_find_entry(struct hashmap *hashmap,
82 {
83 struct dir_rename_entry key;
84
85 - if (dir == NULL)
85 + if (!dir)
86 return NULL;
87 hashmap_entry_init(&key.ent, strhash(dir));
88 key.dir = dir;
@@ -1987,14 +1987,14 @@ static void get_renamed_dir_portion(const char *old_path, const char *new_path,
1987 * renamed means the root directory can never be renamed -- because
1988 * the root directory always exists).
1989 */
1990 - if (end_of_old == NULL)
1990 + if (!end_of_old)
1991 return; /* Note: *old_dir and *new_dir are still NULL */
1992
1993 /*
1994 * If new_path contains no directory (end_of_new is NULL), then we
1995 * have a rename of old_path's directory to the root directory.
1996 */
1997 - if (end_of_new == NULL) {
1997 + if (!end_of_new) {
1998 *old_dir = xstrndup(old_path, end_of_old - old_path);
1999 *new_dir = xstrdup("");
2000 return;
@@ -2113,7 +2113,7 @@ static char *handle_path_level_conflicts(struct merge_options *opt,
2113 * to ensure that's the case.
2114 */
2115 collision_ent = collision_find_entry(collisions, new_path);
2116 - if (collision_ent == NULL)
2116 + if (!collision_ent)
2117 BUG("collision_ent is NULL");
2118
2119 /*
@@ -2993,7 +2993,7 @@ static void final_cleanup_rename(struct string_list *rename)
2993 const struct rename *re;
2994 int i;
2995
2996 - if (rename == NULL)
2996 + if (!rename)
2997 return;
2998
2999 for (i = 0; i < rename->nr; i++) {
@@ -3602,7 +3602,7 @@ static int merge_recursive_internal(struct merge_options *opt,
3602 }
3603
3604 merged_merge_bases = pop_commit(&merge_bases);
3605 - if (merged_merge_bases == NULL) {
3605 + if (!merged_merge_bases) {
3606 /* if there is no common ancestor, use an empty tree */
3607 struct tree *tree;
3608
object-file.c
+1 -1
@@ -1672,7 +1672,7 @@ void *read_object_file_extended(struct repository *r,
1672 die(_("loose object %s (stored in %s) is corrupt"),
1673 oid_to_hex(repl), path);
1674
1675 - if ((p = has_packed_and_bad(r, repl)) != NULL)
1675 + if ((p = has_packed_and_bad(r, repl)))
1676 die(_("packed object %s (stored in %s) is corrupt"),
1677 oid_to_hex(repl), p->pack_name);
1678 obj_read_unlock();
pack-bitmap.c
+7 -7
@@ -111,7 +111,7 @@ static struct ewah_bitmap *lookup_stored_bitmap(struct stored_bitmap *st)
111 struct ewah_bitmap *parent;
112 struct ewah_bitmap *composed;
113
114 - if (st->xor == NULL)
114 + if (!st->xor)
115 return st->root;
116
117 composed = ewah_pool_new();
@@ -279,7 +279,7 @@ static int load_bitmap_entries_v1(struct bitmap_index *index)
279 if (xor_offset > 0) {
280 xor_bitmap = recent_bitmaps[(i - xor_offset) % MAX_XOR_OFFSET];
281
282 - if (xor_bitmap == NULL)
282 + if (!xor_bitmap)
283 return error("Invalid XOR offset in bitmap pack index");
284 }
285
@@ -719,7 +719,7 @@ static int add_commit_to_bitmap(struct bitmap_index *bitmap_git,
719 if (!or_with)
720 return 0;
721
722 - if (*base == NULL)
722 + if (!*base)
723 *base = ewah_to_bitmap(or_with);
724 else
725 bitmap_or_ewah(*base, or_with);
@@ -763,7 +763,7 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
763 * Best case scenario: We found bitmaps for all the roots,
764 * so the resulting `or` bitmap has the full reachability analysis
765 */
766 - if (not_mapped == NULL)
766 + if (!not_mapped)
767 return base;
768
769 roots = not_mapped;
@@ -797,7 +797,7 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
797 struct include_data incdata;
798 struct bitmap_show_data show_data;
799
800 - if (base == NULL)
800 + if (!base)
801 base = bitmap_new();
802
803 incdata.bitmap_git = bitmap_git;
@@ -1293,7 +1293,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
1293 reset_revision_walk();
1294 revs->ignore_missing_links = 0;
1295
1296 - if (haves_bitmap == NULL)
1296 + if (!haves_bitmap)
1297 BUG("failed to perform bitmap walk");
1298 }
1299
@@ -1691,7 +1691,7 @@ void test_bitmap_walk(struct rev_info *revs)
1691 result = ewah_to_bitmap(bm);
1692 }
1693
1694 - if (result == NULL)
1694 + if (!result)
1695 die("Commit %s doesn't have an indexed bitmap", oid_to_hex(&root->oid));
1696
1697 revs->tag_objects = 1;
packfile.c
+1 -1
@@ -116,7 +116,7 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
116
117 if (idx_size < 4 * 256 + hashsz + hashsz)
118 return error("index file %s is too small", path);
119 - if (idx_map == NULL)
119 + if (!idx_map)
120 return error("empty data");
121
122 if (hdr->idx_signature == htonl(PACK_IDX_SIGNATURE)) {
path.c
+1 -1
@@ -733,7 +733,7 @@ char *interpolate_path(const char *path, int real_home)
733 struct strbuf user_path = STRBUF_INIT;
734 const char *to_copy = path;
735
736 - if (path == NULL)
736 + if (!path)
737 goto return_null;
738
739 if (skip_prefix(path, "%(prefix)/", &path))
prio-queue.c
+1 -1
@@ -19,7 +19,7 @@ void prio_queue_reverse(struct prio_queue *queue)
19 {
20 int i, j;
21
22 - if (queue->compare != NULL)
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);
promisor-remote.c
+1 -1
@@ -84,7 +84,7 @@ static void promisor_remote_move_to_tail(struct promisor_remote_config *config,
84 struct promisor_remote *r,
85 struct promisor_remote *previous)
86 {
87 - if (r->next == NULL)
87 + if (!r->next)
88 return;
89
90 if (previous)
ref-filter.c
+3 -3
@@ -1261,7 +1261,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
1261 * ":" means no format is specified, and use the default.
1262 */
1263 formatp = strchr(atomname, ':');
1264 - if (formatp != NULL) {
1264 + if (formatp) {
1265 formatp++;
1266 parse_date_format(formatp, &date_mode);
1267 }
@@ -1508,7 +1508,7 @@ static void fill_missing_values(struct atom_value *val)
1508 int i;
1509 for (i = 0; i < used_atom_cnt; i++) {
1510 struct atom_value *v = &val[i];
1511 - if (v->s == NULL)
1511 + if (!v->s)
1512 v->s = xstrdup("");
1513 }
1514 }
@@ -1618,7 +1618,7 @@ static const char *rstrip_ref_components(const char *refname, int len)
1618
1619 while (remaining-- > 0) {
1620 char *p = strrchr(start, '/');
1621 - if (p == NULL) {
1621 + if (!p) {
1622 free((char *)to_free);
1623 return xstrdup("");
1624 } else
refs/ref-cache.c
+1 -1
@@ -134,7 +134,7 @@ int search_ref_dir(struct ref_dir *dir, const char *refname, size_t len)
134 r = bsearch(&key, dir->entries, dir->nr, sizeof(*dir->entries),
135 ref_entry_cmp_sslice);
136
137 - if (r == NULL)
137 + if (!r)
138 return -1;
139
140 return r - dir->entries;
rerere.c
+1 -1
@@ -591,7 +591,7 @@ int rerere_remaining(struct repository *r, struct string_list *merge_rr)
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) {
594 + if (it) {
595 free_rerere_id(it);
596 it->util = RERERE_RESOLVED;
597 }
revision.c
+2 -2
@@ -2801,7 +2801,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2801 }
2802 strvec_clear(&prune_data);
2803
2804 - if (revs->def == NULL)
2804 + if (!revs->def)
2805 revs->def = opt ? opt->def : NULL;
2806 if (opt && opt->tweak)
2807 opt->tweak(revs, opt);
@@ -3620,7 +3620,7 @@ static enum rewrite_result rewrite_one_1(struct rev_info *revs,
3620 return rewrite_one_ok;
3621 if (!p->parents)
3622 return rewrite_one_noparents;
3623 - if ((p = one_relevant_parent(revs, p->parents)) == NULL)
3623 + if (!(p = one_relevant_parent(revs, p->parents)))
3624 return rewrite_one_ok;
3625 *pp = p;
3626 }
setup.c
+1 -1
@@ -1404,7 +1404,7 @@ int git_config_perm(const char *var, const char *value)
1404 int i;
1405 char *endptr;
1406
1407 - if (value == NULL)
1407 + if (!value)
1408 return PERM_GROUP;
1409
1410 if (!strcmp(value, "umask"))
sh-i18n--envsubst.c
+1 -1
@@ -397,7 +397,7 @@ subst_from_stdin (void)
397 /* Substitute the variable's value from the environment. */
398 const char *env_value = getenv (buffer);
399
400 - if (env_value != NULL)
400 + if (env_value)
401 fputs (env_value, stdout);
402 }
403 else
shallow.c
+1 -1
@@ -559,7 +559,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
559 else
560 c->object.flags |= SEEN;
561
562 - if (*refs == NULL)
562 + if (!*refs)
563 *refs = bitmap;
564 else {
565 memcpy(tmp, *refs, bitmap_size);
trailer.c
+1 -1
@@ -1029,7 +1029,7 @@ static FILE *create_in_place_tempfile(const char *file)
1029
1030 /* Create temporary file in the same directory as the original */
1031 tail = strrchr(file, '/');
1032 - if (tail != NULL)
1032 + if (tail)
1033 strbuf_add(&filename_template, file, tail - file + 1);
1034 strbuf_addstr(&filename_template, "git-interpret-trailers-XXXXXX");
1035
transport.c
+1 -1
@@ -427,7 +427,7 @@ static int fetch_refs_via_pack(struct transport *transport,
427 args.self_contained_and_connected;
428 data->options.connectivity_checked = args.connectivity_checked;
429
430 - if (refs == NULL)
430 + if (!refs)
431 ret = -1;
432 if (report_unmatched_refs(to_fetch, nr_heads))
433 ret = -1;
wildmatch.c
+1 -1
@@ -113,7 +113,7 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
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)
116 + if (strchr((char *)text, '/'))
117 return WM_NOMATCH;
118 }
119 return WM_MATCH;
worktree.c
+1 -1
@@ -486,7 +486,7 @@ int submodule_uses_worktrees(const char *path)
486 return 0;
487
488 d = readdir_skip_dot_and_dotdot(dir);
489 - if (d != NULL)
489 + if (d)
490 ret = 1;
491 closedir(dir);
492 return ret;
wrapper.c
+1 -1
@@ -383,7 +383,7 @@ FILE *xfopen(const char *path, const char *mode)
383 FILE *xfdopen(int fd, const char *mode)
384 {
385 FILE *stream = fdopen(fd, mode);
386 - if (stream == NULL)
386 + if (!stream)
387 die_errno("Out of memory? fdopen failed");
388 return stream;
389 }
xdiff-interface.c
+1 -1
@@ -159,7 +159,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
159
160 if (stat(filename, &st))
161 return error_errno("Could not stat %s", filename);
162 - if ((f = fopen(filename, "rb")) == NULL)
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);
xdiff/xemit.c
+1 -1
@@ -65,7 +65,7 @@ xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg)
65 *xscr = xch;
66 }
67
68 - if (*xscr == NULL)
68 + if (!*xscr)
69 return NULL;
70
71 lxch = *xscr;
xdiff/xprepare.c
+1 -1
@@ -192,7 +192,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
192 }
193
194 nrec = 0;
195 - if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) {
195 + if ((cur = blk = xdl_mmfile_first(mf, &bsize))) {
196 for (top = blk + bsize; cur < top; ) {
197 prev = cur;
198 hav = xdl_hash_record(&cur, top, xpp->flags);
xdiff/xutils.c
+1 -1
@@ -122,7 +122,7 @@ long xdl_guess_lines(mmfile_t *mf, long sample) {
122 long nl = 0, size, tsize = 0;
123 char const *data, *cur, *top;
124
125 - if ((cur = data = xdl_mmfile_first(mf, &size)) != NULL) {
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)))