[Libguestfs] [PATCH libguestfs 6/8] suppress a warning from -Wswitch-default

Jim Meyering jim at meyering.net
Tue Aug 18 15:30:47 UTC 2009


Richard W.M. Jones wrote:

> On Tue, Aug 18, 2009 at 03:49:43PM +0200, Jim Meyering wrote:
>> From: Jim Meyering <meyering at redhat.com>
>>
>> * src/guestfs.c (guestfs_end_busy): Add a "default:" label.
>> ---
>>  src/guestfs.c |    2 ++
>>  1 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/guestfs.c b/src/guestfs.c
>> index 0c007d2..8491205 100644
>> --- a/src/guestfs.c
>> +++ b/src/guestfs.c
>> @@ -1628,8 +1628,10 @@ guestfs_end_busy (guestfs_h *g)
>>      case CONFIG:
>>      case READY:
>>        break;
>> +
>>      case LAUNCHING:
>>      case NO_HANDLE:
>> +    default:
>>        error (g, _("guestfs_end_busy: called when in state %d"), g->state);
>>        return -1;
>>      }
>> --
>> 1.6.4.378.g88f2f
>
> I thought switch would catch that it's an enum?  Anyway ACK.

In C, there's no hard restriction that the value is one of
the enumerated ones, and few compilers will complain if you
associate an out-of-range value with an enum variable.
So in a way, the default: label is required.




More information about the Libguestfs mailing list