reiserfscore: constify strings
There are many calls in which strings are passed as "char *" yet aren't modified. This patch marks them const so callers can depend on it. Signed-off-by: Jeff Mahoney <jeffm@suse.com>
This commit is contained in:
1 parent
6bdb171b9e
commit
9b52a79ba2
9 files changed
+86
-83
No files matched your search
@@ -414,7 +414,7 @@ void reiserfs_bitmap_fill(reiserfs_bitmap_t *bm)
|
||||
#define BITMAP_START_MAGIC 374031
|
||||
#define BITMAP_END_MAGIC 7786472
|
||||
|
||||
FILE *open_file(char *filename, char *option)
|
||||
FILE *open_file(const char *filename, char *const option)
|
||||
{
|
||||
FILE *fp = fopen(filename, option);
|
||||
if (!fp) {
|
||||
|
||||
@@ -471,7 +471,8 @@ int reiserfs_journal_params_check(reiserfs_filsys_t fs)
|
||||
|
||||
/* read journal header and make sure that it matches with the filesystem
|
||||
opened */
|
||||
int reiserfs_open_journal(reiserfs_filsys_t fs, char *j_filename, int flags)
|
||||
int reiserfs_open_journal(reiserfs_filsys_t fs, const char *j_filename,
|
||||
int flags)
|
||||
{
|
||||
struct reiserfs_super_block *sb;
|
||||
__u64 count;
|
||||
@@ -551,7 +552,7 @@ int reiserfs_open_journal(reiserfs_filsys_t fs, char *j_filename, int flags)
|
||||
|
||||
/* initialize super block's journal related fields and journal header fields.
|
||||
* If len is 0 - make journal of default size */
|
||||
int reiserfs_create_journal(reiserfs_filsys_t fs, char *j_device, /* journal device name */
|
||||
int reiserfs_create_journal(reiserfs_filsys_t fs, const char *j_device, /* journal device name */
|
||||
unsigned long offset, /* journal offset on the j_device */
|
||||
unsigned long len, /* including journal header */
|
||||
int transaction_max_size, int force)
|
||||
|
||||
+21
-21
@@ -5,9 +5,9 @@
|
||||
|
||||
#include "includes.h"
|
||||
|
||||
int leaf_count_ih(char *buf, int blocksize)
|
||||
int leaf_count_ih(const char *buf, int blocksize)
|
||||
{
|
||||
struct item_head *ih;
|
||||
const struct item_head *ih;
|
||||
int prev_location;
|
||||
int nr;
|
||||
|
||||
@@ -30,10 +30,10 @@ int leaf_count_ih(char *buf, int blocksize)
|
||||
return nr;
|
||||
}
|
||||
|
||||
int leaf_free_space_estimate(char *buf, int blocksize)
|
||||
int leaf_free_space_estimate(const char *buf, int blocksize)
|
||||
{
|
||||
struct block_head *blkh;
|
||||
struct item_head *ih;
|
||||
const struct block_head *blkh;
|
||||
const struct item_head *ih;
|
||||
int nr;
|
||||
|
||||
blkh = (struct block_head *)buf;
|
||||
@@ -44,7 +44,7 @@ int leaf_free_space_estimate(char *buf, int blocksize)
|
||||
IH_SIZE * nr;
|
||||
}
|
||||
|
||||
static int leaf_blkh_correct(char *buf, int blocksize)
|
||||
static int leaf_blkh_correct(const char *buf, int blocksize)
|
||||
{
|
||||
struct block_head *blkh;
|
||||
unsigned int nr;
|
||||
@@ -62,9 +62,9 @@ static int leaf_blkh_correct(char *buf, int blocksize)
|
||||
blocksize) == get_blkh_free_space(blkh);
|
||||
}
|
||||
|
||||
int is_a_leaf(char *buf, int blocksize)
|
||||
int is_a_leaf(const char *buf, int blocksize)
|
||||
{
|
||||
struct block_head *blkh;
|
||||
const struct block_head *blkh;
|
||||
int counted;
|
||||
|
||||
blkh = (struct block_head *)buf;
|
||||
@@ -84,7 +84,7 @@ int is_a_leaf(char *buf, int blocksize)
|
||||
|
||||
int leaf_item_number_estimate(struct buffer_head *bh)
|
||||
{
|
||||
struct block_head *blkh;
|
||||
const struct block_head *blkh;
|
||||
int nr;
|
||||
|
||||
nr = leaf_count_ih(bh->b_data, bh->b_size);
|
||||
@@ -174,9 +174,9 @@ static int does_node_have_ih_array(char *buf, int blocksize)
|
||||
#endif
|
||||
|
||||
/* returns 1 if buf looks like an internal node, 0 otherwise */
|
||||
static int is_correct_internal(char *buf, int blocksize)
|
||||
static int is_correct_internal(const char *buf, int blocksize)
|
||||
{
|
||||
struct block_head *blkh;
|
||||
const struct block_head *blkh;
|
||||
unsigned int nr;
|
||||
int used_space;
|
||||
|
||||
@@ -210,9 +210,9 @@ int is_tree_node(struct buffer_head *bh, int level)
|
||||
return is_correct_internal(bh->b_data, bh->b_size);
|
||||
}
|
||||
|
||||
static int is_desc_block(char *buf, unsigned long buf_size)
|
||||
static int is_desc_block(const char *buf, unsigned long buf_size)
|
||||
{
|
||||
struct reiserfs_journal_desc *desc =
|
||||
const struct reiserfs_journal_desc *desc =
|
||||
(struct reiserfs_journal_desc *)buf;
|
||||
if (!memcmp(buf + buf_size - 12, JOURNAL_DESC_MAGIC, 8)
|
||||
&& le32_to_cpu(desc->j2_len) > 0)
|
||||
@@ -299,7 +299,7 @@ int does_look_like_super_block(struct reiserfs_super_block *sb)
|
||||
|
||||
/* returns code of reiserfs metadata block (leaf, internal, super
|
||||
block, journal descriptor), unformatted */
|
||||
int who_is_this(char *buf, int blocksize)
|
||||
int who_is_this(const char *buf, int blocksize)
|
||||
{
|
||||
int res;
|
||||
|
||||
@@ -492,7 +492,7 @@ static int does_ih_look_correct(struct item_head *ih)
|
||||
/* check item length, ih_free_space for pure 3.5 format, unformatted node
|
||||
pointers */
|
||||
static int is_bad_indirect(reiserfs_filsys_t fs, struct item_head *ih,
|
||||
char *item, check_unfm_func_t check_unfm_func)
|
||||
const char *item, check_unfm_func_t check_unfm_func)
|
||||
{
|
||||
unsigned int i;
|
||||
__le32 *ind = (__le32 *) item;
|
||||
@@ -537,7 +537,7 @@ int known_hashes(void)
|
||||
|
||||
/* this also sets hash function */
|
||||
int is_properly_hashed(reiserfs_filsys_t fs,
|
||||
char *name, int namelen, __u32 offset)
|
||||
const char *name, int namelen, __u32 offset)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@@ -583,7 +583,7 @@ int is_properly_hashed(reiserfs_filsys_t fs,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int find_hash_in_use(char *name, int namelen, __u32 offset,
|
||||
int find_hash_in_use(const char *name, int namelen, __u32 offset,
|
||||
unsigned int code_to_try_first)
|
||||
{
|
||||
unsigned int i;
|
||||
@@ -638,7 +638,7 @@ hashf_t code2func(unsigned int code)
|
||||
return hashes[code].func;
|
||||
}
|
||||
|
||||
hashf_t name2func(char *hash)
|
||||
hashf_t name2func(const char *hash)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
@@ -666,7 +666,7 @@ int dir_entry_bad_location(struct reiserfs_de_head *deh, struct item_head *ih,
|
||||
/* the only corruption which is not considered fatal - is hash mismatching. If
|
||||
bad_dir is set - directory item having such names is considered bad */
|
||||
static int is_bad_directory(reiserfs_filsys_t fs, struct item_head *ih,
|
||||
char *item, int bad_dir)
|
||||
const char *item, int bad_dir)
|
||||
{
|
||||
int i;
|
||||
int namelen;
|
||||
@@ -702,7 +702,7 @@ static int is_bad_directory(reiserfs_filsys_t fs, struct item_head *ih,
|
||||
}
|
||||
|
||||
/* used by debugreisrefs -p only yet */
|
||||
int is_it_bad_item(reiserfs_filsys_t fs, struct item_head *ih, char *item,
|
||||
int is_it_bad_item(reiserfs_filsys_t fs, struct item_head *ih, const char *item,
|
||||
check_unfm_func_t check_unfm, int bad_dir)
|
||||
{
|
||||
int retval;
|
||||
@@ -1018,7 +1018,7 @@ int name_in_entry_length(struct item_head *ih,
|
||||
return i;
|
||||
}
|
||||
|
||||
int name_length(char *name, int key_format)
|
||||
int name_length(const char *name, int key_format)
|
||||
{
|
||||
if (key_format == KEY_FORMAT_2)
|
||||
return ROUND_UP(strlen(name));
|
||||
|
||||
@@ -545,7 +545,7 @@ void print_journal_params(FILE * fp, struct journal_params *jp)
|
||||
}
|
||||
|
||||
/* return 1 if this is not super block */
|
||||
int print_super_block(FILE * fp, reiserfs_filsys_t fs, char *file_name,
|
||||
int print_super_block(FILE * fp, reiserfs_filsys_t fs, const char *file_name,
|
||||
struct buffer_head *bh, int short_print)
|
||||
{
|
||||
struct reiserfs_super_block *sb =
|
||||
@@ -696,7 +696,7 @@ void print_block(FILE * fp, reiserfs_filsys_t fs, struct buffer_head *bh, ...) /
|
||||
{
|
||||
va_list args;
|
||||
int mode, first, last;
|
||||
char *file_name;
|
||||
const char *file_name;
|
||||
|
||||
va_start(args, bh);
|
||||
|
||||
@@ -719,7 +719,7 @@ void print_block(FILE * fp, reiserfs_filsys_t fs, struct buffer_head *bh, ...) /
|
||||
}
|
||||
|
||||
void print_tb(int mode, int item_pos, int pos_in_item, struct tree_balance *tb,
|
||||
char *mes)
|
||||
const char *mes)
|
||||
{
|
||||
unsigned int h = 0;
|
||||
struct buffer_head *tbSh, *tbFh;
|
||||
@@ -806,8 +806,9 @@ void print_tb(int mode, int item_pos, int pos_in_item, struct tree_balance *tb,
|
||||
("********************** END OF PRINT_TB *******************\n\n");
|
||||
}
|
||||
|
||||
static void print_bmap_block(FILE * fp, int i, unsigned long block, char *map,
|
||||
int blocks, int silent, int blocksize)
|
||||
static void print_bmap_block(FILE * fp, int i, unsigned long block,
|
||||
const char *map, int blocks, int silent,
|
||||
int blocksize)
|
||||
{
|
||||
int j, k;
|
||||
int bits = blocksize * 8;
|
||||
|
||||
@@ -185,7 +185,7 @@ found:
|
||||
|
||||
/* creates buffer for super block and fills it up with fields which are
|
||||
constant for given size and version of a filesystem */
|
||||
reiserfs_filsys_t reiserfs_create(char *filename,
|
||||
reiserfs_filsys_t reiserfs_create(const char *filename,
|
||||
int version,
|
||||
unsigned long block_count,
|
||||
int block_size,
|
||||
@@ -866,7 +866,7 @@ void reiserfs_insert_item(reiserfs_filsys_t fs, struct reiserfs_path *path,
|
||||
|
||||
/*===========================================================================*/
|
||||
|
||||
__u32 hash_value(hashf_t func, char *name, int namelen)
|
||||
__u32 hash_value(hashf_t func, const char *name, int namelen)
|
||||
{
|
||||
__u32 res;
|
||||
|
||||
@@ -881,7 +881,7 @@ __u32 hash_value(hashf_t func, char *name, int namelen)
|
||||
/* if name is found in a directory - return 1 and set path to the name,
|
||||
otherwise return 0 and pathrelse path */
|
||||
int reiserfs_locate_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
|
||||
char *name, struct reiserfs_path *path)
|
||||
const char *name, struct reiserfs_path *path)
|
||||
{
|
||||
struct reiserfs_key entry_key;
|
||||
struct item_head *ih;
|
||||
@@ -944,7 +944,7 @@ int reiserfs_locate_entry(reiserfs_filsys_t fs, struct reiserfs_key *dir,
|
||||
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,
|
||||
char *name, unsigned int *min_gen_counter,
|
||||
const char *name, unsigned int *min_gen_counter,
|
||||
struct reiserfs_key *key)
|
||||
{
|
||||
struct reiserfs_key entry_key;
|
||||
@@ -1040,7 +1040,7 @@ 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, char *name, struct reiserfs_key *key,
|
||||
static char *make_entry(char *entry, const char *name, struct reiserfs_key *key,
|
||||
__u32 offset)
|
||||
{
|
||||
struct reiserfs_de_head *deh;
|
||||
@@ -1068,8 +1068,8 @@ static char *make_entry(char *entry, 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,
|
||||
char *name, int name_len, struct reiserfs_key *key,
|
||||
__u16 fsck_need)
|
||||
const char *name, int name_len,
|
||||
struct reiserfs_key *key, __u16 fsck_need)
|
||||
{
|
||||
struct item_head entry_ih = { {0,}, };
|
||||
char *entry;
|
||||
@@ -1229,7 +1229,7 @@ void make_sure_root_dir_exists(reiserfs_filsys_t fs,
|
||||
|
||||
/* we only can use a file for filesystem or journal if it is either not
|
||||
mounted block device or regular file and we are forced to use it */
|
||||
int can_we_format_it(char *device_name, int force)
|
||||
int can_we_format_it(const char *device_name, int force)
|
||||
{
|
||||
mode_t mode;
|
||||
dev_t rdev;
|
||||
@@ -1262,7 +1262,7 @@ int can_we_format_it(char *device_name, int force)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int create_badblock_bitmap(reiserfs_filsys_t fs, char *badblocks_file)
|
||||
int create_badblock_bitmap(reiserfs_filsys_t fs, const char *badblocks_file)
|
||||
{
|
||||
FILE *fd;
|
||||
char buf[128];
|
||||
|
||||
Reference in new issue
Block a user