From: Thomas Preston <thomas.preston@codethink.co.uk>
To: akpm@linux-foundation.org, pmladek@suse.com,
andriy.shevchenko@linux.intel.com, rostedt@goodmis.org,
geert+renesas@glider.be, corbet@lwn.net, me@tobin.cc,
sergey.senozhatsky@gmail.com, linux-kernel@vger.kernel.org
Cc: Thomas Preston <thomas.preston@codethink.co.uk>
Subject: [PATCH 1/2] vsprintf: Specify type for union val members
Date: Tue, 11 Dec 2018 15:21:12 +0000 [thread overview]
Message-ID: <20181211152113.8523-2-thomas.preston@codethink.co.uk> (raw)
In-Reply-To: <20181211152113.8523-1-thomas.preston@codethink.co.uk>
The vsscanf function uses implicit type casting to populate the long
long integers in union val from the obsolete functions simple_strtol()
and simple_strtoll(). However the new functions kstrtol() and kstrtoll()
expect a pointer to the correct type, so we must be explicit about which
type we are using.
Signed-off-by: Thomas Preston <thomas.preston@codethink.co.uk>
---
lib/vsprintf.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 37a54a6dd594..bbf2ac734711 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -2914,8 +2914,8 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
u8 qualifier;
unsigned int base;
union {
- long long s;
- unsigned long long u;
+ long long sll;
+ unsigned long long ull;
} val;
s16 field_width;
bool is_sign;
@@ -3120,11 +3120,11 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
break;
if (is_sign)
- val.s = qualifier != 'L' ?
+ val.sll = qualifier != 'L' ?
simple_strtol(str, &next, base) :
simple_strtoll(str, &next, base);
else
- val.u = qualifier != 'L' ?
+ val.ull = qualifier != 'L' ?
simple_strtoul(str, &next, base) :
simple_strtoull(str, &next, base);
@@ -3133,9 +3133,9 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
_parse_integer_fixup_radix(str, &base);
while (next - str > field_width) {
if (is_sign)
- val.s = div_s64(val.s, base);
+ val.sll = div_s64(val.sll, base);
else
- val.u = div_u64(val.u, base);
+ val.ull = div_u64(val.ull, base);
--next;
}
}
@@ -3143,36 +3143,36 @@ int vsscanf(const char *buf, const char *fmt, va_list args)
switch (qualifier) {
case 'H': /* that's 'hh' in format */
if (is_sign)
- *va_arg(args, signed char *) = val.s;
+ *va_arg(args, signed char *) = val.sll;
else
- *va_arg(args, unsigned char *) = val.u;
+ *va_arg(args, unsigned char *) = val.ull;
break;
case 'h':
if (is_sign)
- *va_arg(args, short *) = val.s;
+ *va_arg(args, short *) = val.sll;
else
- *va_arg(args, unsigned short *) = val.u;
+ *va_arg(args, unsigned short *) = val.ull;
break;
case 'l':
if (is_sign)
- *va_arg(args, long *) = val.s;
+ *va_arg(args, long *) = val.sll;
else
- *va_arg(args, unsigned long *) = val.u;
+ *va_arg(args, unsigned long *) = val.ull;
break;
case 'L':
if (is_sign)
- *va_arg(args, long long *) = val.s;
+ *va_arg(args, long long *) = val.sll;
else
- *va_arg(args, unsigned long long *) = val.u;
+ *va_arg(args, unsigned long long *) = val.ull;
break;
case 'z':
- *va_arg(args, size_t *) = val.u;
+ *va_arg(args, size_t *) = val.ull;
break;
default:
if (is_sign)
- *va_arg(args, int *) = val.s;
+ *va_arg(args, int *) = val.sll;
else
- *va_arg(args, unsigned int *) = val.u;
+ *va_arg(args, unsigned int *) = val.ull;
break;
}
num++;
--
2.11.0
next prev parent reply other threads:[~2018-12-11 15:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-11 15:21 [PATCH 0/2] vsprintf Stop using obsolete simple_strtoul() Thomas Preston
2018-12-11 15:21 ` Thomas Preston [this message]
2018-12-11 15:21 ` [PATCH 2/2] vsprintf: " Thomas Preston
2018-12-11 17:22 ` Linus Torvalds
2018-12-11 18:04 ` Andy Shevchenko
2018-12-11 18:19 ` Linus Torvalds
2018-12-11 21:30 ` Andy Shevchenko
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=20181211152113.8523-2-thomas.preston@codethink.co.uk \
--to=thomas.preston@codethink.co.uk \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=corbet@lwn.net \
--cc=geert+renesas@glider.be \
--cc=linux-kernel@vger.kernel.org \
--cc=me@tobin.cc \
--cc=pmladek@suse.com \
--cc=rostedt@goodmis.org \
--cc=sergey.senozhatsky@gmail.com \
/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