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>
This commit is contained in:
parent
f809c0d66b
commit
443916d1d9
12
cutils.c
12
cutils.c
@ -415,3 +415,15 @@ int64_t strtosz(const char *nptr, char **end)
|
|||||||
{
|
{
|
||||||
return strtosz_suffix(nptr, end, STRTOSZ_DEFSUFFIX_MB);
|
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;
|
||||||
|
}
|
||||||
|
7
net.c
7
net.c
@ -733,12 +733,7 @@ int net_handle_fd_param(Monitor *mon, const char *param)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
char *endptr = NULL;
|
fd = qemu_parse_fd(param);
|
||||||
|
|
||||||
fd = strtol(param, &endptr, 10);
|
|
||||||
if (*endptr || (fd == 0 && param == endptr)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return fd;
|
return fd;
|
||||||
|
@ -129,6 +129,7 @@ time_t mktimegm(struct tm *tm);
|
|||||||
int qemu_fls(int i);
|
int qemu_fls(int i);
|
||||||
int qemu_fdatasync(int fd);
|
int qemu_fdatasync(int fd);
|
||||||
int fcntl_setfl(int fd, int flag);
|
int fcntl_setfl(int fd, int flag);
|
||||||
|
int qemu_parse_fd(const char *param);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* strtosz() suffixes used to specify the default treatment of an
|
* strtosz() suffixes used to specify the default treatment of an
|
||||||
|
Loading…
Reference in New Issue
Block a user