remove remainder of offending strerror uses

* qemud/qemud.c (GET_CONF_STR): Use virStrerror, not strerror.
* qemud/remote.c (remoteDispatchDomainBlockPeek): Likewise.
(remoteDispatchDomainMemoryPeek, remoteDispatchAuthSaslInit): Likewise.
(remoteDispatchAuthPolkit): Likewise.
* src/lxc_container.c (lxcContainerAvailable): Likewise.
* src/network_driver.c (networkStartNetworkDaemon): Likewise.
(networkShutdownNetworkDaemon): Likewise.
* src/qemu_conf.c (qemudExtractVersion, qemudNetworkIfaceConnect):
* src/storage_conf.c (virStoragePoolLoadAllConfigs): Likewise.
* src/storage_driver.c (storagePoolUndefine): Likewise.
* src/uml_driver.c (umlStartup, umlStartVMDaemon): Likewise.
* src/util.c (virFileReadAll): Likewise.
* src/uuid.c (virUUIDGenerate): Likewise.
* src/xen_internal.c (get_cpu_flags): Likewise.
This commit is contained in:
Jim Meyering 2009-02-05 16:28:30 +00:00
parent d22a844b46
commit bafd7389e4
12 changed files with 84 additions and 35 deletions

View File

@ -1,3 +1,21 @@
Thu Feb 5 17:03:35 +0100 2009 Jim Meyering <meyering@redhat.com>
remove remainder of offending strerror uses
* qemud/qemud.c (GET_CONF_STR): Use virStrerror, not strerror.
* qemud/remote.c (remoteDispatchDomainBlockPeek): Likewise.
(remoteDispatchDomainMemoryPeek, remoteDispatchAuthSaslInit): Likewise.
(remoteDispatchAuthPolkit): Likewise.
* src/lxc_container.c (lxcContainerAvailable): Likewise.
* src/network_driver.c (networkStartNetworkDaemon): Likewise.
(networkShutdownNetworkDaemon): Likewise.
* src/qemu_conf.c (qemudExtractVersion, qemudNetworkIfaceConnect):
* src/storage_conf.c (virStoragePoolLoadAllConfigs): Likewise.
* src/storage_driver.c (storagePoolUndefine): Likewise.
* src/uml_driver.c (umlStartup, umlStartVMDaemon): Likewise.
* src/util.c (virFileReadAll): Likewise.
* src/uuid.c (virUUIDGenerate): Likewise.
* src/xen_internal.c (get_cpu_flags): Likewise.
Thu Feb 5 17:03:35 +0100 2009 Jim Meyering <meyering@redhat.com> Thu Feb 5 17:03:35 +0100 2009 Jim Meyering <meyering@redhat.com>
don't include raw errno in diagnostics don't include raw errno in diagnostics

View File

@ -49,6 +49,7 @@
#include <netdb.h> #include <netdb.h>
#include "libvirt_internal.h" #include "libvirt_internal.h"
#include "virterror_internal.h"
#include "qemud.h" #include "qemud.h"
#include "util.h" #include "util.h"
@ -2316,7 +2317,9 @@ checkType (virConfValuePtr p, const char *filename,
goto free_and_fail; \ goto free_and_fail; \
(var_name) = strdup (p->str); \ (var_name) = strdup (p->str); \
if ((var_name) == NULL) { \ if ((var_name) == NULL) { \
VIR_ERROR(_("remoteReadConfigFile: %s\n"),strerror (errno)); \ char ebuf[1024]; \
VIR_ERROR(_("remoteReadConfigFile: %s\n"), \
virStrerror(errno, ebuf, sizeof ebuf)); \
goto free_and_fail; \ goto free_and_fail; \
} \ } \
} \ } \

View File

@ -41,6 +41,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <fnmatch.h> #include <fnmatch.h>
#include "virterror_internal.h"
#ifdef HAVE_POLKIT #ifdef HAVE_POLKIT
#include <polkit/polkit.h> #include <polkit/polkit.h>
@ -991,8 +992,10 @@ remoteDispatchDomainBlockPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
ret->buffer.buffer_len = size; ret->buffer.buffer_len = size;
if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) { if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) {
char ebuf[1024];
virDomainFree (dom); virDomainFree (dom);
remoteDispatchFormatError (rerr, "%s", strerror (errno)); remoteDispatchFormatError (rerr, "%s",
virStrerror(errno, ebuf, sizeof ebuf));
return -1; return -1;
} }
@ -1031,16 +1034,18 @@ remoteDispatchDomainMemoryPeek (struct qemud_server *server ATTRIBUTE_UNUSED,
flags = args->flags; flags = args->flags;
if (size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX) { if (size > REMOTE_DOMAIN_MEMORY_PEEK_BUFFER_MAX) {
virDomainFree (dom);
remoteDispatchFormatError (rerr, remoteDispatchFormatError (rerr,
"%s", _("size > maximum buffer size")); "%s", _("size > maximum buffer size"));
virDomainFree (dom);
return -1; return -1;
} }
ret->buffer.buffer_len = size; ret->buffer.buffer_len = size;
if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) { if (VIR_ALLOC_N (ret->buffer.buffer_val, size) < 0) {
remoteDispatchFormatError (rerr, "%s", strerror (errno)); char ebuf[1024];
virDomainFree (dom); virDomainFree (dom);
remoteDispatchFormatError (rerr, "%s",
virStrerror(errno, ebuf, sizeof ebuf));
return -1; return -1;
} }
@ -2571,9 +2576,10 @@ remoteDispatchAuthSaslInit (struct qemud_server *server,
/* Get local address in form IPADDR:PORT */ /* Get local address in form IPADDR:PORT */
salen = sizeof(sa); salen = sizeof(sa);
if (getsockname(client->fd, (struct sockaddr*)&sa, &salen) < 0) { if (getsockname(client->fd, (struct sockaddr*)&sa, &salen) < 0) {
char ebuf[1024];
remoteDispatchFormatError(rerr, remoteDispatchFormatError(rerr,
_("failed to get sock address: %s"), _("failed to get sock address: %s"),
strerror(errno)); virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;
} }
if ((localAddr = addrToString(rerr, &sa, salen)) == NULL) { if ((localAddr = addrToString(rerr, &sa, salen)) == NULL) {
@ -2583,8 +2589,9 @@ remoteDispatchAuthSaslInit (struct qemud_server *server,
/* Get remote address in form IPADDR:PORT */ /* Get remote address in form IPADDR:PORT */
salen = sizeof(sa); salen = sizeof(sa);
if (getpeername(client->fd, (struct sockaddr*)&sa, &salen) < 0) { if (getpeername(client->fd, (struct sockaddr*)&sa, &salen) < 0) {
char ebuf[1024];
remoteDispatchFormatError(rerr, _("failed to get peer address: %s"), remoteDispatchFormatError(rerr, _("failed to get peer address: %s"),
strerror(errno)); virStrerror(errno, ebuf, sizeof ebuf));
VIR_FREE(localAddr); VIR_FREE(localAddr);
goto error; goto error;
} }
@ -3062,7 +3069,9 @@ remoteDispatchAuthPolkit (struct qemud_server *server,
} }
if (!(pkaction = polkit_action_new())) { if (!(pkaction = polkit_action_new())) {
VIR_ERROR(_("Failed to create polkit action %s\n"), strerror(errno)); char ebuf[1024];
VIR_ERROR(_("Failed to create polkit action %s\n"),
virStrerror(errno, ebuf, sizeof ebuf));
polkit_caller_unref(pkcaller); polkit_caller_unref(pkcaller);
goto authfail; goto authfail;
} }
@ -3070,9 +3079,10 @@ remoteDispatchAuthPolkit (struct qemud_server *server,
if (!(pkcontext = polkit_context_new()) || if (!(pkcontext = polkit_context_new()) ||
!polkit_context_init(pkcontext, &pkerr)) { !polkit_context_init(pkcontext, &pkerr)) {
char ebuf[1024];
VIR_ERROR(_("Failed to create polkit context %s\n"), VIR_ERROR(_("Failed to create polkit context %s\n"),
(pkerr ? polkit_error_get_error_message(pkerr) (pkerr ? polkit_error_get_error_message(pkerr)
: strerror(errno))); : virStrerror(errno, ebuf, sizeof ebuf)));
if (pkerr) if (pkerr)
polkit_error_free(pkerr); polkit_error_free(pkerr);
polkit_caller_unref(pkcaller); polkit_caller_unref(pkcaller);

View File

@ -668,8 +668,9 @@ int lxcContainerAvailable(int features)
cpid = clone(lxcContainerDummyChild, childStack, flags, NULL); cpid = clone(lxcContainerDummyChild, childStack, flags, NULL);
VIR_FREE(stack); VIR_FREE(stack);
if (cpid < 0) { if (cpid < 0) {
char ebuf[1024];
DEBUG("clone call returned %s, container support is not enabled", DEBUG("clone call returned %s, container support is not enabled",
strerror(errno)); virStrerror(errno, ebuf, sizeof ebuf));
return -1; return -1;
} else { } else {
waitpid(cpid, &childStatus, 0); waitpid(cpid, &childStatus, 0);

View File

@ -907,14 +907,16 @@ static int networkStartNetworkDaemon(virConnectPtr conn,
err_delbr1: err_delbr1:
if (network->def->ipAddress && if (network->def->ipAddress &&
(err = brSetInterfaceUp(driver->brctl, network->def->bridge, 0))) { (err = brSetInterfaceUp(driver->brctl, network->def->bridge, 0))) {
char ebuf[1024];
networkLog(NETWORK_WARN, _("Failed to bring down bridge '%s' : %s\n"), networkLog(NETWORK_WARN, _("Failed to bring down bridge '%s' : %s\n"),
network->def->bridge, strerror(err)); network->def->bridge, virStrerror(err, ebuf, sizeof ebuf));
} }
err_delbr: err_delbr:
if ((err = brDeleteBridge(driver->brctl, network->def->bridge))) { if ((err = brDeleteBridge(driver->brctl, network->def->bridge))) {
char ebuf[1024];
networkLog(NETWORK_WARN, _("Failed to delete bridge '%s' : %s\n"), networkLog(NETWORK_WARN, _("Failed to delete bridge '%s' : %s\n"),
network->def->bridge, strerror(err)); network->def->bridge, virStrerror(err, ebuf, sizeof ebuf));
} }
return -1; return -1;
@ -944,15 +946,16 @@ static int networkShutdownNetworkDaemon(virConnectPtr conn,
networkRemoveIptablesRules(driver, network); networkRemoveIptablesRules(driver, network);
char ebuf[1024];
if (network->def->ipAddress && if (network->def->ipAddress &&
(err = brSetInterfaceUp(driver->brctl, network->def->bridge, 0))) { (err = brSetInterfaceUp(driver->brctl, network->def->bridge, 0))) {
networkLog(NETWORK_WARN, _("Failed to bring down bridge '%s' : %s\n"), networkLog(NETWORK_WARN, _("Failed to bring down bridge '%s' : %s\n"),
network->def->bridge, strerror(err)); network->def->bridge, virStrerror(err, ebuf, sizeof ebuf));
} }
if ((err = brDeleteBridge(driver->brctl, network->def->bridge))) { if ((err = brDeleteBridge(driver->brctl, network->def->bridge))) {
networkLog(NETWORK_WARN, _("Failed to delete bridge '%s' : %s\n"), networkLog(NETWORK_WARN, _("Failed to delete bridge '%s' : %s\n"),
network->def->bridge, strerror(err)); network->def->bridge, virStrerror(err, ebuf, sizeof ebuf));
} }
/* See if its still alive and really really kill it */ /* See if its still alive and really really kill it */

View File

@ -517,9 +517,10 @@ int qemudExtractVersion(virConnectPtr conn,
return -1; return -1;
if (stat(binary, &sb) < 0) { if (stat(binary, &sb) < 0) {
char ebuf[1024];
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("Cannot find QEMU binary %s: %s"), binary, _("Cannot find QEMU binary %s: %s"), binary,
strerror(errno)); virStrerror(errno, ebuf, sizeof ebuf));
return -1; return -1;
} }
@ -580,10 +581,11 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
} }
} }
char ebuf[1024];
if (!driver->brctl && (err = brInit(&driver->brctl))) { if (!driver->brctl && (err = brInit(&driver->brctl))) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("cannot initialize bridge support: %s"), _("cannot initialize bridge support: %s"),
strerror(err)); virStrerror(err, ebuf, sizeof ebuf));
goto error; goto error;
} }
@ -598,7 +600,7 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
_("Failed to add tap interface '%s' " _("Failed to add tap interface '%s' "
"to bridge '%s' : %s"), "to bridge '%s' : %s"),
net->ifname, brname, strerror(err)); net->ifname, brname, virStrerror(err, ebuf, sizeof ebuf));
} }
goto error; goto error;
} }

View File

@ -1,7 +1,7 @@
/* /*
* storage_conf.c: config handling for storage driver * storage_conf.c: config handling for storage driver
* *
* Copyright (C) 2006-2008 Red Hat, Inc. * Copyright (C) 2006-2009 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange * Copyright (C) 2006-2008 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -1384,10 +1384,11 @@ virStoragePoolLoadAllConfigs(virConnectPtr conn,
struct dirent *entry; struct dirent *entry;
if (!(dir = opendir(configDir))) { if (!(dir = opendir(configDir))) {
char ebuf[1024];
if (errno == ENOENT) if (errno == ENOENT)
return 0; return 0;
virStorageLog("Failed to open dir '%s': %s", virStorageLog("Failed to open dir '%s': %s",
configDir, strerror(errno)); configDir, virStrerror(errno, ebuf, sizeof ebuf));
return -1; return -1;
} }

View File

@ -1,7 +1,7 @@
/* /*
* storage_driver.c: core driver for storage APIs * storage_driver.c: core driver for storage APIs
* *
* Copyright (C) 2006-2008 Red Hat, Inc. * Copyright (C) 2006-2009 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange * Copyright (C) 2006-2008 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -567,9 +567,11 @@ storagePoolUndefine(virStoragePoolPtr obj) {
if (virStoragePoolObjDeleteDef(obj->conn, pool) < 0) if (virStoragePoolObjDeleteDef(obj->conn, pool) < 0)
goto cleanup; goto cleanup;
if (unlink(pool->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) if (unlink(pool->autostartLink) < 0 && errno != ENOENT && errno != ENOTDIR) {
char ebuf[1024];
storageLog("Failed to delete autostart link '%s': %s", storageLog("Failed to delete autostart link '%s': %s",
pool->autostartLink, strerror(errno)); pool->autostartLink, virStrerror(errno, ebuf, sizeof ebuf));
}
VIR_FREE(pool->configFile); VIR_FREE(pool->configFile);
VIR_FREE(pool->autostartLink); VIR_FREE(pool->autostartLink);

View File

@ -376,8 +376,9 @@ umlStartup(void) {
} }
if (virFileMakePath(uml_driver->monitorDir) < 0) { if (virFileMakePath(uml_driver->monitorDir) < 0) {
char ebuf[1024];
umlLog(VIR_LOG_ERROR, _("Failed to create monitor directory %s: %s"), umlLog(VIR_LOG_ERROR, _("Failed to create monitor directory %s: %s"),
uml_driver->monitorDir, strerror(errno)); uml_driver->monitorDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error; goto error;
} }
@ -726,6 +727,7 @@ static int umlStartVMDaemon(virConnectPtr conn,
int *tapfds = NULL; int *tapfds = NULL;
int ntapfds = 0; int ntapfds = 0;
fd_set keepfd; fd_set keepfd;
char ebuf[1024];
FD_ZERO(&keepfd); FD_ZERO(&keepfd);
@ -792,25 +794,25 @@ static int umlStartVMDaemon(virConnectPtr conn,
while (*tmp) { while (*tmp) {
if (safewrite(logfd, *tmp, strlen(*tmp)) < 0) if (safewrite(logfd, *tmp, strlen(*tmp)) < 0)
umlLog(VIR_LOG_WARN, _("Unable to write envv to logfile: %s\n"), umlLog(VIR_LOG_WARN, _("Unable to write envv to logfile: %s\n"),
strerror(errno)); virStrerror(errno, ebuf, sizeof ebuf));
if (safewrite(logfd, " ", 1) < 0) if (safewrite(logfd, " ", 1) < 0)
umlLog(VIR_LOG_WARN, _("Unable to write envv to logfile: %s\n"), umlLog(VIR_LOG_WARN, _("Unable to write envv to logfile: %s\n"),
strerror(errno)); virStrerror(errno, ebuf, sizeof ebuf));
tmp++; tmp++;
} }
tmp = argv; tmp = argv;
while (*tmp) { while (*tmp) {
if (safewrite(logfd, *tmp, strlen(*tmp)) < 0) if (safewrite(logfd, *tmp, strlen(*tmp)) < 0)
umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"), umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"),
strerror(errno)); virStrerror(errno, ebuf, sizeof ebuf));
if (safewrite(logfd, " ", 1) < 0) if (safewrite(logfd, " ", 1) < 0)
umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"), umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"),
strerror(errno)); virStrerror(errno, ebuf, sizeof ebuf));
tmp++; tmp++;
} }
if (safewrite(logfd, "\n", 1) < 0) if (safewrite(logfd, "\n", 1) < 0)
umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"), umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"),
strerror(errno)); virStrerror(errno, ebuf, sizeof ebuf));
vm->monitor = -1; vm->monitor = -1;
@ -825,7 +827,7 @@ static int umlStartVMDaemon(virConnectPtr conn,
/* Cleanup intermediate proces */ /* Cleanup intermediate proces */
if (waitpid(pid, NULL, 0) != pid) if (waitpid(pid, NULL, 0) != pid)
umlLog(VIR_LOG_WARN, _("failed to wait on process: %d: %s\n"), umlLog(VIR_LOG_WARN, _("failed to wait on process: %d: %s\n"),
pid, strerror(errno)); pid, virStrerror(errno, ebuf, sizeof ebuf));
for (i = 0 ; argv[i] ; i++) for (i = 0 ; argv[i] ; i++)
VIR_FREE(argv[i]); VIR_FREE(argv[i]);

View File

@ -755,17 +755,19 @@ int virFileReadLimFD(int fd_arg, int maxlen, char **buf)
int virFileReadAll(const char *path, int maxlen, char **buf) int virFileReadAll(const char *path, int maxlen, char **buf)
{ {
char ebuf[1024];
FILE *fh = fopen(path, "r"); FILE *fh = fopen(path, "r");
if (fh == NULL) { if (fh == NULL) {
virLog("Failed to open file '%s': %s\n", virLog("Failed to open file '%s': %s\n",
path, strerror(errno)); path, virStrerror(errno, ebuf, sizeof ebuf));
return -1; return -1;
} }
int len = virFileReadLimFP (fh, maxlen, buf); int len = virFileReadLimFP (fh, maxlen, buf);
fclose(fh); fclose(fh);
if (len < 0) { if (len < 0) {
virLog("Failed to read '%s': %s\n", path, strerror (errno)); virLog("Failed to read '%s': %s\n", path,
virStrerror(errno, ebuf, sizeof ebuf));
return -1; return -1;
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2007, 2008 Red Hat, Inc. * Copyright (C) 2007, 2008, 2009 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -36,6 +36,7 @@
#include "c-ctype.h" #include "c-ctype.h"
#include "internal.h" #include "internal.h"
#include "util.h" #include "util.h"
#include "virterror_internal.h"
#define qemudLog(level, msg...) fprintf(stderr, msg) #define qemudLog(level, msg...) fprintf(stderr, msg)
@ -99,10 +100,13 @@ virUUIDGenerate(unsigned char *uuid)
if (uuid == NULL) if (uuid == NULL)
return(-1); return(-1);
if ((err = virUUIDGenerateRandomBytes(uuid, VIR_UUID_BUFLEN))) if ((err = virUUIDGenerateRandomBytes(uuid, VIR_UUID_BUFLEN))) {
char ebuf[1024];
qemudLog(QEMUD_WARN, qemudLog(QEMUD_WARN,
_("Falling back to pseudorandom UUID," _("Falling back to pseudorandom UUID,"
" failed to generate random bytes: %s"), strerror(err)); " failed to generate random bytes: %s"),
virStrerror(err, ebuf, sizeof ebuf));
}
return virUUIDGeneratePseudoRandomBytes(uuid, VIR_UUID_BUFLEN); return virUUIDGeneratePseudoRandomBytes(uuid, VIR_UUID_BUFLEN);
} }

View File

@ -2265,8 +2265,9 @@ get_cpu_flags(virConnectPtr conn, const char **hvm, int *pae, int *longmode)
if ((fd = open("/dev/cpu/self/cpuid", O_RDONLY)) == -1 || if ((fd = open("/dev/cpu/self/cpuid", O_RDONLY)) == -1 ||
pread(fd, &regs, sizeof(regs), 0) != sizeof(regs)) { pread(fd, &regs, sizeof(regs), 0) != sizeof(regs)) {
char ebuf[1024];
virXenError(conn, VIR_ERR_SYSTEM_ERROR, virXenError(conn, VIR_ERR_SYSTEM_ERROR,
"couldn't read CPU flags: %s", strerror(errno)); "couldn't read CPU flags: %s", virStrerror(errno, ebuf, sizeof ebuf));
goto out; goto out;
} }