build: avoid frame size error when building without -O2

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.
This commit is contained in:
Laine Stump 2012-03-26 14:42:22 -04:00
parent f094452526
commit cf57d345b5
2 changed files with 3 additions and 12 deletions

View File

@ -833,6 +833,7 @@ libxlStartup(int privileged) {
char *log_file = NULL; char *log_file = NULL;
virCommandPtr cmd; virCommandPtr cmd;
int status, ret = 0; int status, ret = 0;
char ebuf[1024];
/* Disable libxl driver if non-root */ /* Disable libxl driver if non-root */
if (!privileged) { if (!privileged) {
@ -893,25 +894,21 @@ libxlStartup(int privileged) {
goto out_of_memory; goto out_of_memory;
if (virFileMakePath(libxl_driver->logDir) < 0) { if (virFileMakePath(libxl_driver->logDir) < 0) {
char ebuf[1024];
VIR_ERROR(_("Failed to create log dir '%s': %s"), VIR_ERROR(_("Failed to create log dir '%s': %s"),
libxl_driver->logDir, virStrerror(errno, ebuf, sizeof ebuf)); libxl_driver->logDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;
} }
if (virFileMakePath(libxl_driver->stateDir) < 0) { if (virFileMakePath(libxl_driver->stateDir) < 0) {
char ebuf[1024];
VIR_ERROR(_("Failed to create state dir '%s': %s"), VIR_ERROR(_("Failed to create state dir '%s': %s"),
libxl_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf)); libxl_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;
} }
if (virFileMakePath(libxl_driver->libDir) < 0) { if (virFileMakePath(libxl_driver->libDir) < 0) {
char ebuf[1024];
VIR_ERROR(_("Failed to create lib dir '%s': %s"), VIR_ERROR(_("Failed to create lib dir '%s': %s"),
libxl_driver->libDir, virStrerror(errno, ebuf, sizeof ebuf)); libxl_driver->libDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;
} }
if (virFileMakePath(libxl_driver->saveDir) < 0) { if (virFileMakePath(libxl_driver->saveDir) < 0) {
char ebuf[1024];
VIR_ERROR(_("Failed to create save dir '%s': %s"), VIR_ERROR(_("Failed to create save dir '%s': %s"),
libxl_driver->saveDir, virStrerror(errno, ebuf, sizeof ebuf)); libxl_driver->saveDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;

View File

@ -426,6 +426,7 @@ qemudStartup(int privileged) {
char *driverConf = NULL; char *driverConf = NULL;
int rc; int rc;
virConnectPtr conn = NULL; virConnectPtr conn = NULL;
char ebuf[1024];
if (VIR_ALLOC(qemu_driver) < 0) if (VIR_ALLOC(qemu_driver) < 0)
return -1; return -1;
@ -519,37 +520,31 @@ qemudStartup(int privileged) {
} }
if (virFileMakePath(qemu_driver->stateDir) < 0) { if (virFileMakePath(qemu_driver->stateDir) < 0) {
char ebuf[1024];
VIR_ERROR(_("Failed to create state dir '%s': %s"), VIR_ERROR(_("Failed to create state dir '%s': %s"),
qemu_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf)); qemu_driver->stateDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;
} }
if (virFileMakePath(qemu_driver->libDir) < 0) { if (virFileMakePath(qemu_driver->libDir) < 0) {
char ebuf[1024];
VIR_ERROR(_("Failed to create lib dir '%s': %s"), VIR_ERROR(_("Failed to create lib dir '%s': %s"),
qemu_driver->libDir, virStrerror(errno, ebuf, sizeof ebuf)); qemu_driver->libDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;
} }
if (virFileMakePath(qemu_driver->cacheDir) < 0) { if (virFileMakePath(qemu_driver->cacheDir) < 0) {
char ebuf[1024];
VIR_ERROR(_("Failed to create cache dir '%s': %s"), VIR_ERROR(_("Failed to create cache dir '%s': %s"),
qemu_driver->cacheDir, virStrerror(errno, ebuf, sizeof ebuf)); qemu_driver->cacheDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;
} }
if (virFileMakePath(qemu_driver->saveDir) < 0) { if (virFileMakePath(qemu_driver->saveDir) < 0) {
char ebuf[1024];
VIR_ERROR(_("Failed to create save dir '%s': %s"), VIR_ERROR(_("Failed to create save dir '%s': %s"),
qemu_driver->saveDir, virStrerror(errno, ebuf, sizeof ebuf)); qemu_driver->saveDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;
} }
if (virFileMakePath(qemu_driver->snapshotDir) < 0) { if (virFileMakePath(qemu_driver->snapshotDir) < 0) {
char ebuf[1024];
VIR_ERROR(_("Failed to create save dir '%s': %s"), VIR_ERROR(_("Failed to create save dir '%s': %s"),
qemu_driver->snapshotDir, virStrerror(errno, ebuf, sizeof ebuf)); qemu_driver->snapshotDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;
} }
if (virFileMakePath(qemu_driver->autoDumpPath) < 0) { if (virFileMakePath(qemu_driver->autoDumpPath) < 0) {
char ebuf[1024];
VIR_ERROR(_("Failed to create dump dir '%s': %s"), VIR_ERROR(_("Failed to create dump dir '%s': %s"),
qemu_driver->autoDumpPath, virStrerror(errno, ebuf, sizeof ebuf)); qemu_driver->autoDumpPath, virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;
@ -567,9 +562,8 @@ qemudStartup(int privileged) {
rc = virCgroupForDriver("qemu", &qemu_driver->cgroup, privileged, 1); rc = virCgroupForDriver("qemu", &qemu_driver->cgroup, privileged, 1);
if (rc < 0) { if (rc < 0) {
char buf[1024];
VIR_INFO("Unable to create cgroup for driver: %s", 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) { if (qemudLoadDriverConfig(qemu_driver, driverConf) < 0) {