mirror of
https://github.com/facebook/zstd.git
synced 2025-07-30 22:23:13 +03:00
change function name: _readU32FromChar() -> readU32FromCharChecked()
This commit is contained in:
@ -234,12 +234,12 @@ static void errorOut(const char* msg)
|
|||||||
DISPLAY("%s \n", msg); exit(1);
|
DISPLAY("%s \n", msg); exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! _readU32FromChar() :
|
/*! readU32FromCharChecked() :
|
||||||
* @return 0 if success, and store the result in *value.
|
* @return 0 if success, and store the result in *value.
|
||||||
* allows and interprets K, KB, KiB, M, MB and MiB suffix.
|
* allows and interprets K, KB, KiB, M, MB and MiB suffix.
|
||||||
* Will also modify `*stringPtr`, advancing it to position where it stopped reading.
|
* Will also modify `*stringPtr`, advancing it to position where it stopped reading.
|
||||||
* @return 1 if an overflow error occurs */
|
* @return 1 if an overflow error occurs */
|
||||||
static int _readU32FromChar(const char** stringPtr, unsigned* value)
|
static int readU32FromCharChecked(const char** stringPtr, unsigned* value)
|
||||||
{
|
{
|
||||||
static unsigned const max = (((unsigned)(-1)) / 10) - 1;
|
static unsigned const max = (((unsigned)(-1)) / 10) - 1;
|
||||||
unsigned result = 0;
|
unsigned result = 0;
|
||||||
@ -271,7 +271,7 @@ static int _readU32FromChar(const char** stringPtr, unsigned* value)
|
|||||||
static unsigned readU32FromChar(const char** stringPtr) {
|
static unsigned readU32FromChar(const char** stringPtr) {
|
||||||
static const char errorMsg[] = "error: numeric value too large";
|
static const char errorMsg[] = "error: numeric value too large";
|
||||||
unsigned result;
|
unsigned result;
|
||||||
if (_readU32FromChar(stringPtr, &result)) { errorOut(errorMsg); }
|
if (readU32FromCharChecked(stringPtr, &result)) { errorOut(errorMsg); }
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -483,15 +483,15 @@ static int init_cLevel(void) {
|
|||||||
|
|
||||||
if ((*ptr>='0') && (*ptr<='9')) {
|
if ((*ptr>='0') && (*ptr<='9')) {
|
||||||
unsigned absLevel;
|
unsigned absLevel;
|
||||||
if (_readU32FromChar(&ptr, &absLevel)) {
|
if (readU32FromCharChecked(&ptr, &absLevel)) {
|
||||||
DISPLAYLEVEL(2, "Ignore environment variable %s=%s: numeric value too large\n", ENV_CLEVEL, env);
|
DISPLAYLEVEL(2, "Ignore environment variable setting %s=%s: numeric value too large\n", ENV_CLEVEL, env);
|
||||||
return ZSTDCLI_CLEVEL_DEFAULT;
|
return ZSTDCLI_CLEVEL_DEFAULT;
|
||||||
} else if (*ptr == 0) {
|
} else if (*ptr == 0) {
|
||||||
return sign * absLevel;
|
return sign * absLevel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DISPLAYLEVEL(2, "Ignore environment variable %s=%s: not a valid integer value\n", ENV_CLEVEL, env);
|
DISPLAYLEVEL(2, "Ignore environment variable setting %s=%s: not a valid integer value\n", ENV_CLEVEL, env);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ZSTDCLI_CLEVEL_DEFAULT;
|
return ZSTDCLI_CLEVEL_DEFAULT;
|
||||||
|
Reference in New Issue
Block a user