From: Jeff Mahoney <jeffm@suse.com>
To: Nikolay Borisov <nborisov@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/8] btrfs-progs: constify pathnames passed as arguments
Date: Wed, 7 Mar 2018 15:45:52 -0500 [thread overview]
Message-ID: <38d2b435-e52d-672f-c2ae-96ffb154baa4@suse.com> (raw)
In-Reply-To: <2d41799e-227d-95bb-2f17-a67d4ad2e35e@suse.com>
[-- Attachment #1.1: Type: text/plain, Size: 5020 bytes --]
On 3/7/18 3:17 AM, Nikolay Borisov wrote:
>
>
> On 2.03.2018 20:46, jeffm@suse.com wrote:
>> From: Jeff Mahoney <jeffm@suse.com>
>>
>> It's unlikely we're going to modify a pathname argument, so codify that
>> and use const.
>>
>> Signed-off-by: Jeff Mahoney <jeffm@suse.com>
>> ---
>> chunk-recover.c | 4 ++--
>> cmds-device.c | 2 +-
>> cmds-fi-usage.c | 6 +++---
>> cmds-rescue.c | 4 ++--
>> send-utils.c | 4 ++--
>> 5 files changed, 10 insertions(+), 10 deletions(-)
>>
>> diff --git a/chunk-recover.c b/chunk-recover.c
>> index 705bcf52..1d30db51 100644
>> --- a/chunk-recover.c
>> +++ b/chunk-recover.c
>> @@ -1492,7 +1492,7 @@ out:
>> return ERR_PTR(ret);
>> }
>>
>> -static int recover_prepare(struct recover_control *rc, char *path)
>> +static int recover_prepare(struct recover_control *rc, const char *path)
>> {
>> int ret;
>> int fd;
>> @@ -2296,7 +2296,7 @@ static void validate_rebuild_chunks(struct recover_control *rc)
>> /*
>> * Return 0 when successful, < 0 on error and > 0 if aborted by user
>> */
>> -int btrfs_recover_chunk_tree(char *path, int verbose, int yes)
>> +int btrfs_recover_chunk_tree(const char *path, int verbose, int yes)
>> {
>> int ret = 0;
>> struct btrfs_root *root = NULL;
>> diff --git a/cmds-device.c b/cmds-device.c
>> index 86459d1b..a49c9d9d 100644
>> --- a/cmds-device.c
>> +++ b/cmds-device.c
>> @@ -526,7 +526,7 @@ static const char * const cmd_device_usage_usage[] = {
>> NULL
>> };
>>
>> -static int _cmd_device_usage(int fd, char *path, unsigned unit_mode)
>> +static int _cmd_device_usage(int fd, const char *path, unsigned unit_mode)
>
> Actually the path parameter is not used in this function at all, I'd say
> just remove it.
Yep, it's unused, but that's a different project. Add
-Wunused-parameter and see what shakes out. :)
>> {
>> int i;
>> int ret = 0;> diff --git a/cmds-fi-usage.c b/cmds-fi-usage.c
>> index de7ad668..9a1c76ab 100644
>> --- a/cmds-fi-usage.c
>> +++ b/cmds-fi-usage.c
>> @@ -227,7 +227,7 @@ static int cmp_btrfs_ioctl_space_info(const void *a, const void *b)
>> /*
>> * This function load all the information about the space usage
>> */
>> -static struct btrfs_ioctl_space_args *load_space_info(int fd, char *path)
>> +static struct btrfs_ioctl_space_args *load_space_info(int fd, const char *path)
>> {
>> struct btrfs_ioctl_space_args *sargs = NULL, *sargs_orig = NULL;
>> int ret, count;
>> @@ -305,7 +305,7 @@ static void get_raid56_used(struct chunk_info *chunks, int chunkcount,
>> #define MIN_UNALOCATED_THRESH SZ_16M
>> static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
>> int chunkcount, struct device_info *devinfo, int devcount,
>> - char *path, unsigned unit_mode)
>> + const char *path, unsigned unit_mode)
>> {
>> struct btrfs_ioctl_space_args *sargs = NULL;
>> int i;
>> @@ -931,7 +931,7 @@ static void _cmd_filesystem_usage_linear(unsigned unit_mode,
>> static int print_filesystem_usage_by_chunk(int fd,
>> struct chunk_info *chunkinfo, int chunkcount,
>> struct device_info *devinfo, int devcount,
>> - char *path, unsigned unit_mode, int tabular)
>> + const char *path, unsigned unit_mode, int tabular)
>> {
>> struct btrfs_ioctl_space_args *sargs;
>> int ret = 0;
>> diff --git a/cmds-rescue.c b/cmds-rescue.c
>> index c40088ad..c61145bc 100644
>> --- a/cmds-rescue.c
>> +++ b/cmds-rescue.c
>> @@ -32,8 +32,8 @@ static const char * const rescue_cmd_group_usage[] = {
>> NULL
>> };
>>
>> -int btrfs_recover_chunk_tree(char *path, int verbose, int yes);
>> -int btrfs_recover_superblocks(char *path, int verbose, int yes);
>> +int btrfs_recover_chunk_tree(const char *path, int verbose, int yes);
>
> That path argument is being passed to recover_prepare which can alo use
> a const to its path parameter
Yep, and it was in the first chunk.
>> +int btrfs_recover_superblocks(const char *path, int verbose, int yes);
>>
>> static const char * const cmd_rescue_chunk_recover_usage[] = {
>> "btrfs rescue chunk-recover [options] <device>",
>> diff --git a/send-utils.c b/send-utils.c
>> index b5289e76..8ce94de1 100644
>> --- a/send-utils.c
>> +++ b/send-utils.c
>> @@ -28,8 +28,8 @@
>> #include "ioctl.h"
>> #include "btrfs-list.h"
>>
>> -static int btrfs_subvolid_resolve_sub(int fd, char *path, size_t *path_len,
>> - u64 subvol_id);
>> +static int btrfs_subvolid_resolve_sub(int fd, char *path,
>> + size_t *path_len, u64 subvol_id);
>
> This seems like an unrelated change. As a matter of fact
> btrfs_subvolid_resolve_sub is used only by btrfs_subvolid_resolve. So if
> you move the latter after the former then you can drop the declaration
> at the beginning of the file altogether.
Ah, yep. That's the fallout from adding const, reformatting, and
removing it. I'll just skip it entirely.
-Jeff
--
Jeff Mahoney
SUSE Labs
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 854 bytes --]
next prev parent reply other threads:[~2018-03-07 20:46 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-02 18:46 [PATCH 0/8] btrfs-progs: qgroups usability [corrected] jeffm
2018-03-02 18:46 ` [PATCH 1/8] btrfs-progs: quota: Add -W option to rescan to wait without starting rescan jeffm
2018-03-02 18:59 ` Nikolay Borisov
2018-03-03 2:46 ` Jeff Mahoney
2018-03-02 18:46 ` [PATCH 2/8] btrfs-progs: qgroups: fix misleading index check jeffm
2018-03-07 8:05 ` Nikolay Borisov
2018-03-02 18:46 ` [PATCH 3/8] btrfs-progs: constify pathnames passed as arguments jeffm
2018-03-07 8:17 ` Nikolay Borisov
2018-03-07 20:45 ` Jeff Mahoney [this message]
2018-03-02 18:47 ` [PATCH 4/8] btrfs-progs: qgroups: add pathname to show output jeffm
2018-03-07 5:45 ` Qu Wenruo
2018-03-07 16:37 ` Jeff Mahoney
2018-03-02 18:47 ` [PATCH 5/8] btrfs-progs: qgroups: introduce and use info and limit structures jeffm
2018-03-07 9:19 ` Nikolay Borisov
2018-03-02 18:47 ` [PATCH 6/8] btrfs-progs: qgroups: introduce btrfs_qgroup_query jeffm
2018-03-07 5:58 ` Qu Wenruo
2018-03-07 19:42 ` Jeff Mahoney
2018-03-07 6:08 ` Qu Wenruo
2018-03-07 8:02 ` Misono, Tomohiro
2018-03-07 20:24 ` Jeff Mahoney
2018-03-02 18:47 ` [PATCH 7/8] btrfs-progs: subvolume: add quota info to btrfs sub show jeffm
2018-03-07 6:09 ` Qu Wenruo
2018-03-07 20:21 ` Jeff Mahoney
2018-03-02 18:47 ` [PATCH 8/8] btrfs-progs: qgroups: export qgroups usage information as JSON jeffm
2018-03-07 6:34 ` Qu Wenruo
2018-03-07 15:28 ` Jeff Mahoney
2018-03-06 12:10 ` [PATCH 0/8] btrfs-progs: qgroups usability [corrected] Qu Wenruo
2018-03-06 14:59 ` Jeffrey Mahoney
2018-03-07 6:11 ` Qu Wenruo
-- strict thread matches above, loose matches on Subject: below --
2018-03-02 18:39 [PATCH 0/8] btrfs-progs: qgroups usability jeffm
2018-03-02 18:39 ` [PATCH 3/8] btrfs-progs: constify pathnames passed as arguments jeffm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=38d2b435-e52d-672f-c2ae-96ffb154baa4@suse.com \
--to=jeffm@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).