qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] vl.c: move "if (fd < 0)" into "if (fd <= STDERR_FIL


From: Chen Gang
Subject: [Qemu-devel] [PATCH] vl.c: move "if (fd < 0)" into "if (fd <= STDERR_FILENO)"
Date: Sat, 28 Dec 2013 16:52:45 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7

For valid 'fd' (in most cases), it is enough to only check whether it
is larger than STDERR_FILENO, so recommend to move "if (fd < 0)" into
failure processing block.

Signed-off-by: Chen Gang <address@hidden>
---
 vl.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/vl.c b/vl.c
index 2160933..fbea535 100644
--- a/vl.c
+++ b/vl.c
@@ -1064,15 +1064,10 @@ static int parse_add_fd(QemuOpts *opts, void *opaque)
     fdset_id = qemu_opt_get_number(opts, "set", -1);
     fd_opaque = qemu_opt_get(opts, "opaque");
 
-    if (fd < 0) {
-        qerror_report(ERROR_CLASS_GENERIC_ERROR,
-                      "fd option is required and must be non-negative");
-        return -1;
-    }
-
     if (fd <= STDERR_FILENO) {
         qerror_report(ERROR_CLASS_GENERIC_ERROR,
-                      "fd cannot be a standard I/O stream");
+                      fd < 0 ? "fd option is required and must be non-negative"
+                             : "fd cannot be a standard I/O stream");
         return -1;
     }
 
-- 
1.7.11.7



reply via email to

[Prev in Thread] Current Thread [Next in Thread]