lkml.org 
[lkml]   [1998]   [Jan]   [22]   [last100]   RSS Feed
Views: [more markup]  [less markup]  [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: 2.1.80 miscellanea
FromJames A <>
Date22 Jan 1998 12:20:39 +0000
Jim Bourne <jbourne@island.net> writes:

> On Wed, 21 Jan 1998, Michael Elizabeth Chastain wrote:
> 
> > The new code fails to null-terminate the strings if the strings
> > are too long (this is better than the old code though!)  I think
> > you need these lines:
> > 
> > 	info.id[sizeof(info.id)-1] = '\0';
> > 
> > 	indo.name[sizeof(info.name)-1] = '\0';
> 
> Hi,
> Correct me if I'm wrong, but what if the size of a char is *not* one byte as
> Linux is ported to more hardware platforms then any other OS that I know of. 
> 
> Should these not be
> 	...
> 	info.id[(sizeof(info.id)-1) * sizeof(char)] = '\0';
> 	...
> 
> Just thought it might be more portable this way.

 sizeof is guaranteed to return its size relative to the size of a
char, Ie. sizeof(char) == 1 __must__ be true.

-- 
James Antill

\
 
 \ /
  Last update: 2005-03-22 12:41    [from the cache]
©2003-2008