linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ferdinand Blomqvist <ferdinand.blomqvist@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH v2 5/7] rslib: Fix handling of of caller provided syndrome
Date: Thu, 20 Jun 2019 17:10:37 +0300	[thread overview]
Message-ID: <20190620141039.9874-6-ferdinand.blomqvist@gmail.com> (raw)
In-Reply-To: <20190620141039.9874-1-ferdinand.blomqvist@gmail.com>

Check if the syndrome provided by the caller is zero, and act
accordingly.

Signed-off-by: Ferdinand Blomqvist <ferdinand.blomqvist@gmail.com>
---
 lib/reed_solomon/decode_rs.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/lib/reed_solomon/decode_rs.c b/lib/reed_solomon/decode_rs.c
index 78629bbe6590..b7264a712d46 100644
--- a/lib/reed_solomon/decode_rs.c
+++ b/lib/reed_solomon/decode_rs.c
@@ -42,8 +42,18 @@
 	BUG_ON(pad < 0 || pad >= nn - nroots);
 
 	/* Does the caller provide the syndrome ? */
-	if (s != NULL)
-		goto decode;
+	if (s != NULL) {
+		for (i = 0; i < nroots; i++) {
+			/* The syndrome is in index form,
+			 * so nn represents zero
+			 */
+			if (s[i] != nn)
+				goto decode;
+		}
+
+		/* syndrome is zero, no errors to correct  */
+		return 0;
+	}
 
 	/* form the syndromes; i.e., evaluate data(x) at roots of
 	 * g(x) */
-- 
2.17.2


  parent reply	other threads:[~2019-06-20 14:11 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-20 14:10 [PATCH v2 0/7] rslib: RS decoder is severely broken Ferdinand Blomqvist
2019-06-20 14:10 ` [PATCH v2 1/7] rslib: Add tests for the encoder and decoder Ferdinand Blomqvist
2019-06-26 13:01   ` [tip:core/rslib] " tip-bot for Ferdinand Blomqvist
2019-07-09 18:06   ` [PATCH v2 1/7] " Geert Uytterhoeven
2019-07-09 18:27     ` Thomas Gleixner
2019-06-20 14:10 ` [PATCH v2 2/7] rslib: Fix decoding of shortened codes Ferdinand Blomqvist
2019-06-26 13:01   ` [tip:core/rslib] " tip-bot for Ferdinand Blomqvist
2019-06-20 14:10 ` [PATCH v2 3/7] rslib: decode_rs: Fix length parameter check Ferdinand Blomqvist
2019-06-26 13:02   ` [tip:core/rslib] " tip-bot for Ferdinand Blomqvist
2019-06-20 14:10 ` [PATCH v2 4/7] rslib: decode_rs: code cleanup Ferdinand Blomqvist
2019-06-26 13:03   ` [tip:core/rslib] rslib: decode_rs: Code cleanup tip-bot for Ferdinand Blomqvist
2019-06-20 14:10 ` Ferdinand Blomqvist [this message]
2019-06-26 13:04   ` [tip:core/rslib] rslib: Fix handling of of caller provided syndrome tip-bot for Ferdinand Blomqvist
2019-06-20 14:10 ` [PATCH v2 6/7] rslib: Update documentation Ferdinand Blomqvist
2019-06-26 13:04   ` [tip:core/rslib] " tip-bot for Ferdinand Blomqvist
2019-06-20 14:10 ` [PATCH v2 7/7] rslib: Fix remaining decoder flaws Ferdinand Blomqvist
2019-06-26 13:05   ` [tip:core/rslib] " tip-bot for Ferdinand Blomqvist
2019-06-26 12:57 ` [PATCH v2 0/7] rslib: RS decoder is severely broken Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190620141039.9874-6-ferdinand.blomqvist@gmail.com \
    --to=ferdinand.blomqvist@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).