From: Eric Sandeen <sandeen@sandeen.net>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/4] fiemap: Move global variables out of function scope
Date: Wed, 23 Aug 2017 10:49:04 -0500 [thread overview]
Message-ID: <33bf538b-a67f-016b-bb23-4e0090fa0f9a@sandeen.net> (raw)
In-Reply-To: <1503501082-16983-1-git-send-email-nborisov@suse.com>
On 8/23/17 10:11 AM, Nikolay Borisov wrote:
> Move the blocksize and max_extent variables to the top of the file since they
> are globals. Also blocksize never changes to mark it const. Also stop passing
> max_extents around and refer to it directly.
I think this is fine, though it could probably go further. If blocksize is
always 512, we could just use the BTOBBT() macro, which converts bytes
to "basic blocks" (512 units), and do away with the variable
entirely...
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
> io/fiemap.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/io/fiemap.c b/io/fiemap.c
> index 75e882057362..d1584aba7818 100644
> --- a/io/fiemap.c
> +++ b/io/fiemap.c
> @@ -24,6 +24,8 @@
> #include "io.h"
>
> static cmdinfo_t fiemap_cmd;
> +static const __u64 blocksize = 512;
> +static int max_extents = 0;
>
> static void
> fiemap_help(void)
> @@ -57,7 +59,6 @@ print_verbose(
> int boff_w,
> int tot_w,
> int flg_w,
> - int max_extents,
> int *cur_extent,
> __u64 *last_logical)
> {
> @@ -113,7 +114,6 @@ print_plain(
> struct fiemap_extent *extent,
> int lflag,
> int blocksize,
> - int max_extents,
> int *cur_extent,
> __u64 *last_logical)
> {
> @@ -165,7 +165,7 @@ calc_print_format(
> int *tot_w,
> int *flg_w)
> {
> - int i;
> + int i;
> char lbuf[32];
> char bbuf[32];
> __u64 logical;
> @@ -199,7 +199,6 @@ fiemap_f(
> char **argv)
> {
> struct fiemap *fiemap;
> - int max_extents = 0;
> int num_extents = 32;
> int last = 0;
> int lflag = 0;
> @@ -214,7 +213,6 @@ fiemap_f(
> int boff_w = 16;
> int tot_w = 5; /* 5 since its just one number */
> int flg_w = 5;
> - __u64 blocksize = 512;
> __u64 last_logical = 0;
> struct stat st;
>
> @@ -288,12 +286,10 @@ fiemap_f(
>
> print_verbose(extent, blocksize, foff_w,
> boff_w, tot_w, flg_w,
> - max_extents, &cur_extent,
> - &last_logical);
> + &cur_extent, &last_logical);
> } else
> print_plain(extent, lflag, blocksize,
> - max_extents, &cur_extent,
> - &last_logical);
> + &cur_extent, &last_logical);
>
> if (extent->fe_flags & FIEMAP_EXTENT_LAST) {
> last = 1;
>
next prev parent reply other threads:[~2017-08-23 15:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-11 11:55 [PATCH] fiemap: Refactor fiemap + implement range parameters Nikolay Borisov
2017-08-22 6:41 ` Nikolay Borisov
2017-08-22 19:11 ` Eric Sandeen
2017-08-23 8:07 ` Nikolay Borisov
2017-08-23 15:11 ` [PATCH 1/4] fiemap: Move global variables out of function scope Nikolay Borisov
2017-08-23 15:11 ` [PATCH 2/4] fiemap: Introduce get_extent_count Nikolay Borisov
2017-08-23 17:05 ` Darrick J. Wong
2017-08-23 15:11 ` [PATCH 3/4] fiemap: Simplify internals of fiemap_f Nikolay Borisov
2017-08-23 15:51 ` Eric Sandeen
2017-08-23 17:17 ` Eric Sandeen
2017-08-23 15:11 ` [PATCH 4/4] fiemap: Add support for ranged query Nikolay Borisov
2017-08-23 19:12 ` Eric Sandeen
2017-08-23 15:49 ` Eric Sandeen [this message]
2017-08-23 22:36 ` [PATCH 1/4] fiemap: Move global variables out of function scope Eric Sandeen
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=33bf538b-a67f-016b-bb23-4e0090fa0f9a@sandeen.net \
--to=sandeen@sandeen.net \
--cc=linux-xfs@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.