Skip to content

Commit 72a4ea7

Browse files
committed
tree-wide: apply equals-null.cocci
Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2b0a58d commit 72a4ea7

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

reftable/stack_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static int count_dir_entries(const char *dirname)
3535
DIR *dir = opendir(dirname);
3636
int len = 0;
3737
struct dirent *d;
38-
if (dir == NULL)
38+
if (!dir)
3939
return 0;
4040

4141
while ((d = readdir(dir))) {

reftable/tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ struct tree_node *tree_search(void *key, struct tree_node **rootp,
1616
int insert)
1717
{
1818
int res;
19-
if (*rootp == NULL) {
19+
if (!*rootp) {
2020
if (!insert) {
2121
return NULL;
2222
} else {
@@ -50,7 +50,7 @@ void infix_walk(struct tree_node *t, void (*action)(void *arg, void *key),
5050

5151
void tree_free(struct tree_node *t)
5252
{
53-
if (t == NULL) {
53+
if (!t) {
5454
return;
5555
}
5656
if (t->left) {

reftable/writer.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static void writer_index_hash(struct reftable_writer *w, struct strbuf *hash)
181181
struct tree_node *node = tree_search(&want, &w->obj_index_tree,
182182
&obj_index_tree_node_compare, 0);
183183
struct obj_index_tree_node *key = NULL;
184-
if (node == NULL) {
184+
if (!node) {
185185
struct obj_index_tree_node empty = OBJ_INDEX_TREE_NODE_INIT;
186186
key = reftable_malloc(sizeof(struct obj_index_tree_node));
187187
*key = empty;
@@ -220,7 +220,7 @@ static int writer_add_record(struct reftable_writer *w,
220220

221221
strbuf_reset(&w->last_key);
222222
strbuf_addbuf(&w->last_key, &key);
223-
if (w->block_writer == NULL) {
223+
if (!w->block_writer) {
224224
writer_reinit_block_writer(w, reftable_record_type(rec));
225225
}
226226

@@ -258,7 +258,7 @@ int reftable_writer_add_ref(struct reftable_writer *w,
258258
struct reftable_ref_record copy = *ref;
259259
int err = 0;
260260

261-
if (ref->refname == NULL)
261+
if (!ref->refname)
262262
return REFTABLE_API_ERROR;
263263
if (ref->update_index < w->min_update_index ||
264264
ref->update_index > w->max_update_index)
@@ -329,7 +329,7 @@ int reftable_writer_add_log(struct reftable_writer *w,
329329
if (log->value_type == REFTABLE_LOG_DELETION)
330330
return reftable_writer_add_log_verbatim(w, log);
331331

332-
if (log->refname == NULL)
332+
if (!log->refname)
333333
return REFTABLE_API_ERROR;
334334

335335
input_log_message = log->value.update.message;
@@ -531,7 +531,7 @@ static int writer_finish_public_section(struct reftable_writer *w)
531531
uint8_t typ = 0;
532532
int err = 0;
533533

534-
if (w->block_writer == NULL)
534+
if (!w->block_writer)
535535
return 0;
536536

537537
typ = block_writer_type(w->block_writer);
@@ -680,7 +680,7 @@ static int writer_flush_nonempty_block(struct reftable_writer *w)
680680

681681
static int writer_flush_block(struct reftable_writer *w)
682682
{
683-
if (w->block_writer == NULL)
683+
if (!w->block_writer)
684684
return 0;
685685
if (w->block_writer->entries == 0)
686686
return 0;

0 commit comments

Comments
 (0)