On 12/10/21 6:21 PM, Darrick J. Wong wrote:
On Fri, Dec 10, 2021 at 02:21:36PM -0600, Eric Sandeen wrote:
From: Eric Sandeen <sandeen@xxxxxxxxxx>
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@xxxxxxxxxx>
Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxxx>
---
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.
I mean, that's a legit goal, but
$ grep -rw "printf\|fprintf" libfrog/ | wc -l
55
but ok, I can reduce it to 54 ;)
-Eric