mirror of
https://github.com/facebook/zstd.git
synced 2025-12-24 17:21:03 +03:00
minor presentation refactoring
and removed some // comment style
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user