[dpdk-dev] net/mrvl: reset errno before library call

Message ID 1509611845-19698-1-git-send-email-tdu@semihalf.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Tomasz Duszynski Nov. 2, 2017, 8:37 a.m. UTC
  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 | 1 +
 1 file changed, 1 insertion(+)

--
2.7.4
  

Comments

Ferruh Yigit Nov. 2, 2017, 6:57 p.m. UTC | #1
On 11/2/2017 1:37 AM, Tomasz Duszynski wrote:
> 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>

Applied to dpdk-next-net/master, thanks.
  

Patch

diff --git a/drivers/net/mrvl/mrvl_qos.c b/drivers/net/mrvl/mrvl_qos.c
index 55f6406..2076228 100644
--- a/drivers/net/mrvl/mrvl_qos.c
+++ b/drivers/net/mrvl/mrvl_qos.c
@@ -122,6 +122,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;