From: Pavel Vasilyev <pavel@pavlinux.ru>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: Pavel Machek <pavel@ucw.cz>, Len Brown <lenb@kernel.org>,
linux-acpi@vger.kernel.org, linux-pm@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, Len Brown <len.brown@intel.com>
Subject: Re: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1
Date: Wed, 08 Aug 2012 03:23:30 +0400 [thread overview]
Message-ID: <5021A372.8030409@pavlinux.ru> (raw)
In-Reply-To: <Pine.LNX.4.44L0.1208071322070.2400-100000@iolanthe.rowland.org>
07.08.2012 21:24, Alan Stern пишет:
> On Tue, 7 Aug 2012, Pavel Vasilyev wrote:
>
>> 06.08.2012 23:59, Alan Stern пишет:
>>> On Mon, 6 Aug 2012, Pavel Vasilyev wrote:
>>>
>>>>>> http://www.gossamer-threads.com/lists/engine?do=post_attachment;postatt_id=41157;list=linux
>>>>>
>>>>> Interestingly, many (all?) of the changes in that patch are wrong
>>>>> because they don't try to match the terminating '\0'. As a result,
>>>>> they will match against extensions of the target string as well as the
>>>>> target string itself.
>>>>>
>>>>
>>>> strNcmp compare N bytes - http://lxr.linux.no/#linux+v3.5/lib/string.c#L270
>>>> memcmp compare N bytes - http://lxr.linux.no/#linux+v3.5/lib/string.c#L651
>>>
>>> Yes. So if s contains "abcde" then
>>>
>>> memcmp(s, "abc", 3) and strncmp(s, "abc", 3) will both return 0, and
>>> memcmp(s, "abc", 4) and strncmp(s, "abc", 4) will both return 1.
>>
>> No matter what is contained in *s, "abcde" or "abcxxx",
>> are important first N bytes. The second example, you see,
>> a little bit stupid, and devoid of logic. :)
>
> Maybe yes, maybe no. It all depends on what you want.
>
> For example, if you're looking for "on" or "off", what should you do
> when the user writes "onoff"? You could accept it as meaning the same
> as "on", but if you were being careful then you would want to reject it
> as a meaningless value.
The users should't be allowed to think!
There is "on" - the size of 2 bytes, or "off" - 3 bytes,
other variations - user error.
We do not create a kernel with artificial intelligence? ;)
--
Pavel.
next prev parent reply other threads:[~2012-08-07 23:23 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-30 5:07 ACPI & Power Management Patches for Linux 3.5-rc4 Len Brown
2012-06-30 5:07 ` [PATCH 1/8] ACPI sysfs.c strlen fix Len Brown
2012-06-30 5:07 ` [PATCH 2/8] ACPI, x86: fix Dell M6600 ACPI reboot regression via DMI Len Brown
2012-07-06 11:09 ` Ingo Molnar
2012-06-30 5:07 ` [PATCH 3/8] ACPI: Make acpi_skip_timer_override cover all source_irq==0 cases Len Brown
2012-06-30 5:07 ` [PATCH 4/8] ACPI: Remove one board specific WARN when ignoring timer overriding Len Brown
2012-06-30 5:07 ` [PATCH 5/8] ACPI: Add a quirk for "AMILO PRO V2030" to ignore the " Len Brown
2012-06-30 5:07 ` [PATCH 6/8] ACPI, APEI, Avoid too much error reporting in runtime Len Brown
2012-06-30 5:07 ` [PATCH 7/8] ACPI video: Still use ACPI backlight control if _DOS doesn't exist Len Brown
2012-06-30 5:07 ` [PATCH 8/8] acpi_pad: fix power_saving thread deadlock Len Brown
2012-06-30 14:25 ` [PATCH 1/8] ACPI sysfs.c strlen fix Alan Stern
2012-07-27 1:39 ` [PATCH] ACPI: replace strlen("string") with sizeof("string") -1 Len Brown
2012-07-30 14:26 ` Ian Campbell
2012-07-30 14:41 ` richard -rw- weinberger
2012-08-06 10:21 ` [linux-pm] " Pavel Machek
2012-08-06 14:36 ` Alan Stern
2012-08-06 16:00 ` [linux-pm] " Pavel Vasilyev
2012-08-06 16:28 ` Alan Stern
2012-08-06 18:47 ` [linux-pm] " Pavel Vasilyev
2012-08-06 19:59 ` Alan Stern
2012-08-06 22:57 ` [linux-pm] " Daniel Taylor
2012-08-07 13:19 ` Bernd Petrovitsch
2012-08-08 0:59 ` [linux-pm] " Daniel Taylor
2012-08-07 1:07 ` Pavel Vasilyev
2012-08-07 17:24 ` Alan Stern
2012-08-07 23:23 ` Pavel Vasilyev [this message]
2012-08-08 1:27 ` [linux-pm] " Alan Stern
2012-08-06 10:26 ` Andreas Schwab
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=5021A372.8030409@pavlinux.ru \
--to=pavel@pavlinux.ru \
--cc=len.brown@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=pavel@ucw.cz \
--cc=stern@rowland.harvard.edu \
/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).