]> xenbits.xensource.com Git - libvirt.git/commitdiff
build: avoid frame size error when building without -O2
authorLaine Stump <laine@laine.org>
Mon, 26 Mar 2012 18:42:22 +0000 (14:42 -0400)
committerLaine Stump <laine@laine.org>
Mon, 26 Mar 2012 21:08:30 +0000 (17:08 -0400)
libvirt always adds -Werror-frame-larger-than=4096 to the flags when
it builds. When building on Fedora 17, two functions with multiple
1024 buffers declared inside if {} blocks would generate frame size
errors; apparently the version of gcc on Fedora 16 will merge these
multiple buffers into a single buffer even when optimization is off,
but Fedora 17 won't.

The fix is to declare a single 1024 buffer at the top of the two
offending functions, and reuse the single buffer throughout the
functions.

src/libxl/libxl_driver.c
src/qemu/qemu_driver.c

index eccd198bcda8668d4992dbf362d8eea1aa6f7b16..fb18948d4f8ff6f87048aa477d5c977ffa46b8e0 100644 (file)
@@ -833,6 +833,7 @@ libxlStartup(int privileged) {
     char *log_file = NULL;
     virCommandPtr cmd;
     int status, ret = 0;
+    char ebuf[1024];
 
     /* Disable libxl driver if non-root */
     if (!privileged) {
@@ -893,25 +894,21 @@ libxlStartup(int privileged) {
         goto out_of_memory;
 
     if (virFileMakePath(libxl_driver->logDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create log dir '%s': %s"),
                   libxl_driver->logDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(libxl_driver->stateDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create state dir '%s': %s"),
                   libxl_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(libxl_driver->libDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create lib dir '%s': %s"),
                   libxl_driver->libDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(libxl_driver->saveDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create save dir '%s': %s"),
                   libxl_driver->saveDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
index ea772cf594dd390219aede734db43a5a9c4072f0..d503debcc03a1e7ce3f9f0291a2ea3e9c9a7757a 100644 (file)
@@ -426,6 +426,7 @@ qemudStartup(int privileged) {
     char *driverConf = NULL;
     int rc;
     virConnectPtr conn = NULL;
+    char ebuf[1024];
 
     if (VIR_ALLOC(qemu_driver) < 0)
         return -1;
@@ -519,37 +520,31 @@ qemudStartup(int privileged) {
     }
 
     if (virFileMakePath(qemu_driver->stateDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create state dir '%s': %s"),
                   qemu_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(qemu_driver->libDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create lib dir '%s': %s"),
                   qemu_driver->libDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(qemu_driver->cacheDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create cache dir '%s': %s"),
                   qemu_driver->cacheDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(qemu_driver->saveDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create save dir '%s': %s"),
                   qemu_driver->saveDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(qemu_driver->snapshotDir) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create save dir '%s': %s"),
                   qemu_driver->snapshotDir, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
     }
     if (virFileMakePath(qemu_driver->autoDumpPath) < 0) {
-        char ebuf[1024];
         VIR_ERROR(_("Failed to create dump dir '%s': %s"),
                   qemu_driver->autoDumpPath, virStrerror(errno, ebuf, sizeof ebuf));
         goto error;
@@ -567,9 +562,8 @@ qemudStartup(int privileged) {
 
     rc = virCgroupForDriver("qemu", &qemu_driver->cgroup, privileged, 1);
     if (rc < 0) {
-        char buf[1024];
         VIR_INFO("Unable to create cgroup for driver: %s",
-                 virStrerror(-rc, buf, sizeof(buf)));
+                 virStrerror(-rc, ebuf, sizeof(ebuf)));
     }
 
     if (qemudLoadDriverConfig(qemu_driver, driverConf) < 0) {