]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dm-verity-fec: make fec_decode_bufs() just return 0 or error
authorEric Biggers <ebiggers@kernel.org>
Fri, 6 Feb 2026 04:59:39 +0000 (20:59 -0800)
committerMikulas Patocka <mpatocka@redhat.com>
Mon, 9 Mar 2026 14:13:43 +0000 (15:13 +0100)
fec_decode_bufs() returns the number of errors corrected or a negative
errno value.  However, the caller just checks for an errno value and
doesn't do anything with the number of errors corrected.  Simplify the
code by just returning 0 instead of the number of errors corrected.

Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
drivers/md/dm-verity-fec.c

index 956e03210943146c1a10e156dc07713e8abc2f84..96728e35e8dfb1d2b2498d8f8b90cad38d801796 100644 (file)
@@ -52,7 +52,7 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_io *io,
                           struct dm_verity_fec_io *fio, u64 index_in_region,
                           int target_region, unsigned int out_pos, int neras)
 {
-       int r, corrected = 0, res;
+       int r = 0, corrected = 0, res;
        struct dm_buffer *buf;
        unsigned int n, i, j, parity_pos, to_copy;
        uint16_t par_buf[DM_VERITY_FEC_MAX_ROOTS];
@@ -118,9 +118,8 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_io *io,
                                 NULL, neras, fio->erasures, 0, NULL);
                if (res < 0) {
                        r = res;
-                       goto error;
+                       goto done;
                }
-
                corrected += res;
                fio->output[out_pos++] = msg_buf[target_region];
 
@@ -128,16 +127,14 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_io *io,
                        goto done;
        }
 done:
-       r = corrected;
-error:
        dm_bufio_release(buf);
 
        if (r < 0 && neras)
                DMERR_LIMIT("%s: FEC %llu: failed to correct: %d",
                            v->data_dev->name, index_in_region, r);
-       else if (r > 0)
+       else if (r == 0 && corrected > 0)
                DMWARN_LIMIT("%s: FEC %llu: corrected %d errors",
-                            v->data_dev->name, index_in_region, r);
+                            v->data_dev->name, index_in_region, corrected);
 
        return r;
 }