From: Richard PALO <richard at netbsd.org>
To: devel@acpica.org
Subject: [Devel] PATCH proposal removing use of strtoul in events/evgpeinit.c
Date: Fri, 04 Sep 2015 13:12:11 +0200 [thread overview]
Message-ID: <55E97C8B.3050302@netbsd.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 2171 bytes --]
I'm noticing on catching up recently, e.g. on 20150717, that there is the following issue:
> /home/richard/ws/illumos-gate/usr/src/common/acpica/components/events/evgpeinit.c: In function 'AcpiEvMatchGpeMethod':
> /home/richard/ws/illumos-gate/usr/src/common/acpica/components/events/evgpeinit.c:398: error: implicit declaration of function 'strtoul' [-Wimplicit-function-declaration]
strtoul is indirectly defined in acsolaris via a system header as:
I like to propose the following patch substituting for a simplified, specific conversion
in the file events/evgpeinit.c.
>extern unsigned long strtoul(const char *, char **, int);
This seems to be the only real use of strtoul with _KERNEL defined.
Looking at the code in question, for two hex digits is doesn't seem the worth to use it so I propose
to replace as follows:
> diff --git a/usr/src/common/acpica/components/events/evgpeinit.c b/usr/src/common/acpica/components/events/evgpeinit.c
> index d23a345..de1e15a 100644
> --- a/usr/src/common/acpica/components/events/evgpeinit.c
> +++ b/usr/src/common/acpica/components/events/evgpeinit.c
> @@ -395,8 +395,22 @@ AcpiEvMatchGpeMethod (
>
> /* 4) The last two characters of the name are the hex GPE Number */
>
> - GpeNumber = strtoul (&Name[2], NULL, 16);
> - if (GpeNumber == ACPI_UINT32_MAX)
> + /* GpeNumber = strtoul (&Name[2], NULL, 16); */
> + /*
> + * As this function can be called in KERNEL, not all systems have
> + * strtoul() available. Since this is only for a single hex value,
> + * manually convert nibble by nibble, checking for possible errors.
> + */
> + GpeNumber = isdigit(Name[2]) ? (Name[2] - '0')<<4 :
> + isxdigit(Name[2]) ? (toupper(Name[2]) - 'A' + 10)<<4 : 0xFFFF;
> +
> + if (GpeNumber != 0xFFFF) {
> + GpeNumber = isdigit(Name[3]) ? GpeNumber + (Name[3] - '0') :
> + isxdigit(Name[3]) ? GpeNumber + (toupper(Name[3]) - 'A' + 10) :
> + 0xFFFF;
> + }
> +
> + if (GpeNumber == 0xFFFF || Name[4] != '\0')
> {
> /* Conversion failed; invalid method, just ignore it */
>
--
Richard PALO
next reply other threads:[~2015-09-04 11:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-04 11:12 Richard PALO [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-09-04 13:58 [Devel] PATCH proposal removing use of strtoul in events/evgpeinit.c Moore, Robert
2015-09-05 6:01 Richard PALO
2015-09-09 18:00 Moore, Robert
2015-09-09 18:01 Moore, Robert
2015-09-11 10:56 Richard PALO
2015-09-11 14:53 Moore, Robert
2015-09-11 14:57 Moore, Robert
2015-09-11 15:36 Richard PALO
2015-09-11 15:49 Moore, Robert
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=55E97C8B.3050302@netbsd.org \
--to=devel@acpica.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.