summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-09-29 15:12:35 +0200
committerDavid Sterba <dsterba@suse.com>2016-10-03 15:07:23 +0200
commit85d608f7ecec2317456059199644e9f940a38e5c (patch)
tree764baf5d281194a3238f92849bb4481f68621aee
parent9fcdf8f8945bfddb7e1155bc9da68aed33e4737c (diff)
btrfs-progs: constify string arguments where appropriate
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--btrfs-list.c3
-rw-r--r--cmds-filesystem.c4
-rw-r--r--qgroup.c2
-rw-r--r--qgroup.h2
-rw-r--r--string-table.c4
-rw-r--r--string-table.h4
-rw-r--r--utils.c4
-rw-r--r--utils.h4
8 files changed, 14 insertions, 13 deletions
diff --git a/btrfs-list.c b/btrfs-list.c
index 563845dc..b5d4458b 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -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);
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 26b70e13..0634c2bd 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -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];
diff --git a/qgroup.c b/qgroup.c
index 2d5d5559..5de35e2b 100644
--- a/qgroup.c
+++ b/qgroup.c
@@ -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;
diff --git a/qgroup.h b/qgroup.h
index 7b42d833..5b19ae7c 100644
--- a/qgroup.h
+++ b/qgroup.h
@@ -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 *,
diff --git a/string-table.c b/string-table.c
index 5eda1ac5..95833768 100644
--- a/string-table.c
+++ b/string-table.c
@@ -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;
diff --git a/string-table.h b/string-table.h
index c1695d8d..516ea97a 100644
--- a/string-table.h
+++ b/string-table.h
@@ -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 *);
diff --git a/utils.c b/utils.c
index beac58a8..72e6ae90 100644
--- a/utils.c
+++ b/utils.c
@@ -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;
diff --git a/utils.h b/utils.h
index 22e35152..117fed8e 100644
--- a/utils.h
+++ b/utils.h
@@ -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);