DPDK patches and discussions
 help / color / mirror / Atom feed
From: Tomasz Duszynski <tdu@semihalf.com>
To: dev@dpdk.org
Cc: Tomasz Duszynski <tdu@semihalf.com>
Subject: [dpdk-dev] [PATCH] net/mrvl: reset errno before library call
Date: Thu,  2 Nov 2017 09:37:25 +0100	[thread overview]
Message-ID: <1509611845-19698-1-git-send-email-tdu@semihalf.com> (raw)

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(+)

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;
--
2.7.4

             reply	other threads:[~2017-11-02  8:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-02  8:37 Tomasz Duszynski [this message]
2017-11-02 18:57 ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1509611845-19698-1-git-send-email-tdu@semihalf.com \
    --to=tdu@semihalf.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).