From: Jiri Slaby <jirislaby@gmail.com>
To: Matthias Pfaller <leo@marco.de>
Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
"Eric W. Biederman" <ebiederm@xmission.com>,
Len Brown <lenb@kernel.org>,
linux-acpi@vger.kernel.org
Subject: DMI year "00" + ACPI [was: DMI: fix dmi_get_year year parsing]
Date: Thu, 09 Jul 2009 09:12:17 +0200 [thread overview]
Message-ID: <4A559851.5030302@gmail.com> (raw)
In-Reply-To: <4A5444BD.1090905@marco.de>
On 07/08/2009 09:03 AM, Matthias Pfaller wrote:
> Jiri Slaby wrote:
>> On 07/08/2009 08:46 AM, Matthias Pfaller wrote:
>>> Jiri Slaby wrote:
>>>> Don't guess a year number base. Use 10 instead, since year may
>>>> be 2-digit starting with 0, so that we would end up in base equal
>>>> to 8.
>>>>
>>>> Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
>>>> Reported-by: Matthias Pfaller <leo@marco.de>
>>>> ---
>>>> drivers/firmware/dmi_scan.c | 2 +-
>>>> 1 files changed, 1 insertions(+), 1 deletions(-)
>>>>
>>>> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
>>>> index 6071078..8fe0f6e 100644
>>>> --- a/drivers/firmware/dmi_scan.c
>>>> +++ b/drivers/firmware/dmi_scan.c
>>>> @@ -611,7 +611,7 @@ int dmi_get_year(int field)
>>>> return 0;
>>>>
>>>> s += 1;
>>>> - year = simple_strtoul(s, NULL, 0);
>>>> + year = simple_strtoul(s, NULL, 10);
>>>> if (year && year < 100) { /* 2-digit year */
>>>> year += 1900;
>>>> if (year < 1996) /* no dates < spec 1.0 */
>>> I just noticed, that this is not enough, because this will still fail
>>> for xxx/xx/00. I suggest the following patch:
>>
>> Actually the patch below is not correct. Standard says consider xx/xx/yy
>> as 19yy, not 20yy.
>>
>> BTW. the patch above is not useful, reporting 1908 and 1909 as a year is
>> almost the same as 1900.
>
> Sorry, I don't understand.
Nevermind, you're right. Both patches are OK, however we might hit a
regression with 00/00/00 entries so that acpi gets unintentionally armed
now for them (ACPI checks year == 0). I don't know if it's worth it. Any
ideas?
>>> --- drivers/firmware/dmi_scan.c.bak Wed Jul 8 02:42:04 2009
>>> +++ drivers/firmware/dmi_scan.c Wed Jul 8 02:42:17 2009
>>> @@ -360,12 +360,15 @@
>>> return 0;
>>>
>>> s += 1;
>>> - year = simple_strtoul(s, NULL, 0);
>>> - if (year && year < 100) { /* 2-digit year */
>>> - year += 1900;
>>> - if (year < 1996) /* no dates < spec 1.0 */
>>> - year += 100;
>>> + if (s[0] == '0' && s[1] == '0' && s[2] == '\0') {
>>> + year = 2000;
>>> + } else {
>>> + year = simple_strtoul(s, NULL, 10);
>>> + if (year && year < 100) { /* 2-digit year */
>>> + year += 1900;
>>> + if (year < 1996) /* no dates < spec
>>> 1.0 */
>>> + year += 100;
>>> + }
>>> }
>>> -
>>> return year;
>>> }
next prev parent reply other threads:[~2009-07-09 7:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-07 20:36 [PATCH 1/1] DMI: fix dmi_get_year year parsing Jiri Slaby
2009-07-08 6:46 ` Matthias Pfaller
2009-07-08 6:54 ` Jiri Slaby
2009-07-08 7:03 ` Matthias Pfaller
2009-07-09 7:12 ` Jiri Slaby [this message]
2009-07-09 7:39 ` DMI year "00" + ACPI [was: DMI: fix dmi_get_year year parsing] Matthias Pfaller
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=4A559851.5030302@gmail.com \
--to=jirislaby@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=lenb@kernel.org \
--cc=leo@marco.de \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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).