Re: warnings in 2.1.90 using pgcs

David Burrows (snadge@gemcorp.com.au)
Fri, 20 Mar 1998 16:30:40 +1000 (EST)


On Fri, 20 Mar 1998, Michael L. Galbraith wrote:

> On Thu, 19 Mar 1998, Christopher W. Fisher wrote:
>
> >
> > in file included from /usr/src/linux/include/linux/string.h:39,
> > from ide-disk.c:30:
> > /usr/src/linux/include/asm/string.h:448: warning: control reaches end of
> > non-void function
> > /usr/src/linux/include/asm/string.h: In function
> > `__constant_c_and_count_memset':
> > /usr/src/linux/include/asm/string.h:599: warning: control reaches end of
> > non-void function
> >
> > I am getting this warning in almost every source file.
> >
>
> Hello Christopher,
>
> I'm using this to get it to shut up.. OOGLY, but silently produces
> assembler identical to the original. The problem is that gcc doesn't
> know that all cases are covered, so it warns about a possibly undesired
> fall-through.. goodthing(tm) but darned annoying.
>
> -Mike
>
> extern inline void * __constant_c_and_count_memset(void * s, unsigned long pattern, size_t count)
> {
> switch (count) {
> case 0:
> goto return_s;
> case 1:
> *(unsigned char *)s = pattern;
> goto return_s;
>
> ...
>
> switch (count % 4) {
> case 0: COMMON(""); goto return_s;
> case 1: COMMON("\n\tstosb"); goto return_s;
>
> ...
>
> return_s:
> return s;
> }

This looks rather silly to me.. My solution was to replace "case 3:" with
"default:".. If you think about it, it makes sense.. If its not 0, or 1,
or 2 then it HAS to be 3, so making it the default case will satisfy egcs
that something is ALWAYS returned regardless..

Just my 0.02 worth.. :)

Cheers,

Dave.

PS.. making it the default case is actually faster than the original code,
it doesn't have to check whether its 3, it just assumes it (and quite
rightly so)..

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu