mirror of
https://git.freebsd.org/src.git
synced 2026-01-12 06:54:03 +00:00
FreeBSD: Fix uninitialized variable error
On FreeBSD errno is defined as (* __error()), which means compiler can't say whether two consecutive reads will return the same. And without this knowledge the reported error is formally right. Caching of the errno in local variable fixes the issue. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Rob Norris <robn@despairlabs.com> Signed-off-by: Alexander Motin <alexander.motin@TrueNAS.com> Closes #17975
This commit is contained in:
parent
e37937f42d
commit
7f7d4934cb
1 changed files with 8 additions and 4 deletions
|
|
@ -124,10 +124,12 @@ zfs_tunable_parse_int(const char *val, intmax_t *np,
|
|||
{
|
||||
intmax_t n;
|
||||
char *end;
|
||||
int err;
|
||||
|
||||
errno = 0;
|
||||
n = strtoimax(val, &end, 0);
|
||||
if (errno != 0)
|
||||
return (errno);
|
||||
if ((err = errno) != 0)
|
||||
return (err);
|
||||
if (*end != '\0')
|
||||
return (EINVAL);
|
||||
if (n < min || n > max)
|
||||
|
|
@ -142,10 +144,12 @@ zfs_tunable_parse_uint(const char *val, uintmax_t *np,
|
|||
{
|
||||
uintmax_t n;
|
||||
char *end;
|
||||
int err;
|
||||
|
||||
errno = 0;
|
||||
n = strtoumax(val, &end, 0);
|
||||
if (errno != 0)
|
||||
return (errno);
|
||||
if ((err = errno) != 0)
|
||||
return (err);
|
||||
if (*end != '\0')
|
||||
return (EINVAL);
|
||||
if (strchr(val, '-'))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue