]> xenbits.xensource.com Git - libvirt.git/commitdiff
Fix gcc-4.3.0 "inlining failed" warning.
authorMark McLoughlin <markmc@redhat.com>
Fri, 8 Feb 2008 09:15:16 +0000 (09:15 +0000)
committerMark McLoughlin <markmc@redhat.com>
Fri, 8 Feb 2008 09:15:16 +0000 (09:15 +0000)
* 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.

ChangeLog
qemud/qemud.c
src/internal.h
src/libvirt_sym.version
src/nodeinfo.c
src/nodeinfo.h
src/stats_linux.c
src/util.c
src/util.h
src/virsh.c
src/xend_internal.c

index 7735e1dcf88e5124afdc0d8e55ed5872e0d40abc..549380371e9e8264a3c361758f241a816ed0de05 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+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.
index b0e255825702b68d190a9c56cb9edcf56a991455..3a5e44c07d432c9c4ede118e0f94390f4ba3da5e 100644 (file)
@@ -52,7 +52,7 @@
 
 #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"
@@ -1905,7 +1905,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
 
     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;
@@ -1916,7 +1916,7 @@ remoteReadConfigFile (struct qemud_server *server, const char *filename)
 
     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;
@@ -2061,7 +2061,7 @@ int main(int argc, char **argv) {
             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)
index fb7bb8f3a28d059c0e8235e7fa3a03276b03278c..033a25dcdfca531d6275f744b669a4ef4eacda90 100644 (file)
@@ -261,85 +261,6 @@ int __virDomainMigratePrepare (virConnectPtr dconn, char **cookie, int *cookiele
 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 */
index edc7f87640806a8cf09affd1bf3c2360f90ebf95..0a94e3cdcf011c23e8b49d4b9a450a25fae20a6b 100644 (file)
        __virDomainMigrateFinish;
 
         __virFileReadAll;
+        __virStrToLong_i;
 
     local: *;
 };
index 65a2cf140d4e45355e9327f593271968d7e037b3..ff5784e279440c80d99204f1ce16ee7fe20e57ec 100644 (file)
@@ -35,6 +35,7 @@
 
 #include "nodeinfo.h"
 #include "physmem.h"
+#include "util.h"
 
 #ifdef __linux__
 #define CPUINFO_PATH "/proc/cpuinfo"
@@ -79,7 +80,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
                                 "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;
@@ -95,7 +96,7 @@ int linuxNodeInfoCPUPopulate(virConnectPtr conn, FILE *cpuinfo, virNodeInfoPtr n
                                 "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;
index d0d0bb29c84102bbf22b6d7b6ffaa8b6d92250b4..de2f6a108231293ac6aa93c4d3880ea7a72aa420 100644 (file)
@@ -24,7 +24,7 @@
 #ifndef __VIR_NODEINFO_H__
 #define __VIR_NODEINFO_H__
 
-#include "internal.h"
+#include "libvirt/libvirt.h"
 
 #ifdef __cplusplus
 extern "C" {
index dcc2a942ee8d25e948bf28655bcd00f4aeafdde7..4cbe92a075d057ce8f99efcdabe4cf9cc91b8c5d 100644 (file)
@@ -24,7 +24,7 @@
 #include <xs.h>
 #endif
 
-#include "internal.h"
+#include "util.h"
 #include "xen_unified.h"
 #include "stats_linux.h"
 
@@ -263,7 +263,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
 
         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",
@@ -307,7 +307,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
                 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",
@@ -333,7 +333,7 @@ xenLinuxDomainDeviceID(virConnectPtr conn, int domid, const char *path)
 
         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",
index 0ecd2acbb3373166d9c5126d3e070131c71342d9..f082984e90536e4025689be61a756c85bd54e19a 100644 (file)
@@ -549,6 +549,87 @@ int virFileBuildPath(const char *dir,
     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
index d64299f3e8d8bd1efac8dabe89f7d9d0ee2d1033..da1f5b0db1f9912aa368900a86092442b1552386 100644 (file)
@@ -56,4 +56,23 @@ int virFileBuildPath(const char *dir,
                      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__ */
index 9521eff6cc0e1aed65bb81b4f6793fec5106ccf3..730f251b12ec5d9512f2c6c9d337c7a8a52c8eed 100644 (file)
@@ -46,7 +46,6 @@
 #include <readline/history.h>
 #endif
 
-#include "internal.h"
 #include "console.h"
 #include "util.h"
 
@@ -2914,7 +2913,7 @@ cmdVNCDisplay(vshControl * ctl, vshCmd * cmd)
         (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);
 
@@ -3955,7 +3954,7 @@ vshCommandOptDomainBy(vshControl * ctl, vshCmd * cmd, const char *optname,
 
     /* 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);
index fd38a6196330ca3cb0949c0eb5a99327bba999ab..6dbd4fb936db8fff6e31a1215ba7fb7b7766fc52 100644 (file)
@@ -35,7 +35,7 @@
 
 #include "libvirt/libvirt.h"
 #include "driver.h"
-#include "internal.h"
+#include "util.h"
 #include "sexpr.h"
 #include "xml.h"
 #include "buf.h"
@@ -3049,7 +3049,7 @@ xenDaemonDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
                         (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);