qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qxl/update_area_io: cleanup invalid parameters handling
@ 2012-09-19 13:41 Michael Tokarev
  2012-09-20  6:41 ` Gerd Hoffmann
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Tokarev @ 2012-09-19 13:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Alon Levy, Michael Tokarev, Gerd Hoffmann, Dunrong Huang

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').

Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Cc: Dunrong Huang <riegamaths@gmail.com>
Cc: Alon Levy <alevy@redhat.com>
---
 hw/qxl.c |   13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/hw/qxl.c b/hw/qxl.c
index 33169f3..3c82c2a 100644
--- a/hw/qxl.c
+++ b/hw/qxl.c
@@ -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) {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] qxl/update_area_io: cleanup invalid parameters handling
  2012-09-19 13:41 [Qemu-devel] [PATCH] qxl/update_area_io: cleanup invalid parameters handling Michael Tokarev
@ 2012-09-20  6:41 ` Gerd Hoffmann
  2012-09-20  6:43   ` Michael Tokarev
  0 siblings, 1 reply; 4+ messages in thread
From: Gerd Hoffmann @ 2012-09-20  6:41 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: Alon Levy, qemu-devel, Dunrong Huang

On 09/19/12 15:41, Michael Tokarev wrote:
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] qxl/update_area_io: cleanup invalid parameters handling
  2012-09-20  6:41 ` Gerd Hoffmann
@ 2012-09-20  6:43   ` Michael Tokarev
  2012-09-20  6:50     ` Gerd Hoffmann
  0 siblings, 1 reply; 4+ messages in thread
From: Michael Tokarev @ 2012-09-20  6:43 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Alon Levy, qemu-devel, Dunrong Huang

On 20.09.2012 10:41, Gerd Hoffmann wrote:
> On 09/19/12 15:41, Michael Tokarev wrote:
>> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] qxl/update_area_io: cleanup invalid parameters handling
  2012-09-20  6:43   ` Michael Tokarev
@ 2012-09-20  6:50     ` Gerd Hoffmann
  0 siblings, 0 replies; 4+ messages in thread
From: Gerd Hoffmann @ 2012-09-20  6:50 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: Alon Levy, qemu-devel, Dunrong Huang

On 09/20/12 08:43, Michael Tokarev wrote:
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-09-20  6:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-19 13:41 [Qemu-devel] [PATCH] qxl/update_area_io: cleanup invalid parameters handling Michael Tokarev
2012-09-20  6:41 ` Gerd Hoffmann
2012-09-20  6:43   ` Michael Tokarev
2012-09-20  6:50     ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).