Skip to contentSkip to conversation

erofs-utils: Print configuration only at INFO debug level

PATCH Applied Peter Collingbourne via Linux-erofs 2 participants 4 messages Feb 9, 2022 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: Print configuration only at INFO debug level

The information printed by erofs_show_config is not useful for ordinary users of the program, and it certainly doesn't count as a warning, so let's only print it at the INFO debug level or greater.

---
 lib/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/config.c +1 -1
index 363dcc5..08deb6f 100644
@@ -34,7 +34,7 @@ void erofs_show_config(void)
 {
 	const struct erofs_configure *c = &cfg;
 
-	if (c->c_dbg_lvl < EROFS_WARN)
+	if (c->c_dbg_lvl < EROFS_INFO)
 		return;
 	erofs_dump("\tc_version:           [%8s]\n", c->c_version);
 	erofs_dump("\tc_dbg_lvl:           [%8d]\n", c->c_dbg_lvl);
Signature · 1 line
2.35.0.263.gb82422642f-goog
#1 lore raw

PATCH 1/1 erofs-utils: Print program name and version to stdout

The program name and version is not an error message, so it should go to stdout, not stderr.

---
 dump/main.c | 2 +-
 fsck/main.c | 2 +-
 fuse/main.c | 2 +-
 mkfs/main.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
dump/main.c +1 -1
index b7560ec..ad1b62e 100644
@@ -109,7 +109,7 @@ static void usage(void)
 
 static void erofsdump_print_version(void)
 {
-	fprintf(stderr, "dump.erofs %s\n", cfg.c_version);
+	printf("dump.erofs %s\n", cfg.c_version);
 }
 
 static int erofsdump_parse_options_cfg(int argc, char **argv)
fsck/main.c +1 -1
index aefa881..2ebc5e9 100644
@@ -43,7 +43,7 @@ static void usage(void)
 
 static void erofsfsck_print_version(void)
 {
-	fprintf(stderr, "fsck.erofs %s\n", cfg.c_version);
+	printf("fsck.erofs %s\n", cfg.c_version);
 }
 
 static int erofsfsck_parse_options_cfg(int argc, char **argv)
fuse/main.c +1 -1
index 255965e..b7760e4 100644
@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
 	struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
 
 	erofs_init_configure();
-	fprintf(stderr, "%s %s\n", basename(argv[0]), cfg.c_version);
+	printf("%s %s\n", basename(argv[0]), cfg.c_version);
 
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE)
 	if (signal(SIGSEGV, signal_handle_sigsegv) == SIG_ERR) {
mkfs/main.c +1 -1
index 58a6441..4325ab4 100644
@@ -548,7 +548,7 @@ int parse_source_date_epoch(void)
 void erofs_show_progs(int argc, char *argv[])
 {
 	if (cfg.c_dbg_lvl >= EROFS_WARN)
-		fprintf(stderr, "%s %s\n", basename(argv[0]), cfg.c_version);
+		printf("%s %s\n", basename(argv[0]), cfg.c_version);
 }
 
 int main(int argc, char **argv)
Signature · 1 line
2.35.0.263.gb82422642f-goog
Applied
#3 lore raw
In reply to Peter Collingbourne via Linux-erofs
Quoted 5 lines · Peter Collingbourne

The information printed by erofs_show_config is not useful for ordinary users of the program, and it certainly doesn't count as a warning, so let's only print it at the INFO debug level or greater.

Applied, thanks!

Thanks,
Gao Xiang

Quoted 19 lines
---
 lib/config.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/config.c +1 -1
index 363dcc5..08deb6f 100644
@@ -34,7 +34,7 @@ void erofs_show_config(void)
 {
 	const struct erofs_configure *c = &cfg;
 
-	if (c->c_dbg_lvl < EROFS_WARN)
+	if (c->c_dbg_lvl < EROFS_INFO)
 		return;
 	erofs_dump("\tc_version:           [%8s]\n", c->c_version);
 	erofs_dump("\tc_dbg_lvl:           [%8d]\n", c->c_dbg_lvl);
Signature · 1 line
2.35.0.263.gb82422642f-goog
Applied
#2 lore raw

Re: [PATCH] erofs-utils: Print program name and version to stdout

In reply to Peter Collingbourne via Linux-erofs
Quoted 4 lines · Peter Collingbourne

The program name and version is not an error message, so it should go to stdout, not stderr.

Applied, thanks!

Thanks,
Gao Xiang

Quoted 61 lines
---
 dump/main.c | 2 +-
 fsck/main.c | 2 +-
 fuse/main.c | 2 +-
 mkfs/main.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
dump/main.c +1 -1
index b7560ec..ad1b62e 100644
@@ -109,7 +109,7 @@ static void usage(void)
 
 static void erofsdump_print_version(void)
 {
-	fprintf(stderr, "dump.erofs %s\n", cfg.c_version);
+	printf("dump.erofs %s\n", cfg.c_version);
 }
 
 static int erofsdump_parse_options_cfg(int argc, char **argv)
fsck/main.c +1 -1
index aefa881..2ebc5e9 100644
@@ -43,7 +43,7 @@ static void usage(void)
 
 static void erofsfsck_print_version(void)
 {
-	fprintf(stderr, "fsck.erofs %s\n", cfg.c_version);
+	printf("fsck.erofs %s\n", cfg.c_version);
 }
 
 static int erofsfsck_parse_options_cfg(int argc, char **argv)
fuse/main.c +1 -1
index 255965e..b7760e4 100644
@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
 	struct fuse_args args = FUSE_ARGS_INIT(argc, argv);
 
 	erofs_init_configure();
-	fprintf(stderr, "%s %s\n", basename(argv[0]), cfg.c_version);
+	printf("%s %s\n", basename(argv[0]), cfg.c_version);
 
 #if defined(HAVE_EXECINFO_H) && defined(HAVE_BACKTRACE)
 	if (signal(SIGSEGV, signal_handle_sigsegv) == SIG_ERR) {
mkfs/main.c +1 -1
index 58a6441..4325ab4 100644
@@ -548,7 +548,7 @@ int parse_source_date_epoch(void)
 void erofs_show_progs(int argc, char *argv[])
 {
 	if (cfg.c_dbg_lvl >= EROFS_WARN)
-		fprintf(stderr, "%s %s\n", basename(argv[0]), cfg.c_version);
+		printf("%s %s\n", basename(argv[0]), cfg.c_version);
 }
 
 int main(int argc, char **argv)
Signature · 1 line
2.35.0.263.gb82422642f-goog