Skip to contentSkip to conversation

bcachefs: indent error messages of invalid compression

PATCH Superseded Integral 2 participants 4 messages Apr 7, 2025 – Apr 10, 2025

lore
Share & tools
lore

Integral

author
#0 lore raw

PATCH 1/1 bcachefs: indent error messages of invalid compression

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/[email protected]

---
 fs/bcachefs/compress.c | 12 ++++++++----
 fs/bcachefs/opts.c     |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)
fs/bcachefs/compress.c +8 -4
index d68c3c7896a3..a107aa88a875 100644
@@ -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;
 
fs/bcachefs/opts.c +1 -0
index cd7b0cd293c7..f35fde896253 100644
@@ -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

Signature · 1 line
2.49.0
#1 lore raw
Quoted 33 lines · 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/[email protected]

---
 fs/bcachefs/compress.c | 12 ++++++++----
 fs/bcachefs/opts.c     |  1 +
 2 files changed, 9 insertions(+), 4 deletions(-)
fs/bcachefs/compress.c +4 -2
index d68c3c7896a3..a107aa88a875 100644
@@ -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;
 

fs/bcachefs/compress.c int bch2_opt_compression_parse(struct bch_fs *c, const char *_val, u64 *res, · line 734

Quoted 7 lines
fs/bcachefs/compress.c +2 -2
@@ -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

Quoted 22 lines
fs/bcachefs/compress.c +2 -0
+			prt_newline(err);
+		}
 		if (ret < 0)
 			goto err;
 
fs/bcachefs/opts.c +1 -0
index cd7b0cd293c7..f35fde896253 100644
@@ -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

Signature · 1 line
2.49.0
author
#2 lore raw

PATCH v2 1/1 bcachefs: indent error messages of invalid compression

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/[email protected]

---
 fs/bcachefs/compress.c | 4 ++--
 fs/bcachefs/opts.c     | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
fs/bcachefs/compress.c +2 -2
index d68c3c7896a3..1bca61d17092 100644
@@ -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;
 
fs/bcachefs/opts.c +1 -0
index cd7b0cd293c7..f35fde896253 100644
@@ -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

Signature · 1 line
2.49.0
#3 lore raw
Quoted 10 lines · 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 prt_str() with prt_printf() to make indentation level work correctly.

[1] Link: https://lore.kernel.org/[email protected]

Applied

Quoted 44 lines
---
 fs/bcachefs/compress.c | 4 ++--
 fs/bcachefs/opts.c     | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
fs/bcachefs/compress.c +2 -2
index d68c3c7896a3..1bca61d17092 100644
@@ -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;
 
fs/bcachefs/opts.c +1 -0
index cd7b0cd293c7..f35fde896253 100644
@@ -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

Signature · 1 line
2.49.0