From 443916d1d9f1094a43d28c6b8cc60e3e7e27eb36 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Wed, 28 Sep 2011 06:41:32 -0400 Subject: 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 Signed-off-by: Anthony Liguori --- cutils.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'cutils.c') diff --git a/cutils.c b/cutils.c index c91f887..5d995bc 100644 --- a/cutils.c +++ b/cutils.c @@ -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; +} -- cgit v1.1