Blob Blame History Raw
From 40848993ca0b4ce826b37508b740055d97a961e2 Mon Sep 17 00:00:00 2001
From: Jonathan Dieter <jdieter@lesbg.com>
Date: Mon, 24 Apr 2017 21:16:12 +0300
Subject: [PATCH] [common] Fix overflow error with GCC 7

Make sure n is always added to unsigned 1 to avoid overflow errors

Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
---
 src/common/galois_coeff.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/common/galois_coeff.h b/src/common/galois_coeff.h
index 305bd10..da5a683 100644
--- a/src/common/galois_coeff.h
+++ b/src/common/galois_coeff.h
@@ -38,7 +38,7 @@ constexpr uint8_t gf_mul2(uint8_t x) {
  * \return log(x)
  */
 constexpr uint8_t gf_log(uint8_t x, uint8_t pow2n = 2, uint8_t n = 1) {
-	return x == pow2n ? n : gf_log(x, gf_mul2(pow2n), n + 1);
+	return x == pow2n ? n : gf_log(x, gf_mul2(pow2n), n + 1U);
 }
 
 /*! \brief Compute base 2 exponent in GF(2^8).
@@ -48,7 +48,7 @@ constexpr uint8_t gf_log(uint8_t x, uint8_t pow2n = 2, uint8_t n = 1) {
  * \return exp(x)
  */
 constexpr uint8_t gf_exp(uint8_t x, uint8_t pow2n = 2, uint8_t n = 1) {
-	return x == n ? pow2n : gf_exp(x, gf_mul2(pow2n), n + 1);
+	return x == n ? pow2n : gf_exp(x, gf_mul2(pow2n), n + 1U);
 }
 
 /*! \brief Returns lookup table for base 2 logarithm in GF(2^8). */
-- 
2.9.3