From 90c0462d63768899d8a08a5ec0975294869e66f2 Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Wed, 10 Apr 2019 10:03:06 -0700 Subject: [PATCH] minor presentation refactoring and removed some // comment style --- programs/zstdcli.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/programs/zstdcli.c b/programs/zstdcli.c index ef2fe2e91..f4452636b 100644 --- a/programs/zstdcli.c +++ b/programs/zstdcli.c @@ -241,18 +241,20 @@ static void errorOut(const char* msg) * @return 1 if an overflow error occurs */ static int readU32FromCharChecked(const char** stringPtr, unsigned* value) { - static unsigned const max = (((unsigned)(-1)) / 10) - 1; unsigned result = 0; while ((**stringPtr >='0') && (**stringPtr <='9')) { - if (result > max) return 1; // overflow error - result *= 10, result += **stringPtr - '0', (*stringPtr)++ ; + unsigned const max = (((unsigned)(-1)) / 10) - 1; + if (result > max) return 1; /* overflow error */ + result *= 10; + result += (unsigned)(**stringPtr - '0'); + (*stringPtr)++ ; } if ((**stringPtr=='K') || (**stringPtr=='M')) { unsigned const maxK = ((unsigned)(-1)) >> 10; - if (result > maxK) return 1; // overflow error + if (result > maxK) return 1; /* overflow error */ result <<= 10; if (**stringPtr=='M') { - if (result > maxK) return 1; // overflow error + if (result > maxK) return 1; /* overflow error */ result <<= 10; } (*stringPtr)++; /* skip `K` or `M` */ @@ -483,7 +485,7 @@ static int init_cLevel(void) { if ((*ptr>='0') && (*ptr<='9')) { unsigned absLevel; - if (readU32FromCharChecked(&ptr, &absLevel)) { + if (readU32FromCharChecked(&ptr, &absLevel)) { DISPLAYLEVEL(2, "Ignore environment variable setting %s=%s: numeric value too large\n", ENV_CLEVEL, env); return ZSTDCLI_CLEVEL_DEFAULT; } else if (*ptr == 0) {