reiserfsprogs: Fix sparse "warning: Using plain integer as NULL pointer"

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
This commit is contained in:
Jeff Mahoney committed 2013-08-26 19:02:18 -04:00
1 parent dd29f49a6c
commit 20357cf349
27 files changed
+192 -188

No files matched your search

+7 -7
View File
@@ -17,14 +17,14 @@ reiserfs_bitmap_t *reiserfs_create_bitmap(unsigned int bit_count)
bm = getmem(sizeof(*bm));
if (!bm)
return 0;
return NULL;
bm->bm_bit_size = bit_count;
bm->bm_byte_size = ((unsigned long long)bit_count + 7) / 8;
bm->bm_set_bits = 0;
bm->bm_map = getmem(bm->bm_byte_size);
if (!bm->bm_map) {
freemem(bm);
return 0;
return NULL;
}
return bm;
@@ -420,7 +420,7 @@ FILE *open_file(char *filename, char *option)
if (!fp) {
reiserfs_warning(stderr, "open_file: could not open file %s\n",
filename);
return 0;
return NULL;
}
reiserfs_warning(stderr, "Temp file opened by fsck: \"%s\" .. \n",
filename);
@@ -622,7 +622,7 @@ reiserfs_bitmap_t *reiserfs_bitmap_load(FILE * fp)
reiserfs_warning(stderr, "reiserfs_bitmap_load: "
"no bitmap start magic found");
// fclose (fp);
return 0;
return NULL;
}
/* read bit size of bitmap */
@@ -633,7 +633,7 @@ reiserfs_bitmap_t *reiserfs_bitmap_load(FILE * fp)
reiserfs_warning(stderr,
"reiserfs_bitmap_load: creation failed");
// fclose (fp);
return 0;
return NULL;
}
/*printf ("LOAD: bit_size - %d\n", v); */
@@ -665,7 +665,7 @@ reiserfs_bitmap_t *reiserfs_bitmap_load(FILE * fp)
if (v != BITMAP_END_MAGIC) {
reiserfs_warning(stderr, "reiserfs_bitmap_load: "
"no bitmap end magic found");
return 0;
return NULL;
}
/* reiserfs_warning (stderr, "%d bits set - done\n", reiserfs_bitmap_ones (bm)); */
@@ -692,7 +692,7 @@ void reiserfs_free_ondisk_bitmap(reiserfs_filsys_t *fs)
{
if (fs->fs_bitmap2) {
reiserfs_delete_bitmap(fs->fs_bitmap2);
fs->fs_bitmap2 = 0;
fs->fs_bitmap2 = NULL;
}
}
+4 -4
View File
@@ -143,9 +143,9 @@ static int balance_leaf_when_delete( /*struct reiserfs_transaction_handle *th, *
return 0;
}
/* all contents of all the 3 buffers will be in R[0] */
leaf_move_items(LEAF_FROM_S_TO_R, tb, n, -1, 0);
leaf_move_items(LEAF_FROM_S_TO_R, tb, n, -1, NULL);
leaf_move_items(LEAF_FROM_L_TO_R, tb,
B_NR_ITEMS(tb->L[0]), -1, 0);
B_NR_ITEMS(tb->L[0]), -1, NULL);
/* right_delimiting_key is correct in R[0] */
replace_key(tb->tb_fs, tb->CFR[0], tb->rkey[0],
@@ -1402,7 +1402,7 @@ struct buffer_head *get_FEB(struct tree_balance *tb)
struct buffer_info bi;
for (i = 0; i < MAX_FEB_SIZE; i++)
if (tb->FEB[i] != 0)
if (tb->FEB[i] != NULL)
break;
if (i == MAX_FEB_SIZE)
@@ -1413,7 +1413,7 @@ struct buffer_head *get_FEB(struct tree_balance *tb)
make_empty_node(&bi);
misc_set_bit(BH_Uptodate, &first_b->b_state);
tb->FEB[i] = 0;
tb->FEB[i] = NULL;
tb->used[i] = first_b;
return (first_b);
+8 -6
View File
@@ -918,7 +918,7 @@ static struct buffer_head *get_left_neighbor(reiserfs_filsys_t *s,
search_by_key(s, &key, &path_to_left_neighbor, DISK_LEAF_NODE_LEVEL);
if (PATH_LAST_POSITION(&path_to_left_neighbor) == 0) {
pathrelse(&path_to_left_neighbor);
return 0;
return NULL;
}
bh = PATH_PLAST_BUFFER(&path_to_left_neighbor);
bh->b_count++;
@@ -946,7 +946,7 @@ static struct buffer_head *get_right_neighbor(reiserfs_filsys_t *s,
if (PATH_PLAST_BUFFER(&path_to_right_neighbor) ==
PATH_PLAST_BUFFER(path)) {
pathrelse(&path_to_right_neighbor);
return 0;
return NULL;
}
bh = PATH_PLAST_BUFFER(&path_to_right_neighbor);
bh->b_count++;
@@ -963,7 +963,7 @@ int is_left_mergeable(reiserfs_filsys_t *s, struct reiserfs_path *path)
right = item_head(PATH_PLAST_BUFFER(path), 0);
bh = get_left_neighbor(s, path);
if (bh == 0) {
if (bh == NULL) {
return 0;
}
retval =
@@ -984,7 +984,7 @@ int is_right_mergeable(reiserfs_filsys_t *s, struct reiserfs_path *path)
B_NR_ITEMS(PATH_PLAST_BUFFER(path)) - 1);
bh = get_right_neighbor(s, path);
if (bh == 0) {
if (bh == NULL) {
return 0;
}
retval = are_items_mergeable(left, item_head(bh, 0), bh->b_size);
@@ -1221,7 +1221,8 @@ static int get_lfree(struct tree_balance *tb, int h)
struct buffer_head *l, *f;
int order;
if ((f = PATH_H_PPARENT(tb->tb_path, h)) == 0 || (l = tb->FL[h]) == 0)
if ((f = PATH_H_PPARENT(tb->tb_path, h)) == NULL ||
(l = tb->FL[h]) == NULL)
return 0;
if (f == l)
@@ -1247,7 +1248,8 @@ static int get_rfree(struct tree_balance *tb, int h)
struct buffer_head *r, *f;
int order;
if ((f = PATH_H_PPARENT(tb->tb_path, h)) == 0 || (r = tb->FR[h]) == 0)
if ((f = PATH_H_PPARENT(tb->tb_path, h)) == NULL ||
(r = tb->FR[h]) == NULL)
return 0;
if (f == r)
+2 -2
View File
@@ -786,9 +786,9 @@ void reiserfs_free_journal(reiserfs_filsys_t *fs)
if (!reiserfs_journal_opened(fs))
return;
brelse(fs->fs_jh_bh);
fs->fs_jh_bh = 0;
fs->fs_jh_bh = NULL;
free(fs->fs_j_file_name);
fs->fs_j_file_name = 0;
fs->fs_j_file_name = NULL;
}
void reiserfs_close_journal(reiserfs_filsys_t *fs)
+3 -3
View File
@@ -52,7 +52,7 @@ static void leaf_copy_dir_entries(struct buffer_info *dest_bi,
get_deh_location(&deh[from + copy_count - 1]);
} else {
copy_records_len = 0;
records = 0;
records = NULL;
}
/* when copy last to first, dest buffer can contain 0 items */
@@ -570,7 +570,7 @@ int leaf_shift_left(struct tree_balance *tb, int shift_num, int shift_bytes)
int i;
/* move shift_num (and shift_bytes bytes) items from S[0] to left neighbor L[0] */
i = leaf_move_items(LEAF_FROM_S_TO_L, tb, shift_num, shift_bytes, 0);
i = leaf_move_items(LEAF_FROM_S_TO_L, tb, shift_num, shift_bytes, NULL);
if (shift_num) {
if (B_NR_ITEMS(S0) == 0) {
@@ -597,7 +597,7 @@ int leaf_shift_right(struct tree_balance *tb, int shift_num, int shift_bytes)
/* move shift_num (and shift_bytes) items from S[0] to right neighbor R[0] */
ret_value =
leaf_move_items(LEAF_FROM_S_TO_R, tb, shift_num, shift_bytes, 0);
leaf_move_items(LEAF_FROM_S_TO_R, tb, shift_num, shift_bytes, NULL);
/* replace rkey in CFR[0] by the 0-th key from R[0] */
if (shift_num) {
+4 -4
View File
@@ -520,7 +520,7 @@ static const struct {
hashf_t func;
char *name;
} hashes[] = { {
0, "not set"}, {
NULL, "not set"}, {
keyed_hash, "\"tea\""}, {
yura_hash, "\"rupasov\""}, {
r5_hash, "\"r5\""}};
@@ -563,7 +563,7 @@ int is_properly_hashed(reiserfs_filsys_t *fs,
fprintf(stderr,
"Detecting hash code: could not detect hash with name \"%.*s\"\n",
namelen, name);
reiserfs_hash(fs) = 0;
reiserfs_hash(fs) = NULL;
return 1;
}
@@ -611,7 +611,7 @@ int find_hash_in_use(char *name, int namelen, __u32 offset,
char *code2name(unsigned int code)
{
if (code >= HASH_AMOUNT || code < 0)
return 0;
return NULL;
return hashes[code].name;
}
@@ -645,7 +645,7 @@ hashf_t name2func(char *hash)
for (i = 0; i < HASH_AMOUNT; i++)
if (!strcmp(hash, hashes[i].name))
return hashes[i].func;
return 0;
return NULL;
}
int dir_entry_bad_location(struct reiserfs_de_head *deh, struct item_head *ih,
+3 -3
View File
@@ -456,7 +456,7 @@ void reiserfs_print_item(FILE * fp, struct buffer_head *bh,
return;
}
print_directory_item(fp, 0, bh, ih);
print_directory_item(fp, NULL, bh, ih);
}
/* this prints internal nodes (4 keys/items in line) (dc_number,
@@ -813,8 +813,8 @@ void print_tb(int mode, int item_pos, int pos_in_item, struct tree_balance *tb,
} else {
/* printk ("print_tb: h=%d, PATH_H_PATH_OFFSET=%d, path_length=%d\n",
h, PATH_H_PATH_OFFSET (tb->tb_path, h), tb->tb_path->path_length); */
tbSh = 0;
tbFh = 0;
tbSh = NULL;
tbFh = NULL;
}
printf
("* %u * %3lu(%2lu) * %3lu(%2lu) * %3lu(%2lu) * %5lu * %5lu * %5lu * %5lu * %5lu *\n",
+27 -27
View File
@@ -76,7 +76,7 @@ reiserfs_filsys_t *reiserfs_open(const char *filename, int flags,
if (fd == -1) {
if (error)
*error = errno;
return 0;
return NULL;
}
fs = getmem(sizeof(*fs));
@@ -160,7 +160,7 @@ found:
"reiserfs_open: bread failed reading block %d, size %d\n",
i, fs->fs_blocksize);
freemem(fs);
return 0;
return NULL;
}
sb = (struct reiserfs_super_block *)bh->b_data;
}
@@ -199,7 +199,7 @@ reiserfs_filsys_t *reiserfs_create(char *filename,
if (count_blocks(filename, block_size) < block_count) {
reiserfs_warning(stderr,
"reiserfs_create: no enough blocks on device\n");
return 0;
return NULL;
}
if (!is_block_count_correct(REISERFS_DISK_OFFSET_IN_BYTES / block_size,
@@ -207,13 +207,13 @@ reiserfs_filsys_t *reiserfs_create(char *filename,
reiserfs_warning(stderr,
"reiserfs_create: can not create that small "
"(%u blocks) filesystem\n", block_count);
return 0;
return NULL;
}
fs = getmem(sizeof(*fs));
if (!fs) {
reiserfs_warning(stderr, "reiserfs_create: getmem failed\n");
return 0;
return NULL;
}
fs->fs_dev = open(filename, O_RDWR | O_EXCL
@@ -226,7 +226,7 @@ reiserfs_filsys_t *reiserfs_create(char *filename,
"reiserfs_create: could not open %s: %s\n",
filename, strerror(errno));
freemem(fs);
return 0;
return NULL;
}
fs->fs_blocksize = block_size;
@@ -244,7 +244,7 @@ reiserfs_filsys_t *reiserfs_create(char *filename,
if (!fs->fs_super_bh) {
reiserfs_warning(stderr, "reiserfs_create: getblk failed\n");
return 0;
return NULL;
}
mark_buffer_uptodate(fs->fs_super_bh, 1);
@@ -407,12 +407,12 @@ void reiserfs_free(reiserfs_filsys_t *fs)
/* release super block and memory used by filesystem handler */
brelse(fs->fs_super_bh);
fs->fs_super_bh = 0;
fs->fs_super_bh = NULL;
free_buffers();
free(fs->fs_file_name);
fs->fs_file_name = 0;
fs->fs_file_name = NULL;
freemem(fs);
}
@@ -464,7 +464,7 @@ static int reiserfs_search_by_key_x(reiserfs_filsys_t *fs,
curr = PATH_OFFSET_PELEMENT(path, ++path->path_length);
bh = curr->pe_buffer =
bread(fs->fs_dev, block, fs->fs_blocksize);
if (bh == 0) {
if (bh == NULL) {
path->path_length--;
pathrelse(path);
return ITEM_NOT_FOUND;
@@ -553,7 +553,7 @@ int reiserfs_search_by_position(reiserfs_filsys_t *s, struct reiserfs_key *key,
next_key = leaf_key(bh, PATH_LAST_POSITION(path));
else
next_key = uget_rkey(path);
if (next_key == 0 || not_of_one_file(next_key, key)) {
if (next_key == NULL || not_of_one_file(next_key, key)) {
/* there is no any part of such file in the tree */
path->pos_in_item = 0;
return FILE_NOT_FOUND;
@@ -642,7 +642,7 @@ struct reiserfs_key *uget_lkey(struct reiserfs_path *path)
}
/* there is no left delimiting key */
return 0;
return NULL;
}
struct reiserfs_key *uget_rkey(struct reiserfs_path *path)
@@ -679,7 +679,7 @@ struct reiserfs_key *uget_rkey(struct reiserfs_path *path)
}
/* there is no right delimiting key */
return 0;
return NULL;
}
struct reiserfs_key *reiserfs_next_key(struct reiserfs_path *path)
@@ -756,7 +756,8 @@ int reiserfs_search_by_entry_key(reiserfs_filsys_t *fs,
/* next item is in right neighboring node */
struct reiserfs_key *next_key = uget_rkey(path);
if (next_key == 0 || not_of_one_file(next_key, key)) {
if (next_key == NULL ||
not_of_one_file(next_key, key)) {
/* there are no items of that directory */
path->pos_in_item = 0;
return DIRECTORY_NOT_FOUND;
@@ -821,22 +822,22 @@ int reiserfs_remove_entry(reiserfs_filsys_t *fs, struct reiserfs_key *key)
if (get_ih_entry_count(ih) == 1) {
init_tb_struct(&tb, fs, &path,
-(IH_SIZE + get_ih_item_len(ih)));
if (fix_nodes(M_DELETE, &tb, 0) != CARRY_ON) {
if (fix_nodes(M_DELETE, &tb, NULL) != CARRY_ON) {
unfix_nodes(&tb);
return 1;
}
do_balance(&tb, 0, 0, M_DELETE, 0);
do_balance(&tb, NULL, NULL, M_DELETE, 0);
return 0;
}
deh = B_I_DEH(get_bh(&path), ih) + path.pos_in_item;
init_tb_struct(&tb, fs, &path,
-(DEH_SIZE + entry_length(ih, deh, path.pos_in_item)));
if (fix_nodes(M_CUT, &tb, 0) != CARRY_ON) {
if (fix_nodes(M_CUT, &tb, NULL) != CARRY_ON) {
unfix_nodes(&tb);
return 1;
}
do_balance(&tb, 0, 0, M_CUT, 0);
do_balance(&tb, NULL, NULL, M_CUT, 0);
return 0;
}
@@ -848,10 +849,10 @@ void reiserfs_paste_into_item(reiserfs_filsys_t *fs,
init_tb_struct(&tb, fs, path, size);
if (fix_nodes(M_PASTE, &tb, 0 /*ih */ ) != CARRY_ON)
if (fix_nodes(M_PASTE, &tb, NULL) != CARRY_ON)
reiserfs_panic("reiserfs_paste_into_item: fix_nodes failed");
do_balance(&tb, 0, body, M_PASTE, 0 /*zero num */ );
do_balance(&tb, NULL, body, M_PASTE, 0 /* zero num */ );
}
void reiserfs_insert_item(reiserfs_filsys_t *fs, struct reiserfs_path *path,
@@ -1081,7 +1082,7 @@ int reiserfs_add_entry(reiserfs_filsys_t *fs, struct reiserfs_key *dir,
int item_len;
__u32 hash;
if (reiserfs_find_entry(fs, dir, name, &gen_counter, 0))
if (reiserfs_find_entry(fs, dir, name, &gen_counter, NULL))
/* entry is in the directory already or directory was not found */
return 0;
@@ -1117,7 +1118,7 @@ int reiserfs_add_entry(reiserfs_filsys_t *fs, struct reiserfs_key *dir,
/* fsck may need to insert item which was not reached yet */
set_ih_flags(&entry_ih, fsck_need);
entry = make_entry(0, name, key, get_offset(&(entry_ih.ih_key)));
entry = make_entry(NULL, name, key, get_offset(&(entry_ih.ih_key)));
retval = reiserfs_search_by_entry_key(fs, &(entry_ih.ih_key), &path);
switch (retval) {
@@ -1401,11 +1402,10 @@ static void callback_badblock_rm(reiserfs_filsys_t *fs,
-(IH_SIZE +
get_ih_item_len(tp_item_head(badblock_path))));
if (fix_nodes(M_DELETE, &tb, 0) != CARRY_ON)
if (fix_nodes(M_DELETE, &tb, NULL) != CARRY_ON)
die("%s: fix_nodes failed", __FUNCTION__);
do_balance( /*tb.transaction_handle, */ &tb, 0, 0, M_DELETE,
0 /*zero num */ );
do_balance(&tb, NULL, NULL, M_DELETE, 0 /* zero num */);
}
void mark_badblock(reiserfs_filsys_t *fs,
@@ -1490,10 +1490,10 @@ void add_badblock_list(reiserfs_filsys_t *fs, int replace)
init_tb_struct(&tb, fs, &badblock_path, UNFM_P_SIZE);
if (fix_nodes(M_PASTE, &tb, 0) != CARRY_ON)
if (fix_nodes(M_PASTE, &tb, NULL) != CARRY_ON)
die("reiserfsck_paste_into_item: fix_nodes failed");
do_balance(&tb, 0, (const char *)&ni, M_PASTE, 0);
do_balance(&tb, NULL, (const char *)&ni, M_PASTE, 0);
break;
}
+1 -1
View File
@@ -372,7 +372,7 @@ int search_by_key(reiserfs_filsys_t *fs, struct reiserfs_key *p_s_key, /* Key to
/* make sure, that the node contents look like a node of
certain level */
if (!is_tree_node(p_s_bh, expected_level)) {
print_block(stderr, 0, p_s_bh, 3, -1, -1);
print_block(stderr, NULL, p_s_bh, 3, -1, -1);
reiserfs_panic("search_by_key: expected level %d",
expected_level);
}