linux-bcachefs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bcachefs: indent error messages of invalid compression
@ 2025-04-07 17:41 Integral
  2025-04-07 18:43 ` Kent Overstreet
  0 siblings, 1 reply; 4+ messages in thread
From: Integral @ 2025-04-07 17:41 UTC (permalink / raw)
  To: Kent Overstreet; +Cc: linux-bcachefs, linux-kernel, Integral

This patch uses printbuf_indent_add_nextline() to set a consistent
indentation level for error messages of invalid compression.

In my previous patch [1], the newline is added by using '\n' in
the argument of prt_str(). This patch replaces '\n' with prt_newline()
to make indentation level work correctly.

[1] Link: https://lore.kernel.org/20250406152659.205997-2-integral@archlinuxcn.org

Signed-off-by: Integral <integral@archlinuxcn.org>
---
 fs/bcachefs/compress.c | 12 ++++++++----
 fs/bcachefs/opts.c     |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c
index d68c3c7896a3..a107aa88a875 100644
--- a/fs/bcachefs/compress.c
+++ b/fs/bcachefs/compress.c
@@ -713,8 +713,10 @@ int bch2_opt_compression_parse(struct bch_fs *c, const char *_val, u64 *res,
 	level_str = p;
 
 	ret = match_string(bch2_compression_opts, -1, type_str);
-	if (ret < 0 && err)
-		prt_str(err, "invalid compression type\n");
+	if (ret < 0 && err) {
+		prt_str(err, "invalid compression type");
+		prt_newline(err);
+	}
 	if (ret < 0)
 		goto err;
 
@@ -728,8 +730,10 @@ int bch2_opt_compression_parse(struct bch_fs *c, const char *_val, u64 *res,
 			ret = -EINVAL;
 		if (!ret && level > 15)
 			ret = -EINVAL;
-		if (ret < 0 && err)
-			prt_str(err, "invalid compression level\n");
+		if (ret < 0 && err) {
+			prt_str(err, "invalid compression level");
+			prt_newline(err);
+		}
 		if (ret < 0)
 			goto err;
 
diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
index cd7b0cd293c7..f35fde896253 100644
--- a/fs/bcachefs/opts.c
+++ b/fs/bcachefs/opts.c
@@ -365,6 +365,7 @@ int bch2_opt_parse(struct bch_fs *c,
 		   struct printbuf *err)
 {
 	ssize_t ret;
+	printbuf_indent_add_nextline(err, 2);
 
 	switch (opt->type) {
 	case BCH_OPT_BOOL:

base-commit: 4d37602fceff942694069cf33cc55863277bd1c2
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] bcachefs: indent error messages of invalid compression
  2025-04-07 17:41 [PATCH] bcachefs: indent error messages of invalid compression Integral
@ 2025-04-07 18:43 ` Kent Overstreet
  2025-04-08 10:31   ` [PATCH v2] " Integral
  0 siblings, 1 reply; 4+ messages in thread
From: Kent Overstreet @ 2025-04-07 18:43 UTC (permalink / raw)
  To: Integral; +Cc: linux-bcachefs, linux-kernel

On Tue, Apr 08, 2025 at 01:41:31AM +0800, Integral wrote:
> This patch uses printbuf_indent_add_nextline() to set a consistent
> indentation level for error messages of invalid compression.
> 
> In my previous patch [1], the newline is added by using '\n' in
> the argument of prt_str(). This patch replaces '\n' with prt_newline()
> to make indentation level work correctly.
> 
> [1] Link: https://lore.kernel.org/20250406152659.205997-2-integral@archlinuxcn.org
> 
> Signed-off-by: Integral <integral@archlinuxcn.org>
> ---
>  fs/bcachefs/compress.c | 12 ++++++++----
>  fs/bcachefs/opts.c     |  1 +
>  2 files changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c
> index d68c3c7896a3..a107aa88a875 100644
> --- a/fs/bcachefs/compress.c
> +++ b/fs/bcachefs/compress.c
> @@ -713,8 +713,10 @@ int bch2_opt_compression_parse(struct bch_fs *c, const char *_val, u64 *res,
>  	level_str = p;
>  
>  	ret = match_string(bch2_compression_opts, -1, type_str);
> -	if (ret < 0 && err)
> -		prt_str(err, "invalid compression type\n");
> +	if (ret < 0 && err) {
> +		prt_str(err, "invalid compression type");
> +		prt_newline(err);
> +	}
>  	if (ret < 0)
>  		goto err;
>  
> @@ -728,8 +730,10 @@ int bch2_opt_compression_parse(struct bch_fs *c, const char *_val, u64 *res,
>  			ret = -EINVAL;
>  		if (!ret && level > 15)
>  			ret = -EINVAL;
> -		if (ret < 0 && err)
> -			prt_str(err, "invalid compression level\n");
> +		if (ret < 0 && err) {
> +			prt_str(err, "invalid compression level");

You can just change this to prt_printf() or prt_str_indented(), that'll
interpret the \n correctly

> +			prt_newline(err);
> +		}
>  		if (ret < 0)
>  			goto err;
>  
> diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
> index cd7b0cd293c7..f35fde896253 100644
> --- a/fs/bcachefs/opts.c
> +++ b/fs/bcachefs/opts.c
> @@ -365,6 +365,7 @@ int bch2_opt_parse(struct bch_fs *c,
>  		   struct printbuf *err)
>  {
>  	ssize_t ret;
> +	printbuf_indent_add_nextline(err, 2);
>  
>  	switch (opt->type) {
>  	case BCH_OPT_BOOL:
> 
> base-commit: 4d37602fceff942694069cf33cc55863277bd1c2
> -- 
> 2.49.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] bcachefs: indent error messages of invalid compression
  2025-04-07 18:43 ` Kent Overstreet
@ 2025-04-08 10:31   ` Integral
  2025-04-10  0:05     ` Kent Overstreet
  0 siblings, 1 reply; 4+ messages in thread
From: Integral @ 2025-04-08 10:31 UTC (permalink / raw)
  To: kent.overstreet; +Cc: integral, linux-bcachefs, linux-kernel

This patch uses printbuf_indent_add_nextline() to set a consistent
indentation level for error messages of invalid compression.

In my previous patch [1], the newline is added by using '\n' in
the argument of prt_str(). This patch replaces prt_str() with
prt_printf() to make indentation level work correctly.

[1] Link: https://lore.kernel.org/20250406152659.205997-2-integral@archlinuxcn.org

Signed-off-by: Integral <integral@archlinuxcn.org>
---
 fs/bcachefs/compress.c | 4 ++--
 fs/bcachefs/opts.c     | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c
index d68c3c7896a3..1bca61d17092 100644
--- a/fs/bcachefs/compress.c
+++ b/fs/bcachefs/compress.c
@@ -714,7 +714,7 @@ int bch2_opt_compression_parse(struct bch_fs *c, const char *_val, u64 *res,
 
 	ret = match_string(bch2_compression_opts, -1, type_str);
 	if (ret < 0 && err)
-		prt_str(err, "invalid compression type\n");
+		prt_printf(err, "invalid compression type\n");
 	if (ret < 0)
 		goto err;
 
@@ -729,7 +729,7 @@ int bch2_opt_compression_parse(struct bch_fs *c, const char *_val, u64 *res,
 		if (!ret && level > 15)
 			ret = -EINVAL;
 		if (ret < 0 && err)
-			prt_str(err, "invalid compression level\n");
+			prt_printf(err, "invalid compression level\n");
 		if (ret < 0)
 			goto err;
 
diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
index cd7b0cd293c7..f35fde896253 100644
--- a/fs/bcachefs/opts.c
+++ b/fs/bcachefs/opts.c
@@ -365,6 +365,7 @@ int bch2_opt_parse(struct bch_fs *c,
 		   struct printbuf *err)
 {
 	ssize_t ret;
+	printbuf_indent_add_nextline(err, 2);
 
 	switch (opt->type) {
 	case BCH_OPT_BOOL:

base-commit: 4d37602fceff942694069cf33cc55863277bd1c2
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] bcachefs: indent error messages of invalid compression
  2025-04-08 10:31   ` [PATCH v2] " Integral
@ 2025-04-10  0:05     ` Kent Overstreet
  0 siblings, 0 replies; 4+ messages in thread
From: Kent Overstreet @ 2025-04-10  0:05 UTC (permalink / raw)
  To: Integral; +Cc: linux-bcachefs, linux-kernel

On Tue, Apr 08, 2025 at 06:31:29PM +0800, Integral wrote:
> This patch uses printbuf_indent_add_nextline() to set a consistent
> indentation level for error messages of invalid compression.
> 
> In my previous patch [1], the newline is added by using '\n' in
> the argument of prt_str(). This patch replaces prt_str() with
> prt_printf() to make indentation level work correctly.
> 
> [1] Link: https://lore.kernel.org/20250406152659.205997-2-integral@archlinuxcn.org
> 
> Signed-off-by: Integral <integral@archlinuxcn.org>

Applied

> ---
>  fs/bcachefs/compress.c | 4 ++--
>  fs/bcachefs/opts.c     | 1 +
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/bcachefs/compress.c b/fs/bcachefs/compress.c
> index d68c3c7896a3..1bca61d17092 100644
> --- a/fs/bcachefs/compress.c
> +++ b/fs/bcachefs/compress.c
> @@ -714,7 +714,7 @@ int bch2_opt_compression_parse(struct bch_fs *c, const char *_val, u64 *res,
>  
>  	ret = match_string(bch2_compression_opts, -1, type_str);
>  	if (ret < 0 && err)
> -		prt_str(err, "invalid compression type\n");
> +		prt_printf(err, "invalid compression type\n");
>  	if (ret < 0)
>  		goto err;
>  
> @@ -729,7 +729,7 @@ int bch2_opt_compression_parse(struct bch_fs *c, const char *_val, u64 *res,
>  		if (!ret && level > 15)
>  			ret = -EINVAL;
>  		if (ret < 0 && err)
> -			prt_str(err, "invalid compression level\n");
> +			prt_printf(err, "invalid compression level\n");
>  		if (ret < 0)
>  			goto err;
>  
> diff --git a/fs/bcachefs/opts.c b/fs/bcachefs/opts.c
> index cd7b0cd293c7..f35fde896253 100644
> --- a/fs/bcachefs/opts.c
> +++ b/fs/bcachefs/opts.c
> @@ -365,6 +365,7 @@ int bch2_opt_parse(struct bch_fs *c,
>  		   struct printbuf *err)
>  {
>  	ssize_t ret;
> +	printbuf_indent_add_nextline(err, 2);
>  
>  	switch (opt->type) {
>  	case BCH_OPT_BOOL:
> 
> base-commit: 4d37602fceff942694069cf33cc55863277bd1c2
> -- 
> 2.49.0
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-10  0:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-07 17:41 [PATCH] bcachefs: indent error messages of invalid compression Integral
2025-04-07 18:43 ` Kent Overstreet
2025-04-08 10:31   ` [PATCH v2] " Integral
2025-04-10  0:05     ` Kent Overstreet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).