reiserfscore: constify struct pointer arguments

There are many cases where functions take pointers to keys, item heads,
paths, etc and don't modify them. Let's annotate them properly.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
This commit is contained in:
Jeff Mahoney committed 2014-03-13 17:42:58 -04:00
1 parent 9b52a79ba2
commit 6daa8a9c5a
16 files changed
+97 -91

No files matched your search

+2 -2
View File
@@ -1452,7 +1452,7 @@ void reiserfs_invalidate_buffer(struct tree_balance *tb, struct buffer_head *bh)
reiserfs_free_block(tb->tb_fs, bh->b_blocknr);
}
int get_left_neighbor_position(struct tree_balance *tb, int h)
int get_left_neighbor_position(const struct tree_balance *tb, int h)
{
int Sh_position = PATH_H_POSITION(tb->tb_path, h + 1);
@@ -1462,7 +1462,7 @@ int get_left_neighbor_position(struct tree_balance *tb, int h)
return Sh_position - 1;
}
int get_right_neighbor_position(struct tree_balance *tb, int h)
int get_right_neighbor_position(const struct tree_balance *tb, int h)
{
int Sh_position = PATH_H_POSITION(tb->tb_path, h + 1);
+7 -7
View File
@@ -82,13 +82,13 @@ int is_a_leaf(const char *buf, int blocksize)
return counted ? HAS_IH_ARRAY : 0;
}
int leaf_item_number_estimate(struct buffer_head *bh)
int leaf_item_number_estimate(const struct buffer_head *bh)
{
const struct block_head *blkh;
int nr;
nr = leaf_count_ih(bh->b_data, bh->b_size);
blkh = (struct block_head *)bh->b_data;
blkh = (const struct block_head *)bh->b_data;
return nr >= get_blkh_nr_items(blkh) ? get_blkh_nr_items(blkh) : nr;
}
@@ -938,7 +938,7 @@ char *key_of_what(const struct reiserfs_key *key)
}
}
int type_unknown(struct reiserfs_key *key)
int type_unknown(const struct reiserfs_key *key)
{
int type = get_type(key);
@@ -988,7 +988,7 @@ void set_type_and_offset(int format, struct reiserfs_key *key, loff_t offset,
following entry in the calculation. See picture above.*/
// NOTE: this is not name length. This is length of whole entry
int entry_length(struct item_head *ih, struct reiserfs_de_head *deh,
int entry_length(const struct item_head *ih, const struct reiserfs_de_head *deh,
int pos_in_item)
{
if (pos_in_item)
@@ -996,13 +996,13 @@ int entry_length(struct item_head *ih, struct reiserfs_de_head *deh,
return (get_ih_item_len(ih) - get_deh_location(deh));
}
char *name_in_entry(struct reiserfs_de_head *deh, int pos_in_item)
char *name_in_entry(const struct reiserfs_de_head *deh, int pos_in_item)
{
return ((char *)(deh - pos_in_item) + get_deh_location(deh));
}
int name_in_entry_length(struct item_head *ih,
struct reiserfs_de_head *deh, int pos_in_item)
int name_in_entry_length(const struct item_head *ih,
const struct reiserfs_de_head *deh, int pos_in_item)
{
int len, i;
char *name;
+1 -1
View File
@@ -402,7 +402,7 @@ void reiserfs_print_item(FILE * fp, struct buffer_head *bh,
/* this prints internal nodes (4 keys/items in line) (dc_number,
dc_size)[k_dirid, k_objectid, k_offset, k_uniqueness](dc_number,
dc_size)...*/
static int print_internal(FILE * fp, struct buffer_head *bh, int first,
static int print_internal(FILE * fp, const struct buffer_head *bh, int first,
int last)
{
struct reiserfs_key *key;
+11 -11
View File
@@ -604,10 +604,10 @@ static int comp_dir_entries(const void *p1, const void *p2)
return 0;
}
struct reiserfs_key *uget_lkey(struct reiserfs_path *path)
struct reiserfs_key *uget_lkey(const struct reiserfs_path *path)
{
int pos, offset = path->path_length;
struct buffer_head *bh;
const struct buffer_head *bh;
if (offset < FIRST_PATH_ELEMENT_OFFSET)
die("uget_lkey: illegal offset in the path (%d)", offset);
@@ -642,7 +642,7 @@ struct reiserfs_key *uget_lkey(struct reiserfs_path *path)
return NULL;
}
struct reiserfs_key *uget_rkey(struct reiserfs_path *path)
struct reiserfs_key *uget_rkey(const struct reiserfs_path *path)
{
int pos, offset = path->path_length;
struct buffer_head *bh;
@@ -679,7 +679,7 @@ struct reiserfs_key *uget_rkey(struct reiserfs_path *path)
return NULL;
}
struct reiserfs_key *reiserfs_next_key(struct reiserfs_path *path)
struct reiserfs_key *reiserfs_next_key(const struct reiserfs_path *path)
{
if (get_item_pos(path) < B_NR_ITEMS(get_bh(path)) - 1)
return leaf_key(get_bh(path), get_item_pos(path) + 1);
@@ -803,7 +803,7 @@ void init_tb_struct(struct tree_balance *tb, reiserfs_filsys_t fs,
tb->insert_size[0] = size;
}
int reiserfs_remove_entry(reiserfs_filsys_t fs, struct reiserfs_key *key)
int reiserfs_remove_entry(reiserfs_filsys_t fs, const struct reiserfs_key *key)
{
struct reiserfs_path path;
struct tree_balance tb;
@@ -943,7 +943,7 @@ int reiserfs_locate_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
found. Stores key found in the entry in 'key'. Returns minimal not used
generation counter in 'min_gen_counter'. dies if found object is not a
directory. */
int reiserfs_find_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
int reiserfs_find_entry(reiserfs_filsys_t fs, const struct reiserfs_key *dir,
const char *name, unsigned int *min_gen_counter,
struct reiserfs_key *key)
{
@@ -1040,8 +1040,8 @@ int reiserfs_find_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
}
/* compose directory entry: dir entry head and name itself */
static char *make_entry(char *entry, const char *name, struct reiserfs_key *key,
__u32 offset)
static char *make_entry(char *entry, const char *name,
const struct reiserfs_key *key, __u32 offset)
{
struct reiserfs_de_head *deh;
__u16 state;
@@ -1067,9 +1067,9 @@ static char *make_entry(char *entry, const char *name, struct reiserfs_key *key,
/* add new name into a directory. If it exists in a directory - do
nothing */
int reiserfs_add_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
int reiserfs_add_entry(reiserfs_filsys_t fs, const struct reiserfs_key *dir,
const char *name, int name_len,
struct reiserfs_key *key, __u16 fsck_need)
const struct reiserfs_key *key, __u16 fsck_need)
{
struct item_head entry_ih = { {0,}, };
char *entry;
@@ -1151,7 +1151,7 @@ void copy_short_key(void *to, const void *from)
/* inserts new or old stat data of a directory (unreachable, nlinks == 0) */
int create_dir_sd(reiserfs_filsys_t fs,
struct reiserfs_path *path, struct reiserfs_key *key,
struct reiserfs_path *path, const struct reiserfs_key *key,
void (*modify_item) (struct item_head *, void *))
{
struct item_head ih;
+4 -4
View File
@@ -38,7 +38,7 @@
#include "includes.h"
/* Does the buffer contain a disk block which is in the tree. */
inline int B_IS_IN_TREE(struct buffer_head *p_s_bh)
inline int B_IS_IN_TREE(const struct buffer_head *p_s_bh)
{
return (get_blkh_level(B_BLK_HEAD(p_s_bh)) != FREE_LEVEL);
}
@@ -133,8 +133,8 @@ int comp_keys(const void *p1, const void *p2)
there are no possible items, and we have not found it. With each examination we
cut the number of possible items it could be by one more than half rounded down,
or we find it. */
int bin_search(void *p_v_key, /* Key to search for. */
void *p_v_base, /* First item in the array. */
int bin_search(const void *p_v_key, /* Key to search for. */
const void *p_v_base, /* First item in the array. */
int p_n_num, /* Number of items in the array. */
int p_n_width, /* Item size in the array.
searched. Lest the reader be
@@ -318,7 +318,7 @@ void pathrelse(struct reiserfs_path *p_s_search_path)
key. search_by_key returns a path that must be checked for the
correctness of the top of the path but need not be checked for the
correctness of the bottom of the path */
int search_by_key(reiserfs_filsys_t fs, struct reiserfs_key *p_s_key, /* Key to search */
int search_by_key(reiserfs_filsys_t fs, const struct reiserfs_key *p_s_key, /* Key to search */
struct reiserfs_path *p_s_search_path, /* This structure was
allocated and
initialized by the