diff options
-rw-r--r-- | cutils.c | 12 | ||||
-rw-r--r-- | net.c | 7 | ||||
-rw-r--r-- | qemu-common.h | 1 |
3 files changed, 14 insertions, 6 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; +} @@ -733,12 +733,7 @@ int net_handle_fd_param(Monitor *mon, const char *param) 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; diff --git a/qemu-common.h b/qemu-common.h index 1c15cb1..2ce47aa 100644 --- a/qemu-common.h +++ b/qemu-common.h @@ -129,6 +129,7 @@ time_t mktimegm(struct tm *tm); int qemu_fls(int i); int qemu_fdatasync(int fd); int fcntl_setfl(int fd, int flag); +int qemu_parse_fd(const char *param); /* * strtosz() suffixes used to specify the default treatment of an |