The branch stable/15 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=bf95db1639afd275a7d0c9aacde1a863ce649089
commit bf95db1639afd275a7d0c9aacde1a863ce649089 Author: Colin Percival <[email protected]> AuthorDate: 2026-08-29 20:22:15 +0000 Commit: Colin Percival <[email protected]> CommitDate: 2026-09-07 19:10:50 +0000 gstat: Set errno = 0 before strtoul The strtoul function sets errno on error, but does not clear it on success; when using strtoul and checking errno (as one should) for ERANGE / EINVAL afterwards, it's important to zero errno first. While here, remove a dead store. Reviewed by: phk Fixes: 4fe8c1b67be0 ("Add error and range checking ... ") MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D59270 (cherry picked from commit 6ddb10cf6b7f870d749e96d2ae55976b18896f54) --- usr.sbin/gstat/gstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/gstat/gstat.c b/usr.sbin/gstat/gstat.c index c650f7120a40..7bf5930939d5 100644 --- a/usr.sbin/gstat/gstat.c +++ b/usr.sbin/gstat/gstat.c @@ -142,7 +142,7 @@ main(int argc, char **argv) strlcpy(f_s, optarg, sizeof(f_s)); break; case 'I': - p = NULL; + errno = 0; i = strtoul(optarg, &p, 0); if (p == optarg || errno == EINVAL || errno == ERANGE) {
