Skip to contentSkip to conversation

Move filedescriptor parsing code from net.c into qemu_parse_fd()

PATCH Superseded Stefan Berger 2 participants 2 messages Sep 27, 2011 – Sep 28, 2011

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Move filedescriptor parsing code from net.c into qemu_parse_fd()

Move the parsing of a filedescriptor into a common function qemu_parse_fd(). Have the code in net.c call this function.

---
 net.c       |    8 ++------
 qemu-char.c |   12 ++++++++++++
 qemu-char.h |    2 ++
 3 files changed, 16 insertions(+), 6 deletions(-)
net.c +2 -6
Index: qemu-git.pt/net.c
===================================================================
@@ -36,6 +36,7 @@
 #include "qemu_socket.h"
 #include "hw/qdev.h"
 #include "iov.h"
+#include "qemu-char.h"
 
 static QTAILQ_HEAD(, VLANState) vlans;
 static QTAILQ_HEAD(, VLANClientState) non_vlan_clients;
@@ -733,12 +734,7 @@ int net_handle_fd_param(Monitor *mon, co
             return -1;
         }
     } else {
-        char *endptr = NULL;
-
-        fd = strtol(param, &endptr, 10);
-        if (*endptr || (fd == 0 && param == endptr)) {
-            return -1;
-        }
+        fd = qemu_parse_fd(param);
     }
 
     return fd;
qemu-char.c +12 -0
Index: qemu-git.pt/qemu-char.c
===================================================================
@@ -2692,3 +2692,15 @@ CharDriverState *qemu_chr_find(const cha
     }
     return NULL;
 }
+
+int qemu_parse_fd(const char *param)
+{
+    int fd;
+    char *endptr = NULL;
+
+    fd = strtol(param, &endptr, 10);
+    if (*endptr || (fd == 0 && param == endptr)) {
+        return -1;
+    }
+    return fd;
+}
qemu-char.h +2 -0
Index: qemu-git.pt/qemu-char.h
===================================================================
@@ -248,4 +248,6 @@ int qemu_set_fd_handler(int fd,
                         IOHandler *fd_read,
                         IOHandler *fd_write,
                         void *opaque);
+
+int qemu_parse_fd(const char *param);
 #endif
#1 lore raw
Quoted 10 lines · Stefan Berger

Move the parsing of a filedescriptor into a common function qemu_parse_fd(). Have the code in net.c call this function.

---
 net.c       |    8 ++------
 qemu-char.c |   12 ++++++++++++
 qemu-char.h |    2 ++

 3 files changed, 16 insertions(+), 6 deletions(-)

Seems fine but what does this have to do with qemu-char.h? Can this be a much more generic function, maybe even cutils.c?

Stefan