bcachefs: indent error messages of invalid compression
authorIntegral <integral@archlinuxcn.org>
Tue, 8 Apr 2025 10:31:29 +0000 (18:31 +0800)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 22 May 2025 00:14:10 +0000 (20:14 -0400)
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.

Link: https://lore.kernel.org/20250406152659.205997-2-integral@archlinuxcn.org
Signed-off-by: Integral <integral@archlinuxcn.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/compress.c
fs/bcachefs/opts.c

index d68c3c7896a3719319aed94006a822792f00a5ec..1bca61d170920bba48b22d04f6f00d32f6ce773b 100644 (file)
@@ -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;
 
index f40de111e5276eb23c8b75663d421df02ea85a85..ed2e2850c1d1b9469af761ff1141defb55d19623 100644 (file)
@@ -337,6 +337,9 @@ int bch2_opt_parse(struct bch_fs *c,
 {
        ssize_t ret;
 
+       if (err)
+               printbuf_indent_add_nextline(err, 2);
+
        switch (opt->type) {
        case BCH_OPT_BOOL:
                if (val) {