Re: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-07 Thread Alan Stern
On Wed, 8 Aug 2012, Pavel Vasilyev wrote: > >>> 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 "a

RE: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-07 Thread Daniel Taylor
zeof(string); Learned something. Thanks, Dan > -Original Message- > From: Bernd Petrovitsch [mailto:be...@petrovitsch.priv.at] > Sent: Tuesday, August 07, 2012 6:20 AM > To: Daniel Taylor > Cc: 'Alan Stern'; Pavel Vasilyev; Pavel Machek; Len Brown; > li

Re: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-07 Thread Pavel Vasilyev
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

Re: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-07 Thread 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 a

RE: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-07 Thread Bernd Petrovitsch
On Mon, 2012-08-06 at 22:57 +, Daniel Taylor wrote: > Silly question: when did sizeof("string") get changed to be anything > other than the size of the pointer ("string" is, after all, an array > of characters)? It is since K&R times that way. If you do not know the difference between a poin

Re: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-06 Thread Pavel Vasilyev
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

RE: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-06 Thread Daniel Taylor
kernel.org] On Behalf Of Alan Stern > Sent: Monday, August 06, 2012 1:00 PM > To: Pavel Vasilyev > Cc: Pavel Machek; Len Brown; linux-a...@vger.kernel.org; > linux...@lists.linux-foundation.org; > linux-kernel@vger.kernel.org; Len Brown > Subject: Re: [linux-pm] [PATCH] ACPI: repla

Re: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-06 Thread 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

Re: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-06 Thread Pavel Vasilyev
06.08.2012 20:28, Alan Stern пишет: On Mon, 6 Aug 2012, Pavel Vasilyev wrote: 06.08.2012 18:36, Alan Stern пишет: On Mon, 6 Aug 2012, Pavel Machek wrote: On Thu 2012-07-26 21:39:38, Len Brown wrote: ...both give the number of chars in the string without the '\0', as strncmp() wants, but siz

Re: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-06 Thread Alan Stern
On Mon, 6 Aug 2012, Pavel Vasilyev wrote: > 06.08.2012 18:36, Alan Stern пишет: > > On Mon, 6 Aug 2012, Pavel Machek wrote: > > > >> On Thu 2012-07-26 21:39:38, Len Brown wrote: > >>> ...both give the number of chars in the string > >>> without the '\0', as strncmp() wants, > >>> but sizeof() is c

Re: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-06 Thread Pavel Vasilyev
06.08.2012 18:36, Alan Stern пишет: On Mon, 6 Aug 2012, Pavel Machek wrote: On Thu 2012-07-26 21:39:38, Len Brown wrote: ...both give the number of chars in the string without the '\0', as strncmp() wants, but sizeof() is compile-time. What about introducing something like streq() to do this

Re: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-06 Thread Alan Stern
On Mon, 6 Aug 2012, Pavel Machek wrote: > On Thu 2012-07-26 21:39:38, Len Brown wrote: > > ...both give the number of chars in the string > > without the '\0', as strncmp() wants, > > but sizeof() is compile-time. > > What about introducing something like streq() to do this > automatically? This

Re: [linux-pm] [PATCH] ACPI: replace strlen("string") with sizeof("string") -1

2012-08-06 Thread Pavel Machek
On Thu 2012-07-26 21:39:38, Len Brown wrote: > ...both give the number of chars in the string > without the '\0', as strncmp() wants, > but sizeof() is compile-time. What about introducing something like streq() to do this automatically? This is ugly #define streq(a, b) ... if (_buildin_const