btrfs-progs: constify string arguments where appropriate

Signed-off-by: David Sterba <dsterba@suse.com>
master
David Sterba 2016-09-29 15:12:35 +02:00
parent 9fcdf8f894
commit 85d608f7ec
8 changed files with 14 additions and 13 deletions

View File

@ -808,9 +808,10 @@ static char *__ino_resolve(int fd, u64 dirid)
* simple string builder, returning a new string with both
* dirid and name
*/
static char *build_name(char *dirid, char *name)
static char *build_name(const char *dirid, const char *name)
{
char *full;
if (!dirid)
return strdup(name);

View File

@ -248,7 +248,7 @@ static int match_search_item_kernel(__u8 *fsid, char *mnt, char *label,
return 0;
}
static int uuid_search(struct btrfs_fs_devices *fs_devices, char *search)
static int uuid_search(struct btrfs_fs_devices *fs_devices, const char *search)
{
char uuidbuf[BTRFS_UUID_UNPARSED_SIZE];
struct list_head *cur;
@ -509,7 +509,7 @@ out:
return !found;
}
static int dev_to_fsid(char *dev, __u8 *fsid)
static int dev_to_fsid(const char *dev, __u8 *fsid)
{
struct btrfs_super_block *disk_super;
char buf[BTRFS_SUPER_INFO_SIZE];

View File

@ -1225,7 +1225,7 @@ u64 btrfs_get_path_rootid(int fd)
return args.treeid;
}
int btrfs_qgroup_parse_sort_string(char *opt_arg,
int btrfs_qgroup_parse_sort_string(const char *opt_arg,
struct btrfs_qgroup_comparer_set **comps)
{
int order;

View File

@ -77,7 +77,7 @@ enum btrfs_qgroup_filter_enum {
BTRFS_QGROUP_FILTER_MAX,
};
int btrfs_qgroup_parse_sort_string(char *opt_arg,
int btrfs_qgroup_parse_sort_string(const char *opt_arg,
struct btrfs_qgroup_comparer_set **comps);
u64 btrfs_get_path_rootid(int fd);
int btrfs_show_qgroups(int fd, struct btrfs_qgroup_filter_set *,

View File

@ -49,7 +49,7 @@ struct string_table *table_create(int columns, int rows)
* be replaced by a '=====' dimensioned on the basis of the column width
*/
char *table_vprintf(struct string_table *tab, int column, int row,
char *fmt, va_list ap)
const char *fmt, va_list ap)
{
int idx = tab->ncols * row + column;
char *msg = calloc(100, 1);
@ -71,7 +71,7 @@ char *table_vprintf(struct string_table *tab, int column, int row,
*/
__attribute__ ((format (printf, 4, 5)))
char *table_printf(struct string_table *tab, int column, int row,
char *fmt, ...)
const char *fmt, ...)
{
va_list ap;
char *ret;

View File

@ -25,9 +25,9 @@ struct string_table {
struct string_table *table_create(int columns, int rows);
char *table_printf(struct string_table *tab, int column, int row,
char *fmt, ...);
const char *fmt, ...);
char *table_vprintf(struct string_table *tab, int column, int row,
char *fmt, va_list ap);
const char *fmt, va_list ap);
void table_dump(struct string_table *tab);
void table_free(struct string_table *);

View File

@ -1606,7 +1606,7 @@ static int zero_dev_clamped(int fd, off_t start, ssize_t len, u64 dev_size)
}
int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
struct btrfs_root *root, int fd, char *path,
struct btrfs_root *root, int fd, const char *path,
u64 device_total_bytes, u32 io_width, u32 io_align,
u32 sectorsize)
{
@ -3031,7 +3031,7 @@ again:
*
* Returns 0 on success, or a negative errno.
*/
int get_fs_info(char *path, struct btrfs_ioctl_fs_info_args *fi_args,
int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args,
struct btrfs_ioctl_dev_info_args **di_ret)
{
int fd = -1;

View File

@ -158,7 +158,7 @@ int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
int btrfs_prepare_device(int fd, const char *file, u64 *block_count_ret,
u64 max_block_count, unsigned opflags);
int btrfs_add_to_fsid(struct btrfs_trans_handle *trans,
struct btrfs_root *root, int fd, char *path,
struct btrfs_root *root, int fd, const char *path,
u64 block_count, u32 io_width, u32 io_align,
u32 sectorsize);
int btrfs_scan_for_fsid(int run_ioctls);
@ -183,7 +183,7 @@ int arg_copy_path(char *dest, const char *src, int destlen);
int open_file_or_dir(const char *fname, DIR **dirstream);
int open_file_or_dir3(const char *fname, DIR **dirstream, int open_flags);
void close_file_or_dir(int fd, DIR *dirstream);
int get_fs_info(char *path, struct btrfs_ioctl_fs_info_args *fi_args,
int get_fs_info(const char *path, struct btrfs_ioctl_fs_info_args *fi_args,
struct btrfs_ioctl_dev_info_args **di_ret);
int get_label(const char *btrfs_dev, char *label);
int set_label(const char *btrfs_dev, const char *label);