Ethereal-dev: RE: [Ethereal-dev] Re: [Ethereal-cvs] rev 13293: /trunk/gtk/: main.cprint_dlg.c

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: "Peter Kjellerstedt" <peter.kjellerstedt@xxxxxxxx>
Date: Sat, 5 Feb 2005 10:02:21 +0100
> -----Original Message-----
> From: ethereal-dev-bounces@xxxxxxxxxxxx 
> [mailto:ethereal-dev-bounces@xxxxxxxxxxxx] On Behalf Of Guy Harris
> Sent: Saturday, February 05, 2005 09:14
> To: Ethereal development
> Subject: Re: [Ethereal-dev] Re: [Ethereal-cvs] rev 13293: 
> /trunk/gtk/: main.cprint_dlg.c /trunk/: file.c file.h tethereal.c
> 
> Ulf Lamping wrote:
> 
> >> that
> >> way you don't get compiler warnings if a case statement 
> >> isn't handling a particular status value if the routine 
> >> in question won't return it.
> >>  
> >>
> > Which compiler warning would that be? Sorry, I just don't 
> > understand that one.
> 
> This one:
> 
> $ cat foo.c
> enum foo {
>          ONE,
>          TWO,
>          THREE
> };
> 
> int
> bar(enum foo a)
> {
>          switch (a) {
> 
>          case ONE:
>                  return 1;
> 
>          case TWO:
>                  return 2;
>          }
> 
>          return 17;
> }
> $ gcc -c -O2 -Wall -W foo.c
> foo.c: In function `bar':
> foo.c:17: warning: enumeration value `THREE' not handled in switch

Well, you could add something like this to the end of the switch:

	default:
		g_assert(0 && "We should never get here");
		break;

//Peter