All of lore.kernel.org
 help / color / mirror / Atom feed
From: Carlos Maiolino <cmaiolino@redhat.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: sandeen@sandeen.net, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/2] xfs_io: clean up the funshare command a bit
Date: Thu, 8 Jul 2021 09:31:36 +0200	[thread overview]
Message-ID: <20210708073136.tpwyppo3a6vskkfp@omega.lan> (raw)
In-Reply-To: <162528108811.36401.13142861358282476701.stgit@locust>

On Fri, Jul 02, 2021 at 07:58:08PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Add proper argument parsing to the funshare command so that when you
> pass it nonexistent --help it will print the help instead of complaining
> that it can't convert that to a number.

Looks ok to me despite the space/tab thing already mentioned by hch.

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> ---
>  io/prealloc.c |   16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> 
> diff --git a/io/prealloc.c b/io/prealloc.c
> index 2ae8afe9..94cf326f 100644
> --- a/io/prealloc.c
> +++ b/io/prealloc.c
> @@ -346,16 +346,24 @@ funshare_f(
>  	char		**argv)
>  {
>  	xfs_flock64_t	segment;
> +	int		c;
>  	int		mode = FALLOC_FL_UNSHARE_RANGE;
> -	int		index = 1;
>  
> -	if (!offset_length(argv[index], argv[index + 1], &segment)) {
> +	while ((c = getopt(argc, argv, "")) != EOF) {
> +		switch (c) {
> +		default:
> +			command_usage(&funshare_cmd);
> +		}
> +	}
> +        if (optind != argc - 2)
> +                return command_usage(&funshare_cmd);
> +
> +	if (!offset_length(argv[optind], argv[optind + 1], &segment)) {
>  		exitcode = 1;
>  		return 0;
>  	}
>  
> -	if (fallocate(file->fd, mode,
> -			segment.l_start, segment.l_len)) {
> +	if (fallocate(file->fd, mode, segment.l_start, segment.l_len)) {
>  		perror("fallocate");
>  		exitcode = 1;
>  		return 0;
> 

-- 
Carlos


  parent reply	other threads:[~2021-07-08  7:31 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-03  2:57 [PATCHSET 0/2] xfs_io: small fixes to funshare command Darrick J. Wong
2021-07-03  2:58 ` [PATCH 1/2] xfs_io: fix broken funshare_cmd usage Darrick J. Wong
2021-07-05 15:16   ` Christoph Hellwig
2021-07-06 18:24     ` Darrick J. Wong
2021-07-08  7:23   ` Carlos Maiolino
2021-07-03  2:58 ` [PATCH 2/2] xfs_io: clean up the funshare command a bit Darrick J. Wong
2021-07-05 15:20   ` Christoph Hellwig
2021-07-06 18:28     ` Darrick J. Wong
2021-07-08  7:31   ` Carlos Maiolino [this message]
  -- strict thread matches above, loose matches on Subject: below --
2021-07-28 21:15 [PATCHSET 0/2] xfs_io: small fixes to funshare command Darrick J. Wong
2021-07-28 21:16 ` [PATCH 2/2] xfs_io: clean up the funshare command a bit Darrick J. Wong

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=20210708073136.tpwyppo3a6vskkfp@omega.lan \
    --to=cmaiolino@redhat.com \
    --cc=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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.