All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Zaborowski <andrew.zaborowski@intel.com>
To: ell@lists.01.org
Subject: [PATCH] settings: Parse non-base-10 integer settings
Date: Wed, 25 Mar 2020 21:18:05 +0100	[thread overview]
Message-ID: <20200325201805.4801-1-andrew.zaborowski@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1232 bytes --]

Change the stro{,u}{l,ll} base parameter to 0 to not disallow hex or
octal numbers, useful for bitmasks.
---
 ell/settings.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/ell/settings.c b/ell/settings.c
index c5e1184..f4326d6 100644
--- a/ell/settings.c
+++ b/ell/settings.c
@@ -998,7 +998,7 @@ LIB_EXPORT bool l_settings_get_int(const struct l_settings *settings,
 
 	errno = 0;
 
-	t = r = strtol(value, &endp, 10);
+	t = r = strtol(value, &endp, 0);
 	if (*endp != '\0')
 		goto error;
 
@@ -1045,7 +1045,7 @@ LIB_EXPORT bool l_settings_get_uint(const struct l_settings *settings,
 
 	errno = 0;
 
-	t = r = strtoul(value, &endp, 10);
+	t = r = strtoul(value, &endp, 0);
 	if (*endp != '\0')
 		goto error;
 
@@ -1091,7 +1091,7 @@ LIB_EXPORT bool l_settings_get_int64(const struct l_settings *settings,
 
 	errno = 0;
 
-	r = strtoll(value, &endp, 10);
+	r = strtoll(value, &endp, 0);
 	if (*endp != '\0')
 		goto error;
 
@@ -1137,7 +1137,7 @@ LIB_EXPORT bool l_settings_get_uint64(const struct l_settings *settings,
 
 	errno = 0;
 
-	r = strtoull(value, &endp, 10);
+	r = strtoull(value, &endp, 0);
 	if (*endp != '\0')
 		goto error;
 
-- 
2.20.1

             reply	other threads:[~2020-03-25 20:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-25 20:18 Andrew Zaborowski [this message]
2020-03-26 18:15 ` [PATCH] settings: Parse non-base-10 integer settings Denis Kenzior

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=20200325201805.4801-1-andrew.zaborowski@intel.com \
    --to=andrew.zaborowski@intel.com \
    --cc=ell@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.