btrfs-progs: constify string arguments where appropriate
authorDavid Sterba <dsterba@suse.com>
Thu, 29 Sep 2016 13:12:35 +0000 (15:12 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 3 Oct 2016 13:07:23 +0000 (15:07 +0200)
Signed-off-by: David Sterba <dsterba@suse.com>
btrfs-list.c
cmds-filesystem.c
qgroup.c
qgroup.h
string-table.c
string-table.h
utils.c
utils.h

index 563845d..b5d4458 100644 (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);
 
index 26b70e1..0634c2b 100644 (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];
index 2d5d555..5de35e2 100644 (file)
--- 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;
index 7b42d83..5b19ae7 100644 (file)
--- 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 *,
index 5eda1ac..9583376 100644 (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;
index c1695d8..516ea97 100644 (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 *);
 
diff --git a/utils.c b/utils.c
index beac58a..72e6ae9 100644 (file)
--- 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 22e3515..117fed8 100644 (file)
--- 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);