[source] ptgen: work around gcc miscompilation

LEDE Commits lede-commits at lists.infradead.org
Mon Sep 26 04:29:15 PDT 2016


jogo pushed a commit to source.git, branch master:
https://git.lede-project.org/997fed94e328315c6055331dbd8d6d4b56d1b454

commit 997fed94e328315c6055331dbd8d6d4b56d1b454
Author: Jonas Gorski <jonas.gorski at gmail.com>
AuthorDate: Mon Sep 12 12:59:21 2016 +0200

    ptgen: work around gcc miscompilation
    
    Some gcc versions seem to miscompile code using ternary operators,
    work around this by just returning the result if exp is 0.
    
    Signed-off-by: Jonas Gorski <jonas.gorski at gmail.com>
---
 tools/firmware-utils/src/ptgen.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/firmware-utils/src/ptgen.c b/tools/firmware-utils/src/ptgen.c
index 04f4ec8..8466d35 100644
--- a/tools/firmware-utils/src/ptgen.c
+++ b/tools/firmware-utils/src/ptgen.c
@@ -93,7 +93,9 @@ static long to_kbytes(const char *string) {
 	}
 
 	/* result: number + 1024^(exp) */
-	return result * ((2 << ((10 * exp) - 1)) ?: 1);
+	if (exp == 0)
+		return result;
+	return result * (2 << ((10 * exp) - 1));
 }
 
 /* convert the sector number into a CHS value for the partition table */



More information about the lede-commits mailing list