[PATCH 01/38] virlog: Return void instead of int in virLogReset<Foo> methods

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

 



In this particular case, reset is meant as clearing the whole list of
outputs/filters, not resetting it to a predefined default setting. Looking at
it from that perspective, returning the number of records removed doesn't help
the caller in any way (not that any of the callers would actually check for
it). Well, callers could detect an error from the number of successfully
removed records, but the only thing that can fail in virLogReset is force
closing a file descriptor in which case the error isn't propagated back to
virLogReset anyway. Conclusion: there is no practical use for having a return
type of 'int' rather than 'void' in this case.
---
 src/util/virlog.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/src/util/virlog.c b/src/util/virlog.c
index 738eaac..6d11328 100644
--- a/src/util/virlog.c
+++ b/src/util/virlog.c
@@ -117,8 +117,8 @@ static int virLogNbOutputs;
  */
 static virLogPriority virLogDefaultPriority = VIR_LOG_DEFAULT;
 
-static int virLogResetFilters(void);
-static int virLogResetOutputs(void);
+static void virLogResetFilters(void);
+static void virLogResetOutputs(void);
 static void virLogOutputToFd(virLogSourcePtr src,
                              virLogPriority priority,
                              const char *filename,
@@ -239,10 +239,8 @@ virLogSetDefaultPriority(virLogPriority priority)
  * virLogResetFilters:
  *
  * Removes the set of logging filters defined.
- *
- * Returns the number of filters removed
  */
-static int
+static void
 virLogResetFilters(void)
 {
     size_t i;
@@ -252,7 +250,6 @@ virLogResetFilters(void)
     VIR_FREE(virLogFilters);
     virLogNbFilters = 0;
     virLogFiltersSerial++;
-    return i;
 }
 
 
@@ -319,10 +316,8 @@ virLogDefineFilter(const char *match,
  * virLogResetOutputs:
  *
  * Removes the set of logging output defined.
- *
- * Returns the number of output removed
  */
-static int
+static void
 virLogResetOutputs(void)
 {
     size_t i;
@@ -333,9 +328,7 @@ virLogResetOutputs(void)
         VIR_FREE(virLogOutputs[i].name);
     }
     VIR_FREE(virLogOutputs);
-    i = virLogNbOutputs;
     virLogNbOutputs = 0;
-    return i;
 }
 
 
-- 
2.4.3

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]