diff mbox series

[RFC,10/14] monitor/hmp: Explicit we ignore a QEMUChrEvent in IOEventHandler

Message ID 20191217163808.20068-11-philmd@redhat.com (mailing list archive)
State New, archived
Headers show
Series chardev: Use QEMUChrEvent enum in IOEventHandler typedef | expand

Commit Message

Philippe Mathieu-Daudé Dec. 17, 2019, 4:38 p.m. UTC
The Chardev events are listed in the QEMUChrEvent enum. To be
able to use this enum in the IOEventHandler typedef, we need to
explicit when frontends ignore some events, to silent GCC the
following warnings:

    CC      monitor/hmp.o
  monitor/hmp.c: In function ‘monitor_event’:
  monitor/hmp.c:1330:5: error: enumeration value ‘CHR_EVENT_BREAK’ not handled in switch [-Werror=switch]
   1330 |     switch (event) {
        |     ^~~~~~
  cc1: all warnings being treated as errors

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
---
 monitor/hmp.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Dr. David Alan Gilbert Dec. 17, 2019, 5:37 p.m. UTC | #1
* Philippe Mathieu-Daudé (philmd@redhat.com) wrote:
> The Chardev events are listed in the QEMUChrEvent enum. To be
> able to use this enum in the IOEventHandler typedef, we need to
> explicit when frontends ignore some events, to silent GCC the
> following warnings:
> 
>     CC      monitor/hmp.o
>   monitor/hmp.c: In function ‘monitor_event’:
>   monitor/hmp.c:1330:5: error: enumeration value ‘CHR_EVENT_BREAK’ not handled in switch [-Werror=switch]
>    1330 |     switch (event) {
>         |     ^~~~~~
>   cc1: all warnings being treated as errors
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---


Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
  for HMP

Note that the use of 'default' will make life more unpredictable
if you ever come to add a new event type.

Dave


> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> ---
>  monitor/hmp.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/monitor/hmp.c b/monitor/hmp.c
> index 8942e28933..d84238c120 100644
> --- a/monitor/hmp.c
> +++ b/monitor/hmp.c
> @@ -1371,6 +1371,10 @@ static void monitor_event(void *opaque, int event)
>          mon_refcount--;
>          monitor_fdsets_cleanup();
>          break;
> +
> +    default:
> +        /* Ignore */
> +        break;
>      }
>  }
>  
> -- 
> 2.21.0
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
Philippe Mathieu-Daudé Dec. 17, 2019, 5:46 p.m. UTC | #2
On 12/17/19 6:37 PM, Dr. David Alan Gilbert wrote:
> * Philippe Mathieu-Daudé (philmd@redhat.com) wrote:
>> The Chardev events are listed in the QEMUChrEvent enum. To be
>> able to use this enum in the IOEventHandler typedef, we need to
>> explicit when frontends ignore some events, to silent GCC the
>> following warnings:
>>
>>      CC      monitor/hmp.o
>>    monitor/hmp.c: In function ‘monitor_event’:
>>    monitor/hmp.c:1330:5: error: enumeration value ‘CHR_EVENT_BREAK’ not handled in switch [-Werror=switch]
>>     1330 |     switch (event) {
>>          |     ^~~~~~
>>    cc1: all warnings being treated as errors
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
> 
> 
> Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
>    for HMP
> 
> Note that the use of 'default' will make life more unpredictable
> if you ever come to add a new event type.

You are right, this patch not good as it dumbly ignore the warning...
I will add all the missing cases:

-- >8 --
@@ -1371,6 +1371,10 @@ static void monitor_event(void *opaque, int event)
          mon_refcount--;
          monitor_fdsets_cleanup();
          break;
+
+    case CHR_EVENT_BREAK:
+        /* Ignored */
+        break;
      }
  }

---

And keep your Acked-by. Thanks!

>> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>> ---
>>   monitor/hmp.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/monitor/hmp.c b/monitor/hmp.c
>> index 8942e28933..d84238c120 100644
>> --- a/monitor/hmp.c
>> +++ b/monitor/hmp.c
>> @@ -1371,6 +1371,10 @@ static void monitor_event(void *opaque, int event)
>>           mon_refcount--;
>>           monitor_fdsets_cleanup();
>>           break;
>> +
>> +    default:
>> +        /* Ignore */
>> +        break;
>>       }
>>   }
>>   
>> -- 
>> 2.21.0
>>
> --
> Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
>
Dr. David Alan Gilbert Dec. 17, 2019, 5:51 p.m. UTC | #3
* Philippe Mathieu-Daudé (philmd@redhat.com) wrote:
> On 12/17/19 6:37 PM, Dr. David Alan Gilbert wrote:
> > * Philippe Mathieu-Daudé (philmd@redhat.com) wrote:
> > > The Chardev events are listed in the QEMUChrEvent enum. To be
> > > able to use this enum in the IOEventHandler typedef, we need to
> > > explicit when frontends ignore some events, to silent GCC the
> > > following warnings:
> > > 
> > >      CC      monitor/hmp.o
> > >    monitor/hmp.c: In function ‘monitor_event’:
> > >    monitor/hmp.c:1330:5: error: enumeration value ‘CHR_EVENT_BREAK’ not handled in switch [-Werror=switch]
> > >     1330 |     switch (event) {
> > >          |     ^~~~~~
> > >    cc1: all warnings being treated as errors
> > > 
> > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> > > ---
> > 
> > 
> > Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> >    for HMP
> > 
> > Note that the use of 'default' will make life more unpredictable
> > if you ever come to add a new event type.
> 
> You are right, this patch not good as it dumbly ignore the warning...
> I will add all the missing cases:
> 
> -- >8 --
> @@ -1371,6 +1371,10 @@ static void monitor_event(void *opaque, int event)
>          mon_refcount--;
>          monitor_fdsets_cleanup();
>          break;
> +
> +    case CHR_EVENT_BREAK:
> +        /* Ignored */
> +        break;
>      }
>  }
> 
> ---
> 
> And keep your Acked-by. Thanks!

Acked-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> 
> > > Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> > > ---
> > >   monitor/hmp.c | 4 ++++
> > >   1 file changed, 4 insertions(+)
> > > 
> > > diff --git a/monitor/hmp.c b/monitor/hmp.c
> > > index 8942e28933..d84238c120 100644
> > > --- a/monitor/hmp.c
> > > +++ b/monitor/hmp.c
> > > @@ -1371,6 +1371,10 @@ static void monitor_event(void *opaque, int event)
> > >           mon_refcount--;
> > >           monitor_fdsets_cleanup();
> > >           break;
> > > +
> > > +    default:
> > > +        /* Ignore */
> > > +        break;
> > >       }
> > >   }
> > > -- 
> > > 2.21.0
> > > 
> > --
> > Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
> > 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
diff mbox series

Patch

diff --git a/monitor/hmp.c b/monitor/hmp.c
index 8942e28933..d84238c120 100644
--- a/monitor/hmp.c
+++ b/monitor/hmp.c
@@ -1371,6 +1371,10 @@  static void monitor_event(void *opaque, int event)
         mon_refcount--;
         monitor_fdsets_cleanup();
         break;
+
+    default:
+        /* Ignore */
+        break;
     }
 }