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

Introduce and apply coccinelle rule to discourage an explicit
comparison between a pointer and NULL, and applies the clean-up to
the maintenance track.

* ep/maint-equals-null-cocci:
  tree-wide: apply equals-null.cocci
  tree-wide: apply equals-null.cocci
  contrib/coccinnelle: add equals-null.cocci
This commit is contained in:
Junio C Hamano
2022-05-20 15:26:59 -07:00
67 changed files with 180 additions and 150 deletions

View 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;
@ -1990,14 +1990,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;
@ -2116,7 +2116,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");
/*
@ -2996,7 +2996,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++) {
@ -3605,7 +3605,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;