Skip to contentSkip to conversation

qxl/update_area_io: cleanup invalid parameters handling

PATCH In review Michael Tokarev 2 participants 4 messages Sep 19, 2012 – Sep 20, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qxl/update_area_io: cleanup invalid parameters handling

This cleans up two additions of almost the same code in commits 511b13e2c9 and ccc2960d654. While at it, make error paths consistent (always use 'break' instead of 'return').

Cc Dunrong Huang <[email protected]>
Cc Alon Levy <[email protected]>
---
 hw/qxl.c |   13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
hw/qxl.c +3 -10
index 33169f3..3c82c2a 100644
@@ -1547,20 +1547,13 @@ async_common:
         if (d->ram->update_surface > d->ssd.num_surfaces) {
             qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: invalid surface id %d\n",
                               d->ram->update_surface);
-            return;
+            break;
         }
-        if (update.left >= update.right || update.top >= update.bottom) {
+        if (update.left >= update.right || update.top >= update.bottom ||
+            update.left < 0 || update.top < 0) {
             qxl_set_guest_bug(d,
                     "QXL_IO_UPDATE_AREA: invalid area (%ux%u)x(%ux%u)\n",
                     update.left, update.top, update.right, update.bottom);
-            return;
-        }
-
-        if (update.left < 0 || update.top < 0 || update.left >= update.right ||
-            update.top >= update.bottom) {
-            qxl_set_guest_bug(d, "QXL_IO_UPDATE_AREA: "
-                              "invalid area(%d,%d,%d,%d)\n", update.left,
-                              update.right, update.top, update.bottom);
             break;
         }
         if (async == QXL_ASYNC) {
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 3 lines · Michael Tokarev

This cleans up two additions of almost the same code in commits 511b13e2c9 and ccc2960d654. While at it, make error paths consistent (always use 'break' instead of 'return').

Other way around: should be 'return' not 'break'.

cheers,
Gerd

#2 lore raw
Quoted 6 lines · Gerd Hoffmann
Quoted 3 lines · Michael Tokarev

This cleans up two additions of almost the same code in commits 511b13e2c9 and ccc2960d654. While at it, make error paths consistent (always use 'break' instead of 'return').

Other way around: should be 'return' not 'break'.

In other, early-added, error-return places it is "break".

For now it is irrelevant actually, since right after the switch we already have "return", so "break" is now the same as "return". For future it might not be the case.

/mjt

#3 lore raw
Quoted 3 lines · Michael Tokarev

For now it is irrelevant actually, since right after the switch we already have "return", so "break" is now the same as "return". For future it might not be the case.

Oh, right. Patch added to spice patch queue.

thanks,
Gerd