qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Cc: mst@redhat.com
Subject: [Qemu-devel] [PATCH] Move filedescriptor parsing code from net.c into qemu_parse_fd()
Date: Tue, 27 Sep 2011 12:02:07 -0400	[thread overview]
Message-ID: <1317139327.12988.2.camel@d941e-10> (raw)

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

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

---
 net.c       |    8 ++------
 qemu-char.c |   12 ++++++++++++
 qemu-char.h |    2 ++
 3 files changed, 16 insertions(+), 6 deletions(-)

Index: qemu-git.pt/net.c
===================================================================
--- qemu-git.pt.orig/net.c
+++ 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;
Index: qemu-git.pt/qemu-char.c
===================================================================
--- qemu-git.pt.orig/qemu-char.c
+++ 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;
+}
Index: qemu-git.pt/qemu-char.h
===================================================================
--- qemu-git.pt.orig/qemu-char.h
+++ 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

             reply	other threads:[~2011-09-27 16:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-27 16:02 Stefan Berger [this message]
2011-09-28  8:36 ` [Qemu-devel] [PATCH] Move filedescriptor parsing code from net.c into qemu_parse_fd() Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1317139327.12988.2.camel@d941e-10 \
    --to=stefanb@linux.vnet.ibm.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).