]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tree-wide: apply equals-null.cocci
authorJunio C Hamano <gitster@pobox.com>
Mon, 2 May 2022 16:50:37 +0000 (09:50 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 2 May 2022 16:50:37 +0000 (09:50 -0700)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
63 files changed:
apply.c
archive.c
blame.c
branch.c
builtin/bisect--helper.c
builtin/checkout.c
builtin/clone.c
builtin/commit.c
builtin/diff.c
builtin/gc.c
builtin/index-pack.c
builtin/log.c
builtin/ls-remote.c
builtin/mailsplit.c
builtin/pack-redundant.c
builtin/receive-pack.c
builtin/replace.c
builtin/rev-parse.c
builtin/shortlog.c
builtin/tag.c
combine-diff.c
commit-graph.c
compat/mingw.c
compat/mkdir.c
compat/mmap.c
config.c
daemon.c
dir.c
ewah/bitmap.c
ewah/ewah_bitmap.c
http-fetch.c
http-push.c
http-walker.c
http.c
kwset.c
ll-merge.c
log-tree.c
mailinfo.c
mailmap.c
merge-ort.c
merge-recursive.c
object-file.c
pack-bitmap.c
packfile.c
path.c
prio-queue.c
promisor-remote.c
ref-filter.c
refs/ref-cache.c
rerere.c
revision.c
setup.c
sh-i18n--envsubst.c
shallow.c
trailer.c
transport.c
wildmatch.c
worktree.c
wrapper.c
xdiff-interface.c
xdiff/xemit.c
xdiff/xprepare.c
xdiff/xutils.c

diff --git a/apply.c b/apply.c
index 43a0aebf4eec85fa6b0a69f655c0224aa14f29e5..d2e5e2d6d0ce0096edf3fb4d304ba1745a51e692 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -3267,11 +3267,11 @@ static struct patch *in_fn_table(struct apply_state *state, const char *name)
 {
        struct string_list_item *item;
 
-       if (name == NULL)
+       if (!name)
                return NULL;
 
        item = string_list_lookup(&state->fn_table, name);
-       if (item != NULL)
+       if (item)
                return (struct patch *)item->util;
 
        return NULL;
@@ -3311,7 +3311,7 @@ static void add_to_fn_table(struct apply_state *state, struct patch *patch)
         * This should cover the cases for normal diffs,
         * file creations and copies
         */
-       if (patch->new_name != NULL) {
+       if (patch->new_name) {
                item = string_list_insert(&state->fn_table, patch->new_name);
                item->util = patch;
        }
index a3bbb091256dd7077e257f20f532d47516e4a960..eed32dec427974199252529100179df6ff0cc9e6 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -465,7 +465,7 @@ static void parse_treeish_arg(const char **argv,
        }
 
        tree = parse_tree_indirect(&oid);
-       if (tree == NULL)
+       if (!tree)
                die(_("not a tree object: %s"), oid_to_hex(&oid));
 
        if (prefix) {
diff --git a/blame.c b/blame.c
index 206c295660f29b1fd44842ef0f28caf4d2e04788..f9714cc941e5d2fc5ee4ede2187981ba0b7cd2aa 100644 (file)
--- a/blame.c
+++ b/blame.c
@@ -1072,7 +1072,7 @@ static struct blame_entry *blame_merge(struct blame_entry *list1,
        if (p1->s_lno <= p2->s_lno) {
                do {
                        tail = &p1->next;
-                       if ((p1 = *tail) == NULL) {
+                       if (!(p1 = *tail)) {
                                *tail = p2;
                                return list1;
                        }
@@ -1082,7 +1082,7 @@ static struct blame_entry *blame_merge(struct blame_entry *list1,
                *tail = p2;
                do {
                        tail = &p2->next;
-                       if ((p2 = *tail) == NULL)  {
+                       if (!(p2 = *tail))  {
                                *tail = p1;
                                return list1;
                        }
@@ -1090,7 +1090,7 @@ static struct blame_entry *blame_merge(struct blame_entry *list1,
                *tail = p1;
                do {
                        tail = &p1->next;
-                       if ((p1 = *tail) == NULL) {
+                       if (!(p1 = *tail)) {
                                *tail = p2;
                                return list1;
                        }
index 07a46430b3846f0fa4595f9ea0f98c2523e8d5f1..fc49f57d77d945c8635a297dc1e7bdbb9e789229 100644 (file)
--- a/branch.c
+++ b/branch.c
@@ -302,7 +302,7 @@ void create_branch(struct repository *r,
                break;
        }
 
-       if ((commit = lookup_commit_reference(r, &oid)) == NULL)
+       if (!(commit = lookup_commit_reference(r, &oid)))
                die(_("Not a valid branch point: '%s'."), start_name);
        oidcpy(&oid, &commit->object.oid);
 
index 28a2e6a5750b737d18412cde48394b73e9a74c30..f1a8ec38ac34f2cd15d457b2b2b3c2fa6e6a5820 100644 (file)
@@ -433,7 +433,7 @@ static int bisect_terms(struct bisect_terms *terms, const char *option)
        if (get_terms(terms))
                return error(_("no terms defined"));
 
-       if (option == NULL) {
+       if (!option) {
                printf(_("Your current terms are %s for the old state\n"
                         "and %s for the new state.\n"),
                       terms->term_good, terms->term_bad);
index cbf73b8c9f65ae2fdd1d96265bd4972aeaa9bd68..c80b607cd88305cdeb44c3f6d9891775c6b436fc 100644 (file)
@@ -811,7 +811,7 @@ static int merge_working_tree(const struct checkout_opts *opts,
                        if (ret)
                                return ret;
                        o.ancestor = old_branch_info->name;
-                       if (old_branch_info->name == NULL) {
+                       if (!old_branch_info->name) {
                                strbuf_add_unique_abbrev(&old_commit_shortname,
                                                         &old_branch_info->commit->object.oid,
                                                         DEFAULT_ABBREV);
index fb377b27657c4048a04c85ddb82e15a950db5a7d..fa9e1fd3c7ba552dd13e5fbfcf012ea17b00f1b0 100644 (file)
@@ -1070,10 +1070,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
         * apply the remote name provided by --origin only after this second
         * call to git_config, to ensure it overrides all config-based values.
         */
-       if (option_origin != NULL)
+       if (option_origin)
                remote_name = xstrdup(option_origin);
 
-       if (remote_name == NULL)
+       if (!remote_name)
                remote_name = xstrdup("origin");
 
        if (!valid_remote_name(remote_name))
index 883c16256c87f75c8367573ba42a8ee8e04346a7..2ef44f106b59f2a8cc48948a9acfbb7ca42d9c0d 100644 (file)
@@ -858,7 +858,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
        }
 
        s->fp = fopen_for_writing(git_path_commit_editmsg());
-       if (s->fp == NULL)
+       if (!s->fp)
                die_errno(_("could not open '%s'"), git_path_commit_editmsg());
 
        /* Ignore status.displayCommentPrefix: we do need comments in COMMIT_EDITMSG. */
index dd8ce688ba7054e7ee76ca4764b1a17b84a3044a..6724f74660d43878bb3c6c29e52da56a3b4ce533 100644 (file)
@@ -352,7 +352,7 @@ static void symdiff_prepare(struct rev_info *rev, struct symdiff *sym)
                        othercount++;
                        continue;
                }
-               if (map == NULL)
+               if (!map)
                        map = bitmap_new();
                bitmap_set(map, i);
        }
index bcef6a4c8da71f54d923bbccc7a152a068e3b8c4..48a0504c670bb8aa0aedc77da2310f5bd0734eaa 100644 (file)
@@ -446,7 +446,7 @@ static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
                        fscanf(fp, scan_fmt, &pid, locking_host) == 2 &&
                        /* be gentle to concurrent "gc" on remote hosts */
                        (strcmp(locking_host, my_host) || !kill(pid, 0) || errno == EPERM);
-               if (fp != NULL)
+               if (fp)
                        fclose(fp);
                if (should_exit) {
                        if (fd >= 0)
@@ -2236,7 +2236,7 @@ static int systemd_timer_write_unit_templates(const char *exec_path)
                goto error;
        }
        file = fopen_or_warn(filename, "w");
-       if (file == NULL)
+       if (!file)
                goto error;
 
        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)
 
        filename = xdg_config_home_systemd("git-maintenance@.service");
        file = fopen_or_warn(filename, "w");
-       if (file == NULL)
+       if (!file)
                goto error;
 
        unit = "# This file was created and is maintained by Git.\n"
index c23d01de7dca4240bca05e7a087adceaaef3e78f..9ecd6826d8b0c578750b991107caa8748393ec2c 100644 (file)
@@ -1935,11 +1935,11 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)
        free(objects);
        strbuf_release(&index_name_buf);
        strbuf_release(&rev_index_name_buf);
-       if (pack_name == NULL)
+       if (!pack_name)
                free((void *) curr_pack);
-       if (index_name == NULL)
+       if (!index_name)
                free((void *) curr_index);
-       if (rev_index_name == NULL)
+       if (!rev_index_name)
                free((void *) curr_rev_index);
 
        /*
index f75d87e8d7fea489639a8e38b7a4704bc75ba0cd..824e172d094910aa8ff383a974e4d03448480443 100644 (file)
@@ -978,7 +978,7 @@ static int open_next_file(struct commit *commit, const char *subject,
        if (!quiet)
                printf("%s\n", filename.buf + outdir_offset);
 
-       if ((rev->diffopt.file = fopen(filename.buf, "w")) == NULL) {
+       if (!(rev->diffopt.file = fopen(filename.buf, "w"))) {
                error_errno(_("cannot open patch file %s"), filename.buf);
                strbuf_release(&filename);
                return -1;
index 318949c3d75327d5adf9524f3f550548f89a20d2..ebbb7ef103c8064b8e8188fcd9c1d1167a11459a 100644 (file)
@@ -116,7 +116,7 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)
        }
 
        transport = transport_get(remote, NULL);
-       if (uploadpack != NULL)
+       if (uploadpack)
                transport_set_option(transport, TRANS_OPT_UPLOADPACK, uploadpack);
        if (server_options.nr)
                transport->server_options = &server_options;
index 7baef30569fce8e6b4a7353067bb4aba00561557..2b30609d174dc9e893f4b13c7ad0f05204610503 100644 (file)
@@ -120,7 +120,7 @@ static int populate_maildir_list(struct string_list *list, const char *path)
        for (sub = subs; *sub; ++sub) {
                free(name);
                name = xstrfmt("%s/%s", path, *sub);
-               if ((dir = opendir(name)) == NULL) {
+               if (!(dir = opendir(name))) {
                        if (errno == ENOENT)
                                continue;
                        error_errno("cannot opendir %s", name);
index 8bf5c0acad2023967abf498832006f37924d9ca1..ed9b9013a5fea10c0e99616ac928661130b4c21e 100644 (file)
@@ -101,7 +101,7 @@ static inline struct llist_item *llist_insert(struct llist *list,
        oidread(&new_item->oid, oid);
        new_item->next = NULL;
 
-       if (after != NULL) {
+       if (after) {
                new_item->next = after->next;
                after->next = new_item;
                if (after == list->back)
@@ -157,7 +157,7 @@ redo_from_start:
                if (cmp > 0) /* not in list, since sorted */
                        return prev;
                if (!cmp) { /* found */
-                       if (prev == NULL) {
+                       if (!prev) {
                                if (hint != NULL && hint != list->front) {
                                        /* we don't know the previous element */
                                        hint = NULL;
@@ -219,7 +219,7 @@ static struct pack_list * pack_list_difference(const struct pack_list *A,
        struct pack_list *ret;
        const struct pack_list *pl;
 
-       if (A == NULL)
+       if (!A)
                return NULL;
 
        pl = B;
@@ -317,7 +317,7 @@ static size_t get_pack_redundancy(struct pack_list *pl)
        struct pack_list *subset;
        size_t ret = 0;
 
-       if (pl == NULL)
+       if (!pl)
                return 0;
 
        while ((subset = pl->next)) {
@@ -611,7 +611,7 @@ int cmd_pack_redundant(int argc, const char **argv, const char *prefix)
                while (*(argv + i) != NULL)
                        add_pack_file(*(argv + i++));
 
-       if (local_packs == NULL)
+       if (!local_packs)
                die("Zero packs found!");
 
        load_all_objects();
index 49b846d960522ad1a5f29f7394bca4fa24e5b622..e7728a217b80a2201177b3128ae94acf8dcc111b 100644 (file)
@@ -1678,7 +1678,7 @@ static void check_aliased_update_internal(struct command *cmd,
        }
        dst_name = strip_namespace(dst_name);
 
-       if ((item = string_list_lookup(list, dst_name)) == NULL)
+       if (!(item = string_list_lookup(list, dst_name)))
                return;
 
        cmd->skip_update = 1;
@@ -2542,7 +2542,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
                           PACKET_READ_CHOMP_NEWLINE |
                           PACKET_READ_DIE_ON_ERR_PACKET);
 
-       if ((commands = read_head_info(&reader, &shallow)) != NULL) {
+       if ((commands = read_head_info(&reader, &shallow))) {
                const char *unpack_status = NULL;
                struct string_list push_options = STRING_LIST_INIT_DUP;
 
index 946938d011ee8ea69040b931c98acd270bbcd46d..402d9e36cee5d134201b575748b9cc0a3a2a2f9e 100644 (file)
@@ -72,7 +72,7 @@ static int list_replace_refs(const char *pattern, const char *format)
 {
        struct show_data data;
 
-       if (pattern == NULL)
+       if (!pattern)
                pattern = "*";
        data.pattern = pattern;
 
index 8480a59f573e28d7777ee7e0dd21a2a640657641..660a6a749b77ecd2b928828cd265fc1ebe5ddc01 100644 (file)
@@ -476,7 +476,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 
                /* name(s) */
                s = strpbrk(sb.buf, flag_chars);
-               if (s == NULL)
+               if (!s)
                        s = help;
 
                if (s - sb.buf == 1) /* short option only */
index e7f7af5de3ff005150680d19761828c7b9984ecf..16a66d8cf452eec372c7b409c77c60aa87aab518 100644 (file)
@@ -81,7 +81,7 @@ static void insert_one_record(struct shortlog *log,
                format_subject(&subject, oneline, " ");
                buffer = strbuf_detach(&subject, NULL);
 
-               if (item->util == NULL)
+               if (!item->util)
                        item->util = xcalloc(1, sizeof(struct string_list));
                string_list_append(item->util, buffer);
        }
index 6fe646710d6ffbf242dda3bf7a5c27742acc0ef3..73a00a6f6fe67d92c7d14361b70152a388369a38 100644 (file)
@@ -364,7 +364,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
                strbuf_addstr(sb, "object of unknown type");
                break;
        case OBJ_COMMIT:
-               if ((buf = read_object_file(oid, &type, &size)) != NULL) {
+               if ((buf = read_object_file(oid, &type, &size))) {
                        subject_len = find_commit_subject(buf, &subject_start);
                        strbuf_insert(sb, sb->len, subject_start, subject_len);
                } else {
@@ -372,7 +372,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
                }
                free(buf);
 
-               if ((c = lookup_commit_reference(the_repository, oid)) != NULL)
+               if ((c = lookup_commit_reference(the_repository, oid)))
                        strbuf_addf(sb, ", %s", show_date(c->date, 0, DATE_MODE(SHORT)));
                break;
        case OBJ_TREE:
index d93782daeb37fee21f5898600ff15628b32d4779..b724f02123d838547fa87fb785d94a2a3141c3e8 100644 (file)
@@ -195,10 +195,10 @@ static struct lline *coalesce_lines(struct lline *base, int *lenbase,
        struct lline *baseend, *newend = NULL;
        int i, j, origbaselen = *lenbase;
 
-       if (newline == NULL)
+       if (!newline)
                return base;
 
-       if (base == NULL) {
+       if (!base) {
                *lenbase = lennew;
                return newline;
        }
index 2706683acfe1c1fc982b1c3119b3e895cac57006..d251a99b8ea97a8c3e5ca371151648c7f6ac863b 100644 (file)
@@ -2552,7 +2552,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
                odb_parents = odb_commit->parents;
 
                while (graph_parents) {
-                       if (odb_parents == NULL) {
+                       if (!odb_parents) {
                                graph_report(_("commit-graph parent list for commit %s is too long"),
                                             oid_to_hex(&cur_oid));
                                break;
@@ -2575,7 +2575,7 @@ int verify_commit_graph(struct repository *r, struct commit_graph *g, int flags)
                        odb_parents = odb_parents->next;
                }
 
-               if (odb_parents != NULL)
+               if (odb_parents)
                        graph_report(_("commit-graph parent list for commit %s terminates early"),
                                     oid_to_hex(&cur_oid));
 
index 5e42191fa4acb4ec353df177488ec4d7d1555a05..36ef6329045e468740d48e4fc51a3f966557b380 100644 (file)
@@ -1043,7 +1043,7 @@ char *mingw_mktemp(char *template)
 int mkstemp(char *template)
 {
        char *filename = mktemp(template);
-       if (filename == NULL)
+       if (!filename)
                return -1;
        return open(filename, O_RDWR | O_CREAT, 0600);
 }
@@ -2311,7 +2311,7 @@ int setitimer(int type, struct itimerval *in, struct itimerval *out)
        static const struct timeval zero;
        static int atexit_done;
 
-       if (out != NULL)
+       if (out)
                return errno = EINVAL,
                        error("setitimer param 3 != NULL not implemented");
        if (!is_timeval_eq(&in->it_interval, &zero) &&
@@ -2340,7 +2340,7 @@ int sigaction(int sig, struct sigaction *in, struct sigaction *out)
        if (sig != SIGALRM)
                return errno = EINVAL,
                        error("sigaction only implemented for SIGALRM");
-       if (out != NULL)
+       if (out)
                return errno = EINVAL,
                        error("sigaction: param 3 != NULL not implemented");
 
index 9e253fb72f2df92a09b562dde59f347c4c207a57..02aea3b32ef1e3c8944985edca52f3b0413e1739 100644 (file)
@@ -9,7 +9,7 @@ int compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode)
        size_t len = strlen(dir);
 
        if (len && dir[len-1] == '/') {
-               if ((tmp_dir = strdup(dir)) == NULL)
+               if (!(tmp_dir = strdup(dir)))
                        return -1;
                tmp_dir[len-1] = '\0';
        }
index 8d6c02d4bccc0160e69d3c0892946bfc79f10d00..2fe1c7732eea9491e4bb26902f60430b6c0bb828 100644 (file)
@@ -13,7 +13,7 @@ void *git_mmap(void *start, size_t length, int prot, int flags, int fd, off_t of
        }
 
        start = malloc(length);
-       if (start == NULL) {
+       if (!start) {
                errno = ENOMEM;
                return MAP_FAILED;
        }
index c5873f3a70643a9c03feeec4981a06a439e78118..f9e29461c8032d092464c162c2707bca385f7599 100644 (file)
--- a/config.c
+++ b/config.c
@@ -2959,7 +2959,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
                        goto out_free;
                }
                /* if nothing to unset, error out */
-               if (value == NULL) {
+               if (!value) {
                        ret = CONFIG_NOTHING_SET;
                        goto out_free;
                }
@@ -2975,7 +2975,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
                int i, new_line = 0;
                struct config_options opts;
 
-               if (value_pattern == NULL)
+               if (!value_pattern)
                        store.value_pattern = NULL;
                else if (value_pattern == CONFIG_REGEX_NONE)
                        store.value_pattern = CONFIG_REGEX_NONE;
@@ -3115,7 +3115,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
                }
 
                /* write the pair (value == NULL means unset) */
-               if (value != NULL) {
+               if (value) {
                        if (!store.section_seen) {
                                if (write_section(fd, key, &store) < 0)
                                        goto write_err_out;
@@ -3322,7 +3322,7 @@ static int git_config_copy_or_rename_section_in_file(const char *config_filename
                        offset = section_name_match(&buf[i], old_name);
                        if (offset > 0) {
                                ret++;
-                               if (new_name == NULL) {
+                               if (!new_name) {
                                        remove = 1;
                                        continue;
                                }
index b1fcbe0d6fa847dd936467c0d8d1aeffbf90d1cc..842c36c64438bf013e6b01cd3955502165a2064e 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -451,7 +451,7 @@ static void copy_to_log(int fd)
        FILE *fp;
 
        fp = fdopen(fd, "r");
-       if (fp == NULL) {
+       if (!fp) {
                logerror("fdopen of error channel failed");
                close(fd);
                return;
diff --git a/dir.c b/dir.c
index 5aa6fbad0b76ad3ad026a8775761f9c7ea1776e8..7a4e55b19be560d7f6e838632fab6276915a914d 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -3049,7 +3049,7 @@ char *git_url_basename(const char *repo, int is_bundle, int is_bare)
         * Skip scheme.
         */
        start = strstr(repo, "://");
-       if (start == NULL)
+       if (!start)
                start = repo;
        else
                start += 3;
index 38a47c44db4c6cd43bd384890ed414d4665bf456..a4f9fcd1c1bc230f459b21a1e0d061165c919a71 100644 (file)
@@ -223,7 +223,7 @@ void bitmap_reset(struct bitmap *bitmap)
 
 void bitmap_free(struct bitmap *bitmap)
 {
-       if (bitmap == NULL)
+       if (!bitmap)
                return;
 
        free(bitmap->words);
index 2a8c7c5c33ab864788baaa7b6a52a5c59f84f7d0..6fe48d3ae0449a0298deb109b967ef3479ef0c47 100644 (file)
@@ -451,7 +451,7 @@ struct ewah_bitmap *ewah_pool_new(void)
 
 void ewah_pool_free(struct ewah_bitmap *self)
 {
-       if (self == NULL)
+       if (!self)
                return;
 
        if (bitmap_pool_size == BITMAP_POOL_MAX ||
index fa642462a9e63867146c3c563aff9bce7b93d284..f0b2c5e1f963d34bba53dbc690dff92c4b9a833e 100644 (file)
@@ -54,7 +54,7 @@ static void fetch_single_packfile(struct object_id *packfile_hash,
        http_init(NULL, url, 0);
 
        preq = new_direct_http_pack_request(packfile_hash->hash, xstrdup(url));
-       if (preq == NULL)
+       if (!preq)
                die("couldn't create http pack request");
        preq->slot->results = &results;
        preq->index_pack_args = index_pack_args;
index 3309aaf004a4db175bc4c0b94b5c63efebcb30e3..28ffed7bc4592cdc2b774be6adeb9325e4672360 100644 (file)
@@ -253,7 +253,7 @@ static void start_fetch_loose(struct transfer_request *request)
        struct http_object_request *obj_req;
 
        obj_req = new_http_object_request(repo->url, &request->obj->oid);
-       if (obj_req == NULL) {
+       if (!obj_req) {
                request->state = ABORTED;
                return;
        }
@@ -318,7 +318,7 @@ static void start_fetch_packed(struct transfer_request *request)
        fprintf(stderr, " which contains %s\n", oid_to_hex(&request->obj->oid));
 
        preq = new_http_pack_request(target->hash, repo->url);
-       if (preq == NULL) {
+       if (!preq) {
                repo->can_update_info_refs = 0;
                return;
        }
@@ -520,7 +520,7 @@ static void finish_request(struct transfer_request *request)
        /* Keep locks active */
        check_locks();
 
-       if (request->headers != NULL)
+       if (request->headers)
                curl_slist_free_all(request->headers);
 
        /* 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)
        const char *c = strchr(name, ':');
        int old_namelen, new_len;
 
-       if (c == NULL)
+       if (!c)
                c = name;
        else
                c++;
@@ -811,7 +811,7 @@ xml_end_tag(void *userData, const char *name)
 
        ctx->userFunc(ctx, 1);
 
-       if (c == NULL)
+       if (!c)
                c = name;
        else
                c++;
@@ -1893,7 +1893,7 @@ int cmd_main(int argc, const char **argv)
 
                /* Lock remote branch ref */
                ref_lock = lock_remote(ref->name, LOCK_TIME);
-               if (ref_lock == NULL) {
+               if (!ref_lock) {
                        fprintf(stderr, "Unable to lock remote branch %s\n",
                                ref->name);
                        if (helper_status)
index 910fae539b89e6aea2af299b61dd64ff645b3578..b8f0f98ae146999adf3770cc7338cbacbbbf8cb3 100644 (file)
@@ -59,7 +59,7 @@ static void start_object_request(struct walker *walker,
        struct http_object_request *req;
 
        req = new_http_object_request(obj_req->repo->base, &obj_req->oid);
-       if (req == NULL) {
+       if (!req) {
                obj_req->state = ABORTED;
                return;
        }
@@ -106,7 +106,7 @@ static void process_object_response(void *callback_data)
        /* Use alternates if necessary */
        if (missing_target(obj_req->req)) {
                fetch_alternates(walker, alt->base);
-               if (obj_req->repo->next != NULL) {
+               if (obj_req->repo->next) {
                        obj_req->repo =
                                obj_req->repo->next;
                        release_http_object_request(obj_req->req);
@@ -225,12 +225,12 @@ static void process_alternates_response(void *callback_data)
                                         alt_req->url->buf);
                        active_requests++;
                        slot->in_use = 1;
-                       if (slot->finished != NULL)
+                       if (slot->finished)
                                (*slot->finished) = 0;
                        if (!start_active_slot(slot)) {
                                cdata->got_alternates = -1;
                                slot->in_use = 0;
-                               if (slot->finished != NULL)
+                               if (slot->finished)
                                        (*slot->finished) = 1;
                        }
                        return;
@@ -443,7 +443,7 @@ static int http_fetch_pack(struct walker *walker, struct alt_base *repo, unsigne
        }
 
        preq = new_http_pack_request(target->hash, repo->base);
-       if (preq == NULL)
+       if (!preq)
                goto abort;
        preq->slot->results = &results;
 
@@ -489,11 +489,11 @@ static int fetch_object(struct walker *walker, unsigned char *hash)
                if (hasheq(obj_req->oid.hash, hash))
                        break;
        }
-       if (obj_req == NULL)
+       if (!obj_req)
                return error("Couldn't find request for %s in the queue", hex);
 
        if (has_object_file(&obj_req->oid)) {
-               if (obj_req->req != NULL)
+               if (obj_req->req)
                        abort_http_object_request(obj_req->req);
                abort_object_request(obj_req);
                return 0;
diff --git a/http.c b/http.c
index f92859f43fa53e0352b239ca43a769c5f9ff4aae..a39cea1d4aca06d349d757170fc2badeb23bac7b 100644 (file)
--- a/http.c
+++ b/http.c
@@ -197,11 +197,11 @@ static void finish_active_slot(struct active_request_slot *slot)
        closedown_active_slot(slot);
        curl_easy_getinfo(slot->curl, CURLINFO_HTTP_CODE, &slot->http_code);
 
-       if (slot->finished != NULL)
+       if (slot->finished)
                (*slot->finished) = 1;
 
        /* Store slot results so they can be read after the slot is reused */
-       if (slot->results != NULL) {
+       if (slot->results) {
                slot->results->curl_result = slot->curl_result;
                slot->results->http_code = slot->http_code;
                curl_easy_getinfo(slot->curl, CURLINFO_HTTPAUTH_AVAIL,
@@ -212,7 +212,7 @@ static void finish_active_slot(struct active_request_slot *slot)
        }
 
        /* Run callback if appropriate */
-       if (slot->callback_func != NULL)
+       if (slot->callback_func)
                slot->callback_func(slot->callback_data);
 }
 
@@ -234,7 +234,7 @@ static void process_curl_messages(void)
                        while (slot != NULL &&
                               slot->curl != curl_message->easy_handle)
                                slot = slot->next;
-                       if (slot != NULL) {
+                       if (slot) {
                                xmulti_remove_handle(slot);
                                slot->curl_result = curl_result;
                                finish_active_slot(slot);
@@ -838,16 +838,16 @@ static CURL *get_curl_handle(void)
                curl_easy_setopt(result, CURLOPT_SSL_CIPHER_LIST,
                                ssl_cipherlist);
 
-       if (ssl_cert != NULL)
+       if (ssl_cert)
                curl_easy_setopt(result, CURLOPT_SSLCERT, ssl_cert);
        if (has_cert_password())
                curl_easy_setopt(result, CURLOPT_KEYPASSWD, cert_auth.password);
-       if (ssl_key != NULL)
+       if (ssl_key)
                curl_easy_setopt(result, CURLOPT_SSLKEY, ssl_key);
-       if (ssl_capath != NULL)
+       if (ssl_capath)
                curl_easy_setopt(result, CURLOPT_CAPATH, ssl_capath);
 #ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY
-       if (ssl_pinnedkey != NULL)
+       if (ssl_pinnedkey)
                curl_easy_setopt(result, CURLOPT_PINNEDPUBLICKEY, ssl_pinnedkey);
 #endif
        if (http_ssl_backend && !strcmp("schannel", http_ssl_backend) &&
@@ -857,10 +857,10 @@ static CURL *get_curl_handle(void)
                curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, NULL);
 #endif
        } else if (ssl_cainfo != NULL || http_proxy_ssl_ca_info != NULL) {
-               if (ssl_cainfo != NULL)
+               if (ssl_cainfo)
                        curl_easy_setopt(result, CURLOPT_CAINFO, ssl_cainfo);
 #ifdef GIT_CURL_HAVE_CURLOPT_PROXY_CAINFO
-               if (http_proxy_ssl_ca_info != NULL)
+               if (http_proxy_ssl_ca_info)
                        curl_easy_setopt(result, CURLOPT_PROXY_CAINFO, http_proxy_ssl_ca_info);
 #endif
        }
@@ -1050,7 +1050,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
 
        {
                char *http_max_requests = getenv("GIT_HTTP_MAX_REQUESTS");
-               if (http_max_requests != NULL)
+               if (http_max_requests)
                        max_requests = atoi(http_max_requests);
        }
 
@@ -1069,10 +1069,10 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
        set_from_env(&user_agent, "GIT_HTTP_USER_AGENT");
 
        low_speed_limit = getenv("GIT_HTTP_LOW_SPEED_LIMIT");
-       if (low_speed_limit != NULL)
+       if (low_speed_limit)
                curl_low_speed_limit = strtol(low_speed_limit, NULL, 10);
        low_speed_time = getenv("GIT_HTTP_LOW_SPEED_TIME");
-       if (low_speed_time != NULL)
+       if (low_speed_time)
                curl_low_speed_time = strtol(low_speed_time, NULL, 10);
 
        if (curl_ssl_verify == -1)
@@ -1109,7 +1109,7 @@ void http_cleanup(void)
 
        while (slot != NULL) {
                struct active_request_slot *next = slot->next;
-               if (slot->curl != NULL) {
+               if (slot->curl) {
                        xmulti_remove_handle(slot);
                        curl_easy_cleanup(slot->curl);
                }
@@ -1147,13 +1147,13 @@ void http_cleanup(void)
        free((void *)http_proxy_authmethod);
        http_proxy_authmethod = NULL;
 
-       if (cert_auth.password != NULL) {
+       if (cert_auth.password) {
                memset(cert_auth.password, 0, strlen(cert_auth.password));
                FREE_AND_NULL(cert_auth.password);
        }
        ssl_cert_password_required = 0;
 
-       if (proxy_cert_auth.password != NULL) {
+       if (proxy_cert_auth.password) {
                memset(proxy_cert_auth.password, 0, strlen(proxy_cert_auth.password));
                FREE_AND_NULL(proxy_cert_auth.password);
        }
@@ -1179,14 +1179,14 @@ struct active_request_slot *get_active_slot(void)
        while (slot != NULL && slot->in_use)
                slot = slot->next;
 
-       if (slot == NULL) {
+       if (!slot) {
                newslot = xmalloc(sizeof(*newslot));
                newslot->curl = NULL;
                newslot->in_use = 0;
                newslot->next = NULL;
 
                slot = active_queue_head;
-               if (slot == NULL) {
+               if (!slot) {
                        active_queue_head = newslot;
                } else {
                        while (slot->next != NULL)
@@ -1196,7 +1196,7 @@ struct active_request_slot *get_active_slot(void)
                slot = newslot;
        }
 
-       if (slot->curl == NULL) {
+       if (!slot->curl) {
                slot->curl = curl_easy_duphandle(curl_default);
                curl_session_count++;
        }
@@ -1768,7 +1768,7 @@ static int http_request(const char *url,
        slot = get_active_slot();
        curl_easy_setopt(slot->curl, CURLOPT_HTTPGET, 1);
 
-       if (result == NULL) {
+       if (!result) {
                curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 1);
        } else {
                curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0);
@@ -2100,7 +2100,7 @@ cleanup:
 
 void release_http_pack_request(struct http_pack_request *preq)
 {
-       if (preq->packfile != NULL) {
+       if (preq->packfile) {
                fclose(preq->packfile);
                preq->packfile = NULL;
        }
@@ -2390,7 +2390,7 @@ abort:
 
 void process_http_object_request(struct http_object_request *freq)
 {
-       if (freq->slot == NULL)
+       if (!freq->slot)
                return;
        freq->curl_result = freq->slot->curl_result;
        freq->http_code = freq->slot->http_code;
@@ -2447,7 +2447,7 @@ void release_http_object_request(struct http_object_request *freq)
                freq->localfile = -1;
        }
        FREE_AND_NULL(freq->url);
-       if (freq->slot != NULL) {
+       if (freq->slot) {
                freq->slot->callback_func = NULL;
                freq->slot->callback_data = NULL;
                release_active_slot(freq->slot);
diff --git a/kwset.c b/kwset.c
index fc439e0667f137f3449635a37a32f8418d5041f0..08aadf03117c5069116bb7e7fa4aa5ed7a9b1fb0 100644 (file)
--- a/kwset.c
+++ b/kwset.c
@@ -477,7 +477,7 @@ kwsprep (kwset_t kws)
        next[i] = NULL;
       treenext(kwset->trie->links, next);
 
-      if ((trans = kwset->trans) != NULL)
+      if ((trans = kwset->trans))
        for (i = 0; i < NCHAR; ++i)
          kwset->next[i] = next[U(trans[i])];
       else
@@ -485,7 +485,7 @@ kwsprep (kwset_t kws)
     }
 
   /* Fix things up for any translation table. */
-  if ((trans = kwset->trans) != NULL)
+  if ((trans = kwset->trans))
     for (i = 0; i < NCHAR; ++i)
       kwset->delta[i] = delta[U(trans[i])];
   else
index 261657578c756c94f27ba03392ef82f4173d5460..d964b534c971786828fbe09a8e515a1b189ee213 100644 (file)
@@ -204,7 +204,7 @@ static int ll_ext_merge(const struct ll_merge_driver *fn,
        dict[4].placeholder = "P"; dict[4].value = path_sq.buf;
        dict[5].placeholder = NULL; dict[5].value = NULL;
 
-       if (fn->cmdline == NULL)
+       if (!fn->cmdline)
                die("custom merge driver %s lacks command line.", fn->name);
 
        result->ptr = NULL;
index 644893fd8cfff6a9ee9cda0b512c2adb9c8a6953..2083f52f4d8363beadb4e3be0bd2ca27d0cd84eb 100644 (file)
@@ -84,7 +84,7 @@ static int match_ref_pattern(const char *refname,
                             const struct string_list_item *item)
 {
        int matched = 0;
-       if (item->util == NULL) {
+       if (!item->util) {
                if (!wildmatch(item->string, refname, 0))
                        matched = 1;
        } else {
index 02f6f9535783a486b09e2f22481b39dbc039c89b..9621ba62a394348a95f6e5e181aea286c6c37b56 100644 (file)
@@ -698,7 +698,7 @@ static int is_scissors_line(const char *line)
                        continue;
                }
                last_nonblank = c;
-               if (first_nonblank == NULL)
+               if (!first_nonblank)
                        first_nonblank = c;
                if (*c == '-') {
                        in_perforation = 1;
@@ -1094,7 +1094,7 @@ static void handle_body(struct mailinfo *mi, struct strbuf *line)
                         */
                        lines = strbuf_split(line, '\n');
                        for (it = lines; (sb = *it); it++) {
-                               if (*(it + 1) == NULL) /* The last line */
+                               if (!*(it + 1)) /* The last line */
                                        if (sb->buf[sb->len - 1] != '\n') {
                                                /* Partial line, save it for later. */
                                                strbuf_addbuf(&prev, sb);
index 40ce152024d7dc3cf6d387dc5d0c1a47542129bd..10173f2d95e5b163b0556a93dd7116006169745e 100644 (file)
--- a/mailmap.c
+++ b/mailmap.c
@@ -77,7 +77,7 @@ static void add_mapping(struct string_list *map,
        struct mailmap_entry *me;
        struct string_list_item *item;
 
-       if (old_email == NULL) {
+       if (!old_email) {
                old_email = new_email;
                new_email = NULL;
        }
@@ -92,7 +92,7 @@ static void add_mapping(struct string_list *map,
                item->util = me;
        }
 
-       if (old_name == NULL) {
+       if (!old_name) {
                debug_mm("mailmap: adding (simple) entry for '%s'\n", old_email);
 
                /* Replace current name and new email for simple entry */
@@ -123,9 +123,9 @@ static char *parse_name_and_email(char *buffer, char **name,
        char *left, *right, *nstart, *nend;
        *name = *email = NULL;
 
-       if ((left = strchr(buffer, '<')) == NULL)
+       if (!(left = strchr(buffer, '<')))
                return NULL;
-       if ((right = strchr(left+1, '>')) == NULL)
+       if (!(right = strchr(left + 1, '>')))
                return NULL;
        if (!allow_empty_email && (left+1 == right))
                return NULL;
@@ -153,7 +153,7 @@ static void read_mailmap_line(struct string_list *map, char *buffer)
        if (buffer[0] == '#')
                return;
 
-       if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)) != NULL)
+       if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)))
                parse_name_and_email(name2, &name2, &email2, 1);
 
        if (email1)
@@ -319,7 +319,7 @@ int map_user(struct string_list *map,
                 (int)*emaillen, debug_str(*email));
 
        item = lookup_prefix(map, *email, *emaillen);
-       if (item != NULL) {
+       if (item) {
                me = (struct mailmap_entry *)item->util;
                if (me->namemap.nr) {
                        /*
@@ -333,7 +333,7 @@ int map_user(struct string_list *map,
                                item = subitem;
                }
        }
-       if (item != NULL) {
+       if (item) {
                struct mailmap_info *mi = (struct mailmap_info *)item->util;
                if (mi->name == NULL && mi->email == NULL) {
                        debug_mm("map_user:  -- (no simple mapping)\n");
index 0342f104836b69a7889b3fa686c7c359c27e5dd6..e5248b1d9fea90b92de56966d15e2f2b012d3f9f 100644 (file)
@@ -2018,7 +2018,7 @@ static char *handle_path_level_conflicts(struct merge_options *opt,
         * to ensure that's the case.
         */
        c_info = strmap_get(collisions, new_path);
-       if (c_info == NULL)
+       if (!c_info)
                BUG("c_info is NULL");
 
        /*
@@ -4574,7 +4574,7 @@ static void merge_ort_internal(struct merge_options *opt,
        }
 
        merged_merge_bases = pop_commit(&merge_bases);
-       if (merged_merge_bases == NULL) {
+       if (!merged_merge_bases) {
                /* if there is no common ancestor, use an empty tree */
                struct tree *tree;
 
index d9457797dbb73bfed720ac9ca0b9bcf56575c62a..543a7caa15dd9331783d76614e8fa0b27efa5cc9 100644 (file)
@@ -82,7 +82,7 @@ static struct dir_rename_entry *dir_rename_find_entry(struct hashmap *hashmap,
 {
        struct dir_rename_entry key;
 
-       if (dir == NULL)
+       if (!dir)
                return NULL;
        hashmap_entry_init(&key.ent, strhash(dir));
        key.dir = dir;
@@ -1987,14 +1987,14 @@ static void get_renamed_dir_portion(const char *old_path, const char *new_path,
         * renamed means the root directory can never be renamed -- because
         * the root directory always exists).
         */
-       if (end_of_old == NULL)
+       if (!end_of_old)
                return; /* Note: *old_dir and *new_dir are still NULL */
 
        /*
         * If new_path contains no directory (end_of_new is NULL), then we
         * have a rename of old_path's directory to the root directory.
         */
-       if (end_of_new == NULL) {
+       if (!end_of_new) {
                *old_dir = xstrndup(old_path, end_of_old - old_path);
                *new_dir = xstrdup("");
                return;
@@ -2113,7 +2113,7 @@ static char *handle_path_level_conflicts(struct merge_options *opt,
         * to ensure that's the case.
         */
        collision_ent = collision_find_entry(collisions, new_path);
-       if (collision_ent == NULL)
+       if (!collision_ent)
                BUG("collision_ent is NULL");
 
        /*
@@ -2993,7 +2993,7 @@ static void final_cleanup_rename(struct string_list *rename)
        const struct rename *re;
        int i;
 
-       if (rename == NULL)
+       if (!rename)
                return;
 
        for (i = 0; i < rename->nr; i++) {
@@ -3602,7 +3602,7 @@ static int merge_recursive_internal(struct merge_options *opt,
        }
 
        merged_merge_bases = pop_commit(&merge_bases);
-       if (merged_merge_bases == NULL) {
+       if (!merged_merge_bases) {
                /* if there is no common ancestor, use an empty tree */
                struct tree *tree;
 
index c3d866a287e03ad0ae5de97ab6a352887c92e233..a0b3f002422a73db5146dbe594764390e86a50da 100644 (file)
@@ -1672,7 +1672,7 @@ void *read_object_file_extended(struct repository *r,
                die(_("loose object %s (stored in %s) is corrupt"),
                    oid_to_hex(repl), path);
 
-       if ((p = has_packed_and_bad(r, repl)) != NULL)
+       if ((p = has_packed_and_bad(r, repl)))
                die(_("packed object %s (stored in %s) is corrupt"),
                    oid_to_hex(repl), p->pack_name);
        obj_read_unlock();
index f47a0a7db4dd30a6450b3e59e0ec463c5578da39..c5317364c5cd7aabccf44d7c35515d5a3f071589 100644 (file)
@@ -111,7 +111,7 @@ static struct ewah_bitmap *lookup_stored_bitmap(struct stored_bitmap *st)
        struct ewah_bitmap *parent;
        struct ewah_bitmap *composed;
 
-       if (st->xor == NULL)
+       if (!st->xor)
                return st->root;
 
        composed = ewah_pool_new();
@@ -279,7 +279,7 @@ static int load_bitmap_entries_v1(struct bitmap_index *index)
                if (xor_offset > 0) {
                        xor_bitmap = recent_bitmaps[(i - xor_offset) % MAX_XOR_OFFSET];
 
-                       if (xor_bitmap == NULL)
+                       if (!xor_bitmap)
                                return error("Invalid XOR offset in bitmap pack index");
                }
 
@@ -719,7 +719,7 @@ static int add_commit_to_bitmap(struct bitmap_index *bitmap_git,
        if (!or_with)
                return 0;
 
-       if (*base == NULL)
+       if (!*base)
                *base = ewah_to_bitmap(or_with);
        else
                bitmap_or_ewah(*base, or_with);
@@ -763,7 +763,7 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
         * Best case scenario: We found bitmaps for all the roots,
         * so the resulting `or` bitmap has the full reachability analysis
         */
-       if (not_mapped == NULL)
+       if (!not_mapped)
                return base;
 
        roots = not_mapped;
@@ -797,7 +797,7 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
                struct include_data incdata;
                struct bitmap_show_data show_data;
 
-               if (base == NULL)
+               if (!base)
                        base = bitmap_new();
 
                incdata.bitmap_git = bitmap_git;
@@ -1293,7 +1293,7 @@ struct bitmap_index *prepare_bitmap_walk(struct rev_info *revs,
                reset_revision_walk();
                revs->ignore_missing_links = 0;
 
-               if (haves_bitmap == NULL)
+               if (!haves_bitmap)
                        BUG("failed to perform bitmap walk");
        }
 
@@ -1691,7 +1691,7 @@ void test_bitmap_walk(struct rev_info *revs)
                result = ewah_to_bitmap(bm);
        }
 
-       if (result == NULL)
+       if (!result)
                die("Commit %s doesn't have an indexed bitmap", oid_to_hex(&root->oid));
 
        revs->tag_objects = 1;
index 89402cfc69cd0f03b268f26bd6c8c7ad459b3e1b..ef452be17750d869d03d9c740fb2a69a324c1fe0 100644 (file)
@@ -116,7 +116,7 @@ int load_idx(const char *path, const unsigned int hashsz, void *idx_map,
 
        if (idx_size < 4 * 256 + hashsz + hashsz)
                return error("index file %s is too small", path);
-       if (idx_map == NULL)
+       if (!idx_map)
                return error("empty data");
 
        if (hdr->idx_signature == htonl(PACK_IDX_SIGNATURE)) {
diff --git a/path.c b/path.c
index d73146b6cd266a9d051c334ae63bb91426da0a33..3236122aad2066c6047139920d00ad155435c221 100644 (file)
--- a/path.c
+++ b/path.c
@@ -733,7 +733,7 @@ char *interpolate_path(const char *path, int real_home)
        struct strbuf user_path = STRBUF_INIT;
        const char *to_copy = path;
 
-       if (path == NULL)
+       if (!path)
                goto return_null;
 
        if (skip_prefix(path, "%(prefix)/", &path))
index d3f488cb05f29bc90e4e03810d9bf4b972d0834f..d31b48e725083654222842049e121a35fe8d511b 100644 (file)
@@ -19,7 +19,7 @@ void prio_queue_reverse(struct prio_queue *queue)
 {
        int i, j;
 
-       if (queue->compare != NULL)
+       if (queue->compare)
                BUG("prio_queue_reverse() on non-LIFO queue");
        for (i = 0; i < (j = (queue->nr - 1) - i); i++)
                swap(queue, i, j);
index db2ebdc66ef2fe465456e39c4d33c6e5f6bd36de..8d6695681c1040aa2c1941228f325607c0c81e6b 100644 (file)
@@ -84,7 +84,7 @@ static void promisor_remote_move_to_tail(struct promisor_remote_config *config,
                                         struct promisor_remote *r,
                                         struct promisor_remote *previous)
 {
-       if (r->next == NULL)
+       if (!r->next)
                return;
 
        if (previous)
index 08a3f839c979ea11ada8f830f5640a965f3058b9..af919ff7c810512f45353b8fd00941ecb1205189 100644 (file)
@@ -1261,7 +1261,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
         * ":" means no format is specified, and use the default.
         */
        formatp = strchr(atomname, ':');
-       if (formatp != NULL) {
+       if (formatp) {
                formatp++;
                parse_date_format(formatp, &date_mode);
        }
@@ -1508,7 +1508,7 @@ static void fill_missing_values(struct atom_value *val)
        int i;
        for (i = 0; i < used_atom_cnt; i++) {
                struct atom_value *v = &val[i];
-               if (v->s == NULL)
+               if (!v->s)
                        v->s = xstrdup("");
        }
 }
@@ -1618,7 +1618,7 @@ static const char *rstrip_ref_components(const char *refname, int len)
 
        while (remaining-- > 0) {
                char *p = strrchr(start, '/');
-               if (p == NULL) {
+               if (!p) {
                        free((char *)to_free);
                        return xstrdup("");
                } else
index be4aa5e09818fad082a7c15303746edd8a5ddcaf..bf97cfbf6911d62b1b5617a2771c242f85765c0e 100644 (file)
@@ -134,7 +134,7 @@ int search_ref_dir(struct ref_dir *dir, const char *refname, size_t len)
        r = bsearch(&key, dir->entries, dir->nr, sizeof(*dir->entries),
                    ref_entry_cmp_sslice);
 
-       if (r == NULL)
+       if (!r)
                return -1;
 
        return r - dir->entries;
index d83d58df4fbc930b756395a8a99a77be4c1e598f..bcefd0c4bf6a922925a11e24d92113f6930ef761 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -591,7 +591,7 @@ int rerere_remaining(struct repository *r, struct string_list *merge_rr)
                else if (conflict_type == RESOLVED) {
                        struct string_list_item *it;
                        it = string_list_lookup(merge_rr, (const char *)e->name);
-                       if (it != NULL) {
+                       if (it) {
                                free_rerere_id(it);
                                it->util = RERERE_RESOLVED;
                        }
index 1981a0859f0e24cadec5e496e9616dc39f23330c..d29c16e55c31c89ab49f2b77b5f93da99af87319 100644 (file)
@@ -2801,7 +2801,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
        }
        strvec_clear(&prune_data);
 
-       if (revs->def == NULL)
+       if (!revs->def)
                revs->def = opt ? opt->def : NULL;
        if (opt && opt->tweak)
                opt->tweak(revs, opt);
@@ -3620,7 +3620,7 @@ static enum rewrite_result rewrite_one_1(struct rev_info *revs,
                        return rewrite_one_ok;
                if (!p->parents)
                        return rewrite_one_noparents;
-               if ((p = one_relevant_parent(revs, p->parents)) == NULL)
+               if (!(p = one_relevant_parent(revs, p->parents)))
                        return rewrite_one_ok;
                *pp = p;
        }
diff --git a/setup.c b/setup.c
index a9161acbe204fe680c2ee4d399f3ea5c788a525b..ac1ef9d97649ae5cc051bdaf32bb16cb6e207dbf 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -1404,7 +1404,7 @@ int git_config_perm(const char *var, const char *value)
        int i;
        char *endptr;
 
-       if (value == NULL)
+       if (!value)
                return PERM_GROUP;
 
        if (!strcmp(value, "umask"))
index 6cd307ac2c65a2825e467aeb9c1e6abfe8cc7e70..133496bd4d9f2979dfe2765e98a50186463dde1d 100644 (file)
@@ -397,7 +397,7 @@ subst_from_stdin (void)
                  /* Substitute the variable's value from the environment.  */
                  const char *env_value = getenv (buffer);
 
-                 if (env_value != NULL)
+                 if (env_value)
                    fputs (env_value, stdout);
                }
              else
index 9ed18eb8849b27856b8cc409921757f7f069b28b..2868b2d3959c1c0a3597d54d6811737ef99d2f72 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -559,7 +559,7 @@ static void paint_down(struct paint_info *info, const struct object_id *oid,
                else
                        c->object.flags |= SEEN;
 
-               if (*refs == NULL)
+               if (!*refs)
                        *refs = bitmap;
                else {
                        memcpy(tmp, *refs, bitmap_size);
index 7c7cb61a945c7ba2634685d6d49e3ad7ac23204a..374b84f6b458aa0a5a216756a17da1e8ef505c9d 100644 (file)
--- a/trailer.c
+++ b/trailer.c
@@ -1029,7 +1029,7 @@ static FILE *create_in_place_tempfile(const char *file)
 
        /* Create temporary file in the same directory as the original */
        tail = strrchr(file, '/');
-       if (tail != NULL)
+       if (tail)
                strbuf_add(&filename_template, file, tail - file + 1);
        strbuf_addstr(&filename_template, "git-interpret-trailers-XXXXXX");
 
index e4f1decae2063ce8981344c19626141c8bcd866c..a52c7e266f031f683e5d3c6a0aff478f6b925e5f 100644 (file)
@@ -427,7 +427,7 @@ static int fetch_refs_via_pack(struct transport *transport,
                args.self_contained_and_connected;
        data->options.connectivity_checked = args.connectivity_checked;
 
-       if (refs == NULL)
+       if (!refs)
                ret = -1;
        if (report_unmatched_refs(to_fetch, nr_heads))
                ret = -1;
index 9e9e2a2f955d242cf994c5451c537a7f88539379..7e5a7ea1eaa9d9d49219537b70256f1d947633ea 100644 (file)
@@ -113,7 +113,7 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags)
                                /* Trailing "**" matches everything.  Trailing "*" matches
                                 * only if there are no more slash characters. */
                                if (!match_slash) {
-                                       if (strchr((char*)text, '/') != NULL)
+                                       if (strchr((char *)text, '/'))
                                                return WM_NOMATCH;
                                }
                                return WM_MATCH;
index 092a4f92ad250e6ab474b6528957cfcf18bb8fda..ac099fa01867f36d8992793e1615c66ce607cf19 100644 (file)
@@ -486,7 +486,7 @@ int submodule_uses_worktrees(const char *path)
                return 0;
 
        d = readdir_skip_dot_and_dotdot(dir);
-       if (d != NULL)
+       if (d)
                ret = 1;
        closedir(dir);
        return ret;
index 36e12119d76556a710dbc8da2953a4710e630fdb..f500c2be1b70fd50a9a36845e0c4f912ddf5be11 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -383,7 +383,7 @@ FILE *xfopen(const char *path, const char *mode)
 FILE *xfdopen(int fd, const char *mode)
 {
        FILE *stream = fdopen(fd, mode);
-       if (stream == NULL)
+       if (!stream)
                die_errno("Out of memory? fdopen failed");
        return stream;
 }
index 75b32aef51dabf9e9ae8384d0376287e3a8495d0..a2f086e5b3011d6c71e3a70af60286cc868cb522 100644 (file)
@@ -159,7 +159,7 @@ int read_mmfile(mmfile_t *ptr, const char *filename)
 
        if (stat(filename, &st))
                return error_errno("Could not stat %s", filename);
-       if ((f = fopen(filename, "rb")) == NULL)
+       if (!(f = fopen(filename, "rb")))
                return error_errno("Could not open %s", filename);
        sz = xsize_t(st.st_size);
        ptr->ptr = xmalloc(sz ? sz : 1);
index 1cbf2b9829e759dd20f5e714d1390b26fe8cdd3d..c4ccd68d4760bc08735d6ca3b7dcdd3440abaf16 100644 (file)
@@ -65,7 +65,7 @@ xdchange_t *xdl_get_hunk(xdchange_t **xscr, xdemitconf_t const *xecfg)
                        *xscr = xch;
        }
 
-       if (*xscr == NULL)
+       if (!*xscr)
                return NULL;
 
        lxch = *xscr;
index abeb8fb84e6d73086d612b831963a227e35743b8..4c0561ce1fd1ad5487398fee19adc3bda073da15 100644 (file)
@@ -192,7 +192,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
        }
 
        nrec = 0;
-       if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) {
+       if ((cur = blk = xdl_mmfile_first(mf, &bsize))) {
                for (top = blk + bsize; cur < top; ) {
                        prev = cur;
                        hav = xdl_hash_record(&cur, top, xpp->flags);
index cfa6e2220ffd0461ce3293911c86366f6ccb1b05..115b2b1640b4504d1b7eb1bc4dc1428b109f6380 100644 (file)
@@ -122,7 +122,7 @@ long xdl_guess_lines(mmfile_t *mf, long sample) {
        long nl = 0, size, tsize = 0;
        char const *data, *cur, *top;
 
-       if ((cur = data = xdl_mmfile_first(mf, &size)) != NULL) {
+       if ((cur = data = xdl_mmfile_first(mf, &size))) {
                for (top = data + size; nl < sample && cur < top; ) {
                        nl++;
                        if (!(cur = memchr(cur, '\n', top - cur)))