tree-wide: apply equals-null.cocci
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
May 2, 2022 at 10:09 UTC
72a4ea71e5f29e4078363e87e4471128ff713a62
3 files changed
+9
-9
reftable/stack_test.c
+1
-1
@@ -35,7 +35,7 @@ static int count_dir_entries(const char *dirname)
35
DIR *dir = opendir(dirname);
36
int len = 0;
37
struct dirent *d;
38
- if (dir == NULL)
38
+ if (!dir)
39
return 0;
40
41
while ((d = readdir(dir))) {
reftable/tree.c
+2
-2
@@ -16,7 +16,7 @@ struct tree_node *tree_search(void *key, struct tree_node **rootp,
16
int insert)
17
{
18
int res;
19
- if (*rootp == NULL) {
19
+ if (!*rootp) {
20
if (!insert) {
21
return NULL;
22
} else {
@@ -50,7 +50,7 @@ void infix_walk(struct tree_node *t, void (*action)(void *arg, void *key),
50
51
void tree_free(struct tree_node *t)
52
{
53
- if (t == NULL) {
53
+ if (!t) {
54
return;
55
}
56
if (t->left) {
reftable/writer.c
+6
-6
@@ -181,7 +181,7 @@ static void writer_index_hash(struct reftable_writer *w, struct strbuf *hash)
181
struct tree_node *node = tree_search(&want, &w->obj_index_tree,
182
&obj_index_tree_node_compare, 0);
183
struct obj_index_tree_node *key = NULL;
184
- if (node == NULL) {
184
+ if (!node) {
185
struct obj_index_tree_node empty = OBJ_INDEX_TREE_NODE_INIT;
186
key = reftable_malloc(sizeof(struct obj_index_tree_node));
187
*key = empty;
@@ -220,7 +220,7 @@ static int writer_add_record(struct reftable_writer *w,
220
221
strbuf_reset(&w->last_key);
222
strbuf_addbuf(&w->last_key, &key);
223
- if (w->block_writer == NULL) {
223
+ if (!w->block_writer) {
224
writer_reinit_block_writer(w, reftable_record_type(rec));
225
}
226
@@ -258,7 +258,7 @@ int reftable_writer_add_ref(struct reftable_writer *w,
258
struct reftable_ref_record copy = *ref;
259
int err = 0;
260
261
- if (ref->refname == NULL)
261
+ if (!ref->refname)
262
return REFTABLE_API_ERROR;
263
if (ref->update_index < w->min_update_index ||
264
ref->update_index > w->max_update_index)
@@ -329,7 +329,7 @@ int reftable_writer_add_log(struct reftable_writer *w,
329
if (log->value_type == REFTABLE_LOG_DELETION)
330
return reftable_writer_add_log_verbatim(w, log);
331
332
- if (log->refname == NULL)
332
+ if (!log->refname)
333
return REFTABLE_API_ERROR;
334
335
input_log_message = log->value.update.message;
@@ -531,7 +531,7 @@ static int writer_finish_public_section(struct reftable_writer *w)
531
uint8_t typ = 0;
532
int err = 0;
533
534
- if (w->block_writer == NULL)
534
+ if (!w->block_writer)
535
return 0;
536
537
typ = block_writer_type(w->block_writer);
@@ -680,7 +680,7 @@ static int writer_flush_nonempty_block(struct reftable_writer *w)
680
681
static int writer_flush_block(struct reftable_writer *w)
682
{
683
- if (w->block_writer == NULL)
683
+ if (!w->block_writer)
684
return 0;
685
if (w->block_writer->entries == 0)
686
return 0;