From: Yann Collet Date: Wed, 10 Apr 2019 17:03:06 +0000 (-0700) Subject: minor presentation refactoring X-Git-Tag: v1.4.0^2~6^2~18 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=90c0462d63768899d8a08a5ec0975294869e66f2;p=thirdparty%2Fzstd.git minor presentation refactoring and removed some // comment style --- 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) {