net/mrvl: reset errno before library call
authorTomasz Duszynski <tdu@semihalf.com>
Thu, 2 Nov 2017 08:37:25 +0000 (09:37 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Thu, 2 Nov 2017 18:42:11 +0000 (19:42 +0100)
In case errno contains some non-zero value and call to strtoul() is
successful -2 error will be returned.

Setting errno to zero before calling strtoul() makes sure
errors will be handled correctly.

Fixes: 0ddc9b815b11 ("net/mrvl: add net PMD skeleton")

Signed-off-by: Tomasz Duszynski <tdu@semihalf.com>
drivers/net/mrvl/mrvl_qos.c

index 54e682a..7c9943a 100644 (file)
@@ -99,6 +99,7 @@ get_val_securely(const char *string, uint32_t *val)
        if (len == 0)
                return -1;
 
+       errno = 0;
        *val = strtoul(string, &endptr, 0);
        if (errno != 0 || RTE_PTR_DIFF(endptr, string) != len)
                return -2;