aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2012-09-20 20:24:00 +0200
committerEric Blake <eblake@redhat.com>2012-09-21 12:55:13 -0600
commitfca338a06c54f272f05aa12e362279e113130284 (patch)
tree76854ccc24fe3760ceaae9b5d399fa5a4ebf6acb
parentRemove redundant lines in src/qemu/qemu_driver.c (diff)
downloadlibvirt-fca338a06c54f272f05aa12e362279e113130284.tar.gz
libvirt-fca338a06c54f272f05aa12e362279e113130284.tar.bz2
libvirt-fca338a06c54f272f05aa12e362279e113130284.zip
Drop unused return value of virLogOutputFunc
Nothing uses the return value, and creating it requries otherwise unnecessary strlen () calls. This cleanup is conceptually independent from the rest of the series (although the later patches won't apply without it). This just seems a good opportunity to clean this up, instead of entrenching the unnecessary return value in the virLogOutputFunc instance that will be added in this series. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
-rw-r--r--src/util/logging.c56
-rw-r--r--src/util/logging.h14
-rw-r--r--tests/testutils.c5
3 files changed, 34 insertions, 41 deletions
diff --git a/src/util/logging.c b/src/util/logging.c
index bc76a2dc2..cdaf86ebf 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -98,12 +98,12 @@ static virLogPriority virLogDefaultPriority = VIR_LOG_DEFAULT;
static int virLogResetFilters(void);
static int virLogResetOutputs(void);
-static int virLogOutputToFd(const char *category, int priority,
- const char *funcname, long long linenr,
- const char *timestamp,
- unsigned int flags,
- const char *str,
- void *data);
+static void virLogOutputToFd(const char *category, int priority,
+ const char *funcname, long long linenr,
+ const char *timestamp,
+ unsigned int flags,
+ const char *str,
+ void *data);
/*
* Logs accesses must be serialized though a mutex
@@ -807,32 +807,29 @@ static void virLogStackTraceToFd(int fd)
#undef STRIP_DEPTH
}
-static int virLogOutputToFd(const char *category ATTRIBUTE_UNUSED,
- int priority ATTRIBUTE_UNUSED,
- const char *funcname ATTRIBUTE_UNUSED,
- long long linenr ATTRIBUTE_UNUSED,
- const char *timestamp,
- unsigned int flags,
- const char *str,
- void *data)
+static void virLogOutputToFd(const char *category ATTRIBUTE_UNUSED,
+ int priority ATTRIBUTE_UNUSED,
+ const char *funcname ATTRIBUTE_UNUSED,
+ long long linenr ATTRIBUTE_UNUSED,
+ const char *timestamp,
+ unsigned int flags,
+ const char *str,
+ void *data)
{
int fd = (intptr_t) data;
- int ret;
char *msg;
if (fd < 0)
- return -1;
+ return;
if (virAsprintf(&msg, "%s: %s", timestamp, str) < 0)
- return -1;
+ return;
- ret = safewrite(fd, msg, strlen(msg));
+ ignore_value(safewrite(fd, msg, strlen(msg)));
VIR_FREE(msg);
if (flags & VIR_LOG_STACK_TRACE)
virLogStackTraceToFd(fd);
-
- return ret;
}
static void virLogCloseFd(void *data)
@@ -865,18 +862,18 @@ static int virLogAddOutputToFile(int priority, const char *file) {
}
#if HAVE_SYSLOG_H
-static int virLogOutputToSyslog(const char *category ATTRIBUTE_UNUSED,
- int priority,
- const char *funcname ATTRIBUTE_UNUSED,
- long long linenr ATTRIBUTE_UNUSED,
- const char *timestamp ATTRIBUTE_UNUSED,
- unsigned int flags,
- const char *str,
- void *data ATTRIBUTE_UNUSED)
+static void virLogOutputToSyslog(const char *category ATTRIBUTE_UNUSED,
+ int priority,
+ const char *funcname ATTRIBUTE_UNUSED,
+ long long linenr ATTRIBUTE_UNUSED,
+ const char *timestamp ATTRIBUTE_UNUSED,
+ unsigned int flags,
+ const char *str,
+ void *data ATTRIBUTE_UNUSED)
{
int prio;
- virCheckFlags(VIR_LOG_STACK_TRACE, -1);
+ virCheckFlags(VIR_LOG_STACK_TRACE,);
switch (priority) {
case VIR_LOG_DEBUG:
@@ -895,7 +892,6 @@ static int virLogOutputToSyslog(const char *category ATTRIBUTE_UNUSED,
prio = LOG_ERR;
}
syslog(prio, "%s", str);
- return strlen(str);
}
static char *current_ident = NULL;
diff --git a/src/util/logging.h b/src/util/logging.h
index 04a613e23..256e81699 100644
--- a/src/util/logging.h
+++ b/src/util/logging.h
@@ -94,15 +94,13 @@ typedef enum {
* @data: extra output logging data
*
* Callback function used to output messages
- *
- * Returns the number of bytes written or -1 in case of error
*/
-typedef int (*virLogOutputFunc) (const char *category, int priority,
- const char *funcname, long long linenr,
- const char *timestamp,
- unsigned int flags,
- const char *str,
- void *data);
+typedef void (*virLogOutputFunc) (const char *category, int priority,
+ const char *funcname, long long linenr,
+ const char *timestamp,
+ unsigned int flags,
+ const char *str,
+ void *data);
/**
* virLogCloseFunc:
diff --git a/tests/testutils.c b/tests/testutils.c
index 34edde977..b555e0621 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -478,7 +478,7 @@ struct virtTestLogData {
static struct virtTestLogData testLog = { VIR_BUFFER_INITIALIZER };
-static int
+static void
virtTestLogOutput(const char *category ATTRIBUTE_UNUSED,
int priority ATTRIBUTE_UNUSED,
const char *funcname ATTRIBUTE_UNUSED,
@@ -489,9 +489,8 @@ virtTestLogOutput(const char *category ATTRIBUTE_UNUSED,
void *data)
{
struct virtTestLogData *log = data;
- virCheckFlags(VIR_LOG_STACK_TRACE, -1);
+ virCheckFlags(VIR_LOG_STACK_TRACE,);
virBufferAsprintf(&log->buf, "%s: %s", timestamp, str);
- return strlen(timestamp) + 2 + strlen(str);
}
static void