qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH] tap-linux: report an error for invalid sndbuf


From: Amos Kong
Subject: [Qemu-devel] [PATCH] tap-linux: report an error for invalid sndbuf
Date: Sun, 27 Apr 2014 22:09:10 +0800

We use default sndbuf (INT_MAX) if user assigns an invalid sndbuf.
This patch just added an error note.

Signed-off-by: Amos Kong <address@hidden>
---
 net/tap-linux.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/net/tap-linux.c b/net/tap-linux.c
index 812bf2d..fc0cc0d 100644
--- a/net/tap-linux.c
+++ b/net/tap-linux.c
@@ -130,9 +130,16 @@ int tap_set_sndbuf(int fd, const NetdevTapOptions *tap)
 {
     int sndbuf;
 
-    sndbuf = !tap->has_sndbuf       ? TAP_DEFAULT_SNDBUF :
-             tap->sndbuf > INT_MAX  ? INT_MAX :
-             tap->sndbuf;
+    if (!tap->has_sndbuf) {
+        sndbuf = TAP_DEFAULT_SNDBUF;
+    } else if (tap->sndbuf > INT_MAX) {
+        sndbuf = TAP_DEFAULT_SNDBUF;
+        error_report("given sndbuf isn't an integer, "
+                     "or it's larger than INT_MAX(%d). "
+                     "use default sndbuf(%d)", INT_MAX, INT_MAX);
+    } else {
+        sndbuf = tap->sndbuf;
+    }
 
     if (!sndbuf) {
         sndbuf = INT_MAX;
-- 
1.9.0




reply via email to

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