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 <[email protected]>
---
 drivers/md/dm-verity-fec.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c
index 37c4eb6a11dee..59ff3d58f49df 100644
--- a/drivers/md/dm-verity-fec.c
+++ b/drivers/md/dm-verity-fec.c
@@ -50,11 +50,11 @@ static inline u8 *fec_buffer_rs_message(struct dm_verity *v,
  */
 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];
        u8 *par, *msg_buf;
        u64 parity_block;
@@ -116,30 +116,27 @@ static int fec_decode_bufs(struct dm_verity *v, struct 
dm_verity_io *io,
                /* Decode an RS codeword using the Reed-Solomon library. */
                res = decode_rs8(fio->rs, msg_buf, par_buf, v->fec->rs_k,
                                 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];
 
                if (out_pos >= v->fec->block_size)
                        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;
 }
 
 /*
-- 
2.52.0


Reply via email to