Re: [patch] fix a few little buglets in mutt HEAD
On Friday, 05 December 2008 at 02:31, Vincent Lefevre wrote:
> On 2008-12-04 12:21:33 -0800, Erik Hovland wrote:
> > 4. Since getc returns int, the variable that stores it should be that type.
> >
> > If the variable that stores the return value of getc is smaller then
> > int (like a char in this case) then the return value is truncated.
>
> This can be even implementation-defined or undefined behavior.
>
> BTW, shouldn't Mutt check for EOF (which can occur either because
> of end of file or because of error)?
yes, but it looks like properly propagating that error would be a
little annoying.
> > diff --git a/hash.c b/hash.c
> > --- a/hash.c
> > +++ b/hash.c
> > @@ -39,7 +39,6 @@ int hash_string (const unsigned char *s,
> > while (*s)
> > h += (h << 7) + *s++;
> > h = (h * SOMEPRIME) % n;
> > - h = (h >= 0) ? h : h + n;
> > #endif
> >
> > return (signed) (h % n);
>
> Since h is the result of some value % n, then the % n in the return
> statement is useless.
I've dropped that bit too.