lizardfs/0001-common-Fix-overflow-er...

49 lines
1.5 KiB
Diff

From ada5b685cf961b62a33afd2c79ad59d78a2789be 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
This commit makes sure n is unsigned to avoid overflow errors in GCC 7.
Closes #540
Signed-off-by: Jonathan Dieter <jdieter@lesbg.com>
Change-Id: I09ae619029b756a11eeffee8fb55ffe2914c3e9a
---
src/common/galois_coeff.h | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/common/galois_coeff.h b/src/common/galois_coeff.h
index 305bd10..07708ba 100644
--- a/src/common/galois_coeff.h
+++ b/src/common/galois_coeff.h
@@ -1,5 +1,5 @@
/*
- Copyright 2016 Skytechnology sp. z o.o.
+ Copyright 2017 Skytechnology sp. z o.o.
This file is part of LizardFS.
@@ -37,7 +37,7 @@ constexpr uint8_t gf_mul2(uint8_t x) {
* \param n Internal variable used for recursion.
* \return log(x)
*/
-constexpr uint8_t gf_log(uint8_t x, uint8_t pow2n = 2, uint8_t n = 1) {
+constexpr uint8_t gf_log(uint8_t x, uint8_t pow2n = 2, unsigned n = 1) {
return x == pow2n ? n : gf_log(x, gf_mul2(pow2n), n + 1);
}
@@ -47,7 +47,7 @@ constexpr uint8_t gf_log(uint8_t x, uint8_t pow2n = 2, uint8_t n = 1) {
* \param n Internal variable used for recursion.
* \return exp(x)
*/
-constexpr uint8_t gf_exp(uint8_t x, uint8_t pow2n = 2, uint8_t n = 1) {
+constexpr uint8_t gf_exp(uint8_t x, uint8_t pow2n = 2, unsigned n = 1) {
return x == n ? pow2n : gf_exp(x, gf_mul2(pow2n), n + 1);
}
--
2.9.3