diff mbox

[RFC,1/8] ui/vnc-enc-tight: add abort() for unexpected default

Message ID 20160919155139.28371-2-alex.bennee@linaro.org
State New
Headers show

Commit Message

Alex Bennée Sept. 19, 2016, 3:51 p.m. UTC
When enabling the sanitizer build it will complain about control
reaching a non-void function. Normally the compiler should detect that
there is only one possible exit given a static VNC_SERVER_FB_BYTES.

As we should never get here I added an abort() rather than a default
return value.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
 ui/vnc-enc-tight.c | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.9.3

Comments

Alex Bennée Sept. 20, 2016, 2:59 p.m. UTC | #1
Paolo Bonzini <pbonzini@redhat.com> writes:

> On 20/09/2016 10:02, Marc-André Lureau wrote:

>> Hi

>>

>> On Mon, Sep 19, 2016 at 7:58 PM Alex Bennée <alex.bennee@linaro.org

>> <mailto:alex.bennee@linaro.org>> wrote:

>>

>>     When enabling the sanitizer build it will complain about control

>>     reaching a non-void function. Normally the compiler should detect that

>>     there is only one possible exit given a static VNC_SERVER_FB_BYTES.

>>

>>     As we should never get here I added an abort() rather than a default

>>     return value.

>>

>>     Signed-off-by: Alex Bennée <alex.bennee@linaro.org

>>     <mailto:alex.bennee@linaro.org>>

>>     ---

>>      ui/vnc-enc-tight.c | 2 ++

>>      1 file changed, 2 insertions(+)

>>

>>     diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c

>>     index 49df85e..9e4d254 100644

>>     --- a/ui/vnc-enc-tight.c

>>     +++ b/ui/vnc-enc-tight.c

>>     @@ -710,6 +710,8 @@ static bool check_solid_tile(VncState *vs, int

>>     x, int y, int w, int h,

>>          switch (VNC_SERVER_FB_BYTES) {

>>          case 4:

>>              return check_solid_tile32(vs, x, y, w, h, color, samecolor);

>>     +    default:

>>     +        abort();

>>          }

>>      }

>>

>>

>>

>> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com

>> <mailto:marcandre.lureau@redhat.com>>

>>

>> Looks fine. Would it make sense to use a

>> G_STATIC_ASSERT(VNC_SERVER_FB_BYTES == 4) above instead?

>

> Or QEMU_BUILD_BUG_ON(VNC_SERVER_FB_BYTES != 4) :)


I'll do that!

>

> Paolo

>

>> --

>> Marc-André Lureau



--
Alex Bennée
diff mbox

Patch

diff --git a/ui/vnc-enc-tight.c b/ui/vnc-enc-tight.c
index 49df85e..9e4d254 100644
--- a/ui/vnc-enc-tight.c
+++ b/ui/vnc-enc-tight.c
@@ -710,6 +710,8 @@  static bool check_solid_tile(VncState *vs, int x, int y, int w, int h,
     switch (VNC_SERVER_FB_BYTES) {
     case 4:
         return check_solid_tile32(vs, x, y, w, h, color, samecolor);
+    default:
+        abort();
     }
 }