[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 1/9] s/int/virLogPriority/ in logging code



From: "Daniel P. Berrange" <berrange redhat com>

The log priority levels are an enum, but most of the code was
just using a plain 'int' for function params / variables.

Signed-off-by: Daniel P. Berrange <berrange redhat com>
---
 src/util/logging.c | 34 +++++++++++++++++-----------------
 src/util/logging.h | 14 +++++++-------
 2 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/src/util/logging.c b/src/util/logging.c
index ae11267..4222b92 100644
--- a/src/util/logging.c
+++ b/src/util/logging.c
@@ -63,7 +63,7 @@ static int virLogEnd = 0;
  */
 struct _virLogFilter {
     const char *match;
-    int priority;
+    virLogPriority priority;
     unsigned int flags;
 };
 typedef struct _virLogFilter virLogFilter;
@@ -81,7 +81,7 @@ struct _virLogOutput {
     void *data;
     virLogOutputFunc f;
     virLogCloseFunc c;
-    int priority;
+    virLogPriority priority;
     virLogDestination dest;
     const char *name;
 };
@@ -98,7 +98,7 @@ static virLogPriority virLogDefaultPriority = VIR_LOG_DEFAULT;
 
 static int virLogResetFilters(void);
 static int virLogResetOutputs(void);
-static void virLogOutputToFd(const char *category, int priority,
+static void virLogOutputToFd(const char *category, virLogPriority priority,
                              const char *funcname, long long linenr,
                              const char *timestamp,
                              unsigned int flags,
@@ -418,7 +418,7 @@ virLogEmergencyDumpAll(int signum) {
  *
  * Returns 0 if successful, -1 in case of error.
  */
-int virLogSetDefaultPriority(int priority) {
+int virLogSetDefaultPriority(virLogPriority priority) {
     if ((priority < VIR_LOG_DEBUG) || (priority > VIR_LOG_ERROR)) {
         VIR_WARN("Ignoring invalid log level setting.");
         return -1;
@@ -460,7 +460,7 @@ static int virLogResetFilters(void) {
  *
  * Returns -1 in case of failure or the filter number if successful
  */
-int virLogDefineFilter(const char *match, int priority,
+int virLogDefineFilter(const char *match, virLogPriority priority,
                        unsigned int flags)
 {
     int i;
@@ -564,7 +564,7 @@ static int virLogResetOutputs(void) {
  * Returns -1 in case of failure or the output number if successful
  */
 int virLogDefineOutput(virLogOutputFunc f, virLogCloseFunc c, void *data,
-                       int priority, int dest, const char *name,
+                       virLogPriority priority, int dest, const char *name,
                        unsigned int flags)
 {
     int ret = -1;
@@ -606,7 +606,7 @@ static int
 virLogFormatString(char **msg,
                    const char *funcname,
                    long long linenr,
-                   int priority,
+                   virLogPriority priority,
                    const char *str)
 {
     int ret;
@@ -663,7 +663,7 @@ virLogVersionString(const char **rawmsg, char **msg)
  * Call the libvirt logger with some information. Based on the configuration
  * the message may be stored, sent to output or just discarded
  */
-void virLogMessage(const char *category, int priority, const char *funcname,
+void virLogMessage(const char *category, virLogPriority priority, const char *funcname,
                    long long linenr, unsigned int flags, const char *fmt, ...)
 {
     va_list ap;
@@ -685,7 +685,7 @@ void virLogMessage(const char *category, int priority, const char *funcname,
  * Call the libvirt logger with some information. Based on the configuration
  * the message may be stored, sent to output or just discarded
  */
-void virLogVMessage(const char *category, int priority, const char *funcname,
+void virLogVMessage(const char *category, virLogPriority priority, const char *funcname,
                     long long linenr, unsigned int flags, const char *fmt,
                     va_list vargs)
 {
@@ -811,7 +811,7 @@ static void virLogStackTraceToFd(int fd)
 }
 
 static void virLogOutputToFd(const char *category ATTRIBUTE_UNUSED,
-                             int priority ATTRIBUTE_UNUSED,
+                             virLogPriority priority ATTRIBUTE_UNUSED,
                              const char *funcname ATTRIBUTE_UNUSED,
                              long long linenr ATTRIBUTE_UNUSED,
                              const char *timestamp,
@@ -843,14 +843,14 @@ static void virLogCloseFd(void *data)
     VIR_LOG_CLOSE(fd);
 }
 
-static int virLogAddOutputToStderr(int priority) {
+static int virLogAddOutputToStderr(virLogPriority priority) {
     if (virLogDefineOutput(virLogOutputToFd, NULL, (void *)2L, priority,
                            VIR_LOG_TO_STDERR, NULL, 0) < 0)
         return -1;
     return 0;
 }
 
-static int virLogAddOutputToFile(int priority, const char *file) {
+static int virLogAddOutputToFile(virLogPriority priority, const char *file) {
     int fd;
 
     fd = open(file, O_CREAT | O_APPEND | O_WRONLY, S_IRUSR | S_IWUSR);
@@ -883,7 +883,7 @@ static int virLogPrioritySyslog(virLogPriority priority)
 }
 
 static void virLogOutputToSyslog(const char *category ATTRIBUTE_UNUSED,
-                                 int priority,
+                                 virLogPriority priority,
                                  const char *funcname ATTRIBUTE_UNUSED,
                                  long long linenr ATTRIBUTE_UNUSED,
                                  const char *timestamp ATTRIBUTE_UNUSED,
@@ -904,7 +904,7 @@ static void virLogCloseSyslog(void *data ATTRIBUTE_UNUSED) {
     VIR_FREE(current_ident);
 }
 
-static int virLogAddOutputToSyslog(int priority, const char *ident) {
+static int virLogAddOutputToSyslog(virLogPriority priority, const char *ident) {
     /*
      * ident needs to be kept around on Solaris
      */
@@ -955,7 +955,7 @@ int virLogParseOutputs(const char *outputs) {
     const char *cur = outputs, *str;
     char *name;
     char *abspath;
-    int prio;
+    virLogPriority prio;
     int ret = -1;
     int count = 0;
 
@@ -1046,7 +1046,7 @@ cleanup:
 int virLogParseFilters(const char *filters) {
     const char *cur = filters, *str;
     char *name;
-    int prio;
+    virLogPriority prio;
     int ret = -1;
     int count = 0;
 
@@ -1091,7 +1091,7 @@ cleanup:
  *
  * Returns the current logging priority level.
  */
-int virLogGetDefaultPriority(void) {
+virLogPriority virLogGetDefaultPriority(void) {
     return virLogDefaultPriority;
 }
 
diff --git a/src/util/logging.h b/src/util/logging.h
index 584e2b4..88fb785 100644
--- a/src/util/logging.h
+++ b/src/util/logging.h
@@ -96,7 +96,7 @@ typedef enum {
  *
  * Callback function used to output messages
  */
-typedef void (*virLogOutputFunc) (const char *category, int priority,
+typedef void (*virLogOutputFunc) (const char *category, virLogPriority priority,
                                   const char *funcname, long long linenr,
                                   const char *timestamp,
                                   unsigned int flags,
@@ -119,13 +119,13 @@ extern int virLogGetNbFilters(void);
 extern int virLogGetNbOutputs(void);
 extern char *virLogGetFilters(void);
 extern char *virLogGetOutputs(void);
-extern int virLogGetDefaultPriority(void);
-extern int virLogSetDefaultPriority(int priority);
+extern virLogPriority virLogGetDefaultPriority(void);
+extern int virLogSetDefaultPriority(virLogPriority priority);
 extern void virLogSetFromEnv(void);
-extern int virLogDefineFilter(const char *match, int priority,
+extern int virLogDefineFilter(const char *match, virLogPriority priority,
                               unsigned int flags);
 extern int virLogDefineOutput(virLogOutputFunc f, virLogCloseFunc c, void *data,
-                              int priority, int dest, const char *name,
+                              virLogPriority priority, int dest, const char *name,
                               unsigned int flags);
 
 /*
@@ -138,11 +138,11 @@ extern int virLogReset(void);
 extern int virLogParseDefaultPriority(const char *priority);
 extern int virLogParseFilters(const char *filters);
 extern int virLogParseOutputs(const char *output);
-extern void virLogMessage(const char *category, int priority,
+extern void virLogMessage(const char *category, virLogPriority priority,
                           const char *funcname, long long linenr,
                           unsigned int flags,
                           const char *fmt, ...) ATTRIBUTE_FMT_PRINTF(6, 7);
-extern void virLogVMessage(const char *category, int priority,
+extern void virLogVMessage(const char *category, virLogPriority priority,
                            const char *funcname, long long linenr,
                            unsigned int flags,
                            const char *fmt,
-- 
1.7.11.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]