]> git.cameronkatri.com Git - pw-darwin.git/commitdiff
pw: Remove unnecessary errp checks.
authorMark Johnston <markj@FreeBSD.org>
Tue, 1 Sep 2020 15:14:26 +0000 (15:14 +0000)
committerMark Johnston <markj@FreeBSD.org>
Tue, 1 Sep 2020 15:14:26 +0000 (15:14 +0000)
The caller-supplied pointer is unconditionally dereferenced at the
beginning of the function, so there is no point in comparing it with
NULL thereafter.

Reported by: Coverity
MFC after: 1 week
Sponsored by: NetApp, Inc.
Sponsored by: Klara, Inc.

pw/strtounum.c

index b2fefebde39295dbc7c298f87d85d1bb8cda2560..ae578bdeaeba22da613b74e50bda0acc747e3052 100644 (file)
@@ -44,28 +44,24 @@ strtounum(const char * __restrict np, uintmax_t minval, uintmax_t maxval,
        *errpp = NULL;
        if (minval > maxval) {
                errno = EINVAL;
-               if (errpp != NULL)
-                       *errpp = "invalid";
+               *errpp = "invalid";
                return (0);
        }
        errno = 0;
        ret = strtoumax(np, &endp, 10);
        if (endp == np || *endp != '\0') {
                errno = EINVAL;
-               if (errpp != NULL)
-                       *errpp = "invalid";
+               *errpp = "invalid";
                return (0);
        }
        if (ret < minval) {
                errno = ERANGE;
-               if (errpp != NULL)
-                       *errpp = "too small";
+               *errpp = "too small";
                return (0);
        }
        if (errno == ERANGE || ret > maxval) {
                errno = ERANGE;
-               if (errpp != NULL)
-                       *errpp = "too large";
+               *errpp = "too large";
                return (0);
        }
        return (ret);