public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 3/4] xfs_quota: don't exit on fs_table_insert_project_path failure
Date: Fri, 10 Dec 2021 16:21:56 -0800	[thread overview]
Message-ID: <20211211002156.GC1218082@magnolia> (raw)
In-Reply-To: <1639167697-15392-4-git-send-email-sandeen@sandeen.net>

On Fri, Dec 10, 2021 at 02:21:36PM -0600, Eric Sandeen wrote:
> From: Eric Sandeen <sandeen@redhat.com>
> 
> If "project -p" fails in fs_table_insert_project_path, it
> calls exit() today which is quite unfriendly. Return an error
> and return to the command prompt as expected.
> 
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
> ---
>  libfrog/paths.c | 7 +++----
>  libfrog/paths.h | 2 +-
>  quota/project.c | 4 +++-
>  3 files changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/libfrog/paths.c b/libfrog/paths.c
> index d679376..6c0fee2 100644
> --- a/libfrog/paths.c
> +++ b/libfrog/paths.c
> @@ -546,7 +546,7 @@ out_error:
>  		progname, strerror(error));
>  }
>  
> -void
> +int
>  fs_table_insert_project_path(
>  	char		*dir,
>  	prid_t		prid)
> @@ -561,9 +561,8 @@ fs_table_insert_project_path(
>  	else
>  		error = ENOENT;
>  
> -	if (error) {
> +	if (error)
>  		fprintf(stderr, _("%s: cannot setup path for project dir %s: %s\n"),
>  				progname, dir, strerror(error));

Why not move this to the (sole) caller?  Libraries (even pseudolibraries
like libfrog) usually aren't supposed to go around fprintfing things.

--D

> -		exit(1);
> -	}
> +	return error;
>  }
> diff --git a/libfrog/paths.h b/libfrog/paths.h
> index c08e373..f20a2c3 100644
> --- a/libfrog/paths.h
> +++ b/libfrog/paths.h
> @@ -40,7 +40,7 @@ extern char *mtab_file;
>  extern void fs_table_initialise(int, char *[], int, char *[]);
>  extern void fs_table_destroy(void);
>  
> -extern void fs_table_insert_project_path(char *__dir, uint __projid);
> +extern int fs_table_insert_project_path(char *__dir, uint __projid);
>  
>  
>  extern fs_path_t *fs_table_lookup(const char *__dir, uint __flags);
> diff --git a/quota/project.c b/quota/project.c
> index 03ae10d..bed0dc5 100644
> --- a/quota/project.c
> +++ b/quota/project.c
> @@ -281,7 +281,9 @@ project_f(
>  			break;
>  		case 'p':
>  			ispath = 1;
> -			fs_table_insert_project_path(optarg, -1);
> +			/* fs_table_insert_project_path prints the failure */
> +			if (fs_table_insert_project_path(optarg, -1))
> +				return 0;
>  			break;
>  		case 's':
>  			type = SETUP_PROJECT;
> -- 
> 1.8.3.1
> 

  reply	other threads:[~2021-12-11  0:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 20:21 [PATCH 0/4] xfsprogs: misc small fixes Eric Sandeen
2021-12-10 20:21 ` [PATCH 1/4] xfs_quota: document unit multipliers used in limit command Eric Sandeen
2021-12-11  0:15   ` Darrick J. Wong
2021-12-11  5:47     ` Eric Sandeen
2021-12-11 16:55       ` Darrick J. Wong
2021-12-10 20:21 ` [PATCH 2/4] mkfs.xfs(8): remove incorrect default inode allocator description Eric Sandeen
2021-12-11  0:19   ` Darrick J. Wong
2021-12-10 20:21 ` [PATCH 3/4] xfs_quota: don't exit on fs_table_insert_project_path failure Eric Sandeen
2021-12-11  0:21   ` Darrick J. Wong [this message]
2021-12-11  5:52     ` Eric Sandeen
2021-12-11 16:56       ` Darrick J. Wong
2021-12-10 20:21 ` [PATCH 4/4] xfs_repair: don't guess about failure reason in phase6 Eric Sandeen
2021-12-11  0:23   ` 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=20211211002156.GC1218082@magnolia \
    --to=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox