[libvirt] [PATCH 4/9] iptables.c: Use virStrerror, not strerror.

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

 



From: Jim Meyering <meyering@xxxxxxxxxx>

* src/iptables.c: Include "virterror_internal.h".
Use virStrerror, not strerror.
* src/virterror.c (virStrerror): Remove "static".
* src/virterror_internal.h (virStrerror): Declare it.
---
 src/iptables.c           |   25 ++++++++++++++++---------
 src/virterror.c          |    2 +-
 src/virterror_internal.h |    3 ++-
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/src/iptables.c b/src/iptables.c
index ad7fddf..81c976b 100644
--- a/src/iptables.c
+++ b/src/iptables.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008 Red Hat, Inc.
+ * Copyright (C) 2007-2009 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -44,6 +44,7 @@
 #include "iptables.h"
 #include "util.h"
 #include "memory.h"
+#include "virterror_internal.h"

 #define qemudLog(level, msg...) fprintf(stderr, msg)

@@ -98,9 +99,10 @@ notifyRulesUpdated(const char *table,
     argv[2] = arg;
     argv[3] = NULL;

+    char ebuf[1024];
     if (virRun(NULL, argv, NULL) < 0)
-        qemudLog(QEMUD_WARN, _("Failed to run '" LOKKIT_PATH
-                               " %s' : %s"), arg, strerror(errno));
+        qemudLog(QEMUD_WARN, _("Failed to run '" LOKKIT_PATH " %s': %s"),
+                 arg, virStrerror(errno, ebuf, sizeof ebuf));
 }

 static int
@@ -174,10 +176,11 @@ notifyRulesRemoved(const char *table,

     return;

- write_error:
+ write_error:;
+    char ebuf[1024];
     qemudLog(QEMUD_WARN, _("Failed to write to " SYSCONF_DIR
                            "/sysconfig/system-config-firewall : %s"),
-             strerror(errno));
+             virStrerror(errno, ebuf, sizeof ebuf));
     if (f)
         fclose(f);
     VIR_FREE(content);
@@ -239,15 +242,16 @@ iptRulesSave(iptRules *rules)
 #ifdef ENABLE_IPTABLES_LOKKIT
     int err;

+    char ebuf[1024];
     if ((err = virFileMakePath(rules->dir))) {
         qemudLog(QEMUD_WARN, _("Failed to create directory %s : %s"),
-                 rules->dir, strerror(err));
+                 rules->dir, virStrerror(err, ebuf, sizeof ebuf));
         return;
     }

     if ((err = writeRules(rules->path, rules->rules, rules->nrules))) {
         qemudLog(QEMUD_WARN, _("Failed to saves iptables rules to %s : %s"),
-                 rules->path, strerror(err));
+                 rules->path, virStrerror(err, ebuf, sizeof ebuf));
         return;
     }

@@ -540,6 +544,7 @@ static void
 iptRulesReload(iptRules *rules)
 {
     int i;
+    char ebuf[1024];

     for (i = 0; i < rules->nrules; i++) {
         iptRule *rule = &rules->rules[i];
@@ -552,7 +557,8 @@ iptRulesReload(iptRules *rules)
             qemudLog(QEMUD_WARN,
                      _("Failed to remove iptables rule '%s'"
                        " from chain '%s' in table '%s': %s"),
-                     rule->rule, rules->chain, rules->table, strerror(errno));
+                     rule->rule, rules->chain, rules->table,
+                     virStrerror(errno, ebuf, sizeof ebuf));

         rule->argv[rule->command_idx] = orig;
     }
@@ -561,7 +567,8 @@ iptRulesReload(iptRules *rules)
         if (virRun(NULL, rules->rules[i].argv, NULL) < 0)
             qemudLog(QEMUD_WARN, _("Failed to add iptables rule '%s'"
                                    " to chain '%s' in table '%s': %s"),
-                     rules->rules[i].rule, rules->chain, rules->table, strerror(errno));
+                     rules->rules[i].rule, rules->chain, rules->table,
+                     virStrerror(errno, ebuf, sizeof ebuf));
 }

 /**
diff --git a/src/virterror.c b/src/virterror.c
index 160fea3..6c479f4 100644
--- a/src/virterror.c
+++ b/src/virterror.c
@@ -1005,7 +1005,7 @@ void virReportErrorHelper(virConnectPtr conn, int domcode, int errcode,

 }

-static const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen)
+const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen)
 {
 #ifdef HAVE_STRERROR_R
 # ifdef __USE_GNU
diff --git a/src/virterror_internal.h b/src/virterror_internal.h
index 3a11705..709c8ec 100644
--- a/src/virterror_internal.h
+++ b/src/virterror_internal.h
@@ -1,7 +1,7 @@
 /*
  * virterror.h: internal error handling
  *
- * Copyright (C) 2006-2008 Red Hat, Inc.
+ * Copyright (C) 2006-2009 Red Hat, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -81,5 +81,6 @@ void virReportOOMErrorFull(virConnectPtr conn,

 void virSetGlobalError(void);
 void virSetConnError(virConnectPtr conn);
+const char *virStrerror(int theerrno, char *errBuf, size_t errBufLen);

 #endif
-- 
1.6.1.2.418.gd79e6

--
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]