diff options
author | Stefan Berger <stefanb@linux.vnet.ibm.com> | 2011-09-28 06:41:32 -0400 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2011-11-01 16:52:08 -0500 |
commit | 443916d1d9f1094a43d28c6b8cc60e3e7e27eb36 (patch) | |
tree | 960cdab08620defed8855e9d8101418fc78b03c6 /cutils.c | |
parent | f809c0d66bf1d9a8a4282b5a089b7eead45428fc (diff) | |
download | qemu-443916d1d9f1094a43d28c6b8cc60e3e7e27eb36.zip qemu-443916d1d9f1094a43d28c6b8cc60e3e7e27eb36.tar.gz qemu-443916d1d9f1094a43d28c6b8cc60e3e7e27eb36.tar.bz2 |
Move filedescriptor parsing code from net.c into qemu_parse_fd()
Move the parsing of a filedescriptor into a common function
qemu_parse_fd() so others can use it as well. Have net.c call this
function.
v2:
- moving qemu_parse_fd into cutils.c
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'cutils.c')
-rw-r--r-- | cutils.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -415,3 +415,15 @@ int64_t strtosz(const char *nptr, char **end) { return strtosz_suffix(nptr, end, STRTOSZ_DEFSUFFIX_MB); } + +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; +} |