* src/internal.h: move xstrol() variants from here ...
* src/util.[ch]: ... to here and rename to virStrToLong()
* src/libvirt_sym.version: export __virStrToLong_i() for
virsh and qemud.
* src/nodeinfo.c, src/stats_linux.c, src/virsh.c,
src/xend_internal.c, qemud/qemud.c: replace xstrtol()
calls with virStrToLong()
* src/nodeinfo.h: don't include internal.h, which was only
needed for xstrtol(), but instead include libvirt.h which
is suffificient for the declarations in the header.
+Thu Feb 7 09:10:18 IST 2008 Mark McLoughlin <markmc@redhat.com>
+
+ Fix gcc-4.3.0 "inlining failed" warning.
+
+ * src/internal.h: move xstrol() variants from here ...
+
+ * src/util.[ch]: ... to here and rename to virStrToLong()
+
+ * src/libvirt_sym.version: export __virStrToLong_i() for
+ virsh and qemud.
+
+ * src/nodeinfo.c, src/stats_linux.c, src/virsh.c,
+ src/xend_internal.c, qemud/qemud.c: replace xstrtol()
+ calls with virStrToLong()
+
+ * src/nodeinfo.h: don't include internal.h, which was only
+ needed for xstrtol(), but instead include libvirt.h which
+ is suffificient for the declarations in the header.
+
Thu Feb 7 20:19:19 CET 2008 Jim Meyering <meyering@redhat.com>
Enable another syntax-check rule.
#include "internal.h"
#include "getaddrinfo.h"
-#include "../src/internal.h"
+#include "../src/util.h"
#include "../src/remote_internal.h"
#include "../src/conf.h"
#include "event.h"
GET_CONF_STR (conf, filename, unix_sock_ro_perms);
if (unix_sock_ro_perms) {
- if (xstrtol_i (unix_sock_ro_perms, NULL, 8, &unix_sock_ro_mask) != 0) {
+ if (virStrToLong_i (unix_sock_ro_perms, NULL, 8, &unix_sock_ro_mask) != 0) {
qemudLog (QEMUD_ERR, _("Failed to parse mode '%s'"),
unix_sock_ro_perms);
goto free_and_fail;
GET_CONF_STR (conf, filename, unix_sock_rw_perms);
if (unix_sock_rw_perms) {
- if (xstrtol_i (unix_sock_rw_perms, NULL, 8, &unix_sock_rw_mask) != 0) {
+ if (virStrToLong_i (unix_sock_rw_perms, NULL, 8, &unix_sock_rw_mask) != 0) {
qemudLog (QEMUD_ERR, _("Failed to parse mode '%s'"),
unix_sock_rw_perms);
goto free_and_fail;
break;
case 't':
- if (xstrtol_i(optarg, &tmp, 10, &timeout) != 0
+ if (virStrToLong_i(optarg, &tmp, 10, &timeout) != 0
|| timeout <= 0
/* Ensure that we can multiply by 1000 without overflowing. */
|| timeout > INT_MAX / 1000)
int __virDomainMigratePerform (virDomainPtr domain, const char *cookie, int cookielen, const char *uri, unsigned long flags, const char *dname, unsigned long bandwidth);
virDomainPtr __virDomainMigrateFinish (virConnectPtr dconn, const char *dname, const char *cookie, int cookielen, const char *uri, unsigned long flags);
-/* Like strtol, but produce an "int" result, and check more carefully.
- Return 0 upon success; return -1 to indicate failure.
- When END_PTR is NULL, the byte after the final valid digit must be NUL.
- Otherwise, it's like strtol and lets the caller check any suffix for
- validity. This function is careful to return -1 when the string S
- represents a number that is not representable as an "int". */
-static inline int
-xstrtol_i(char const *s, char **end_ptr, int base, int *result)
-{
- long int val;
- char *p;
- int err;
-
- errno = 0;
- val = strtol(s, &p, base);
- err = (errno || (!end_ptr && *p) || p == s || (int) val != val);
- if (end_ptr)
- *end_ptr = p;
- if (err)
- return -1;
- *result = val;
- return 0;
-}
-
-/* Just like xstrtol_i, above, but produce an "unsigned int" value. */
-static inline int
-xstrtol_ui(char const *s, char **end_ptr, int base, unsigned int *result)
-{
- unsigned long int val;
- char *p;
- int err;
-
- errno = 0;
- val = strtoul(s, &p, base);
- err = (errno || (!end_ptr && *p) || p == s || (unsigned int) val != val);
- if (end_ptr)
- *end_ptr = p;
- if (err)
- return -1;
- *result = val;
- return 0;
-}
-
-static inline int
-xstrtol_ll(char const *s, char **end_ptr, int base, long long *result)
-{
- long long val;
- char *p;
- int err;
-
- errno = 0;
- val = strtoll(s, &p, base);
- err = (errno || (!end_ptr && *p) || p == s || (long long) val != val);
- if (end_ptr)
- *end_ptr = p;
- if (err)
- return -1;
- *result = val;
- return 0;
-}
-
-/* Just like xstrtol_i, above, but produce an "unsigned long long" value. */
-static inline int
-xstrtol_ull(char const *s, char **end_ptr, int base, unsigned long long *result)
-{
- unsigned long long val;
- char *p;
- int err;
-
- errno = 0;
- val = strtoull(s, &p, base);
- err = (errno || (!end_ptr && *p) || p == s || (unsigned long long) val != val);
- if (end_ptr)
- *end_ptr = p;
- if (err)
- return -1;
- *result = val;
- return 0;
-}
#ifdef __cplusplus
}
#endif /* __cplusplus */
__virDomainMigrateFinish;
__virFileReadAll;
+ __virStrToLong_i;
local: *;
};
#include "nodeinfo.h"
#include "physmem.h"
+#include "util.h"
#ifdef __linux__
#define CPUINFO_PATH "/proc/cpuinfo"
"parsing cpuinfo cpu MHz");
return -1;
}
- if (xstrtol_ui(buf+1, &p, 10, &ui) == 0
+ if (virStrToLong_ui(buf+1, &p, 10, &ui) == 0
/* Accept trailing fractional part. */
&& (*p == '\0' || *p == '.' || isspace(*p)))
nodeinfo->mhz = ui;
"parsing cpuinfo cpu cores %c", *buf);
return -1;
}
- if (xstrtol_ui(buf+1, &p, 10, &id) == 0
+ if (virStrToLong_ui(buf+1, &p, 10, &id) == 0
&& (*p == '\0' || isspace(*p))
&& id > nodeinfo->cores)
nodeinfo->cores = id;
#ifndef __VIR_NODEINFO_H__
#define __VIR_NODEINFO_H__
-#include "internal.h"
+#include "libvirt/libvirt.h"
#ifdef __cplusplus
extern "C" {
#include <xs.h>
#endif
-#include "internal.h"
+#include "util.h"
#include "xen_unified.h"
#include "stats_linux.h"
if (path[4] != '\0') {
if (!isdigit(path[4]) || path[4] == '0' ||
- xstrtol_i(path+4, NULL, 10, &part) < 0 ||
+ virStrToLong_i(path+4, NULL, 10, &part) < 0 ||
part < 1 || part > 15) {
statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"invalid path, partition numbers for xvdN must be in range 1 - 15",
p = path + 3;
}
if (p && (!isdigit(*p) || *p == '0' ||
- xstrtol_i(p, NULL, 10, &part) < 0 ||
+ virStrToLong_i(p, NULL, 10, &part) < 0 ||
part < 1 || part > 15)) {
statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"invalid path, partition numbers for sdN must be in range 1 - 15",
if (path[3] != '\0') {
if (!isdigit(path[3]) || path[3] == '0' ||
- xstrtol_i(path+3, NULL, 10, &part) < 0 ||
+ virStrToLong_i(path+3, NULL, 10, &part) < 0 ||
part < 1 || part > 63) {
statsErrorFunc (conn, VIR_ERR_INVALID_ARG, __FUNCTION__,
"invalid path, partition numbers for hdN must be in range 1 - 63",
return 0;
}
+/* Like strtol, but produce an "int" result, and check more carefully.
+ Return 0 upon success; return -1 to indicate failure.
+ When END_PTR is NULL, the byte after the final valid digit must be NUL.
+ Otherwise, it's like strtol and lets the caller check any suffix for
+ validity. This function is careful to return -1 when the string S
+ represents a number that is not representable as an "int". */
+int
+__virStrToLong_i(char const *s, char **end_ptr, int base, int *result)
+{
+ long int val;
+ char *p;
+ int err;
+
+ errno = 0;
+ val = strtol(s, &p, base);
+ err = (errno || (!end_ptr && *p) || p == s || (int) val != val);
+ if (end_ptr)
+ *end_ptr = p;
+ if (err)
+ return -1;
+ *result = val;
+ return 0;
+}
+
+/* Just like virStrToLong_i, above, but produce an "unsigned int" value. */
+int
+virStrToLong_ui(char const *s, char **end_ptr, int base, unsigned int *result)
+{
+ unsigned long int val;
+ char *p;
+ int err;
+
+ errno = 0;
+ val = strtoul(s, &p, base);
+ err = (errno || (!end_ptr && *p) || p == s || (unsigned int) val != val);
+ if (end_ptr)
+ *end_ptr = p;
+ if (err)
+ return -1;
+ *result = val;
+ return 0;
+}
+
+/* Just like virStrToLong_i, above, but produce an "long long" value. */
+int
+virStrToLong_ll(char const *s, char **end_ptr, int base, long long *result)
+{
+ long long val;
+ char *p;
+ int err;
+
+ errno = 0;
+ val = strtoll(s, &p, base);
+ err = (errno || (!end_ptr && *p) || p == s || (long long) val != val);
+ if (end_ptr)
+ *end_ptr = p;
+ if (err)
+ return -1;
+ *result = val;
+ return 0;
+}
+
+/* Just like virStrToLong_i, above, but produce an "unsigned long long" value. */
+int
+virStrToLong_ull(char const *s, char **end_ptr, int base, unsigned long long *result)
+{
+ unsigned long long val;
+ char *p;
+ int err;
+
+ errno = 0;
+ val = strtoull(s, &p, base);
+ err = (errno || (!end_ptr && *p) || p == s || (unsigned long long) val != val);
+ if (end_ptr)
+ *end_ptr = p;
+ if (err)
+ return -1;
+ *result = val;
+ return 0;
+}
+
/*
* Local variables:
* indent-tabs-mode: nil
unsigned int buflen);
+int __virStrToLong_i(char const *s,
+ char **end_ptr,
+ int base,
+ int *result);
+#define virStrToLong_i(s,e,b,r) __virStrToLong_i((s),(e),(b),(r))
+
+int virStrToLong_ui(char const *s,
+ char **end_ptr,
+ int base,
+ unsigned int *result);
+int virStrToLong_ll(char const *s,
+ char **end_ptr,
+ int base,
+ long long *result);
+int virStrToLong_ull(char const *s,
+ char **end_ptr,
+ int base,
+ unsigned long long *result);
+
#endif /* __VIR_UTIL_H__ */
#include <readline/history.h>
#endif
-#include "internal.h"
#include "console.h"
#include "util.h"
(obj->stringval == NULL) || (obj->stringval[0] == 0)) {
goto cleanup;
}
- if (xstrtol_i((const char *)obj->stringval, NULL, 10, &port) || port < 0)
+ if (virStrToLong_i((const char *)obj->stringval, NULL, 10, &port) || port < 0)
goto cleanup;
xmlXPathFreeObject(obj);
/* try it by ID */
if (flag & VSH_BYID) {
- if (xstrtol_i(n, NULL, 10, &id) == 0 && id >= 0) {
+ if (virStrToLong_i(n, NULL, 10, &id) == 0 && id >= 0) {
vshDebug(ctl, 5, "%s: <%s> seems like domain ID\n",
cmd->def->name, optname);
dom = virDomainLookupByID(ctl->conn, id);
#include "libvirt/libvirt.h"
#include "driver.h"
-#include "internal.h"
+#include "util.h"
#include "sexpr.h"
#include "xml.h"
#include "buf.h"
(t->u.s.car->u.s.cdr->kind == SEXPR_CONS)) {
for (t = t->u.s.car->u.s.cdr->u.s.car; t->kind == SEXPR_CONS; t = t->u.s.cdr)
if (t->u.s.car->kind == SEXPR_VALUE
- && xstrtol_i(t->u.s.car->u.value, NULL, 10, &cpu) == 0
+ && virStrToLong_i(t->u.s.car->u.value, NULL, 10, &cpu) == 0
&& cpu >= 0
&& (VIR_CPU_MAPLEN(cpu+1) <= maplen)) {
VIR_USE_CPU(cpumap, cpu);