Re: code style in the vfs



Hello Pavel,

On Sun, 2004-09-26 at 10:30, Pavel Tsekov wrote:
> > char *dirname (const char *path)
> > {
> >      char *slash = strrchr (path, '/');
> >      if (slash)
> >          *slash = '\0';
> >      return path;
> > }
> >
> > No compiler could ever warn you about this "const-away" cast, and if you
> > pass a string literal to it, the behaviour is undefined.
> 
> I know that the compiler won't detect it.

Actually it does (for this particular piece of code). Without a cast on
the return value that code *does* produce a warning (return discards
qualifiers from pointer target type).

Leonard.

-- 
mount -t life -o ro /dev/dna /genetic/research





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]