iptables.c: Use virStrerror, not strerror.

* src/iptables.c: Include "virterror_internal.h".
Use virStrerror, not strerror.
* src/iptables.c (notifyRulesUpdated): Use %s rather than
string-concatenation that made sc_unmarked_diagnostics report
a false-positive.
This commit is contained in:
Jim Meyering 2009-02-05 16:27:51 +00:00
parent dcfa920aff
commit 1e31bfb055
2 changed files with 24 additions and 8 deletions

View File

@ -1,3 +1,12 @@
Thu Feb 5 17:03:35 +0100 2009 Jim Meyering <meyering@redhat.com>
iptables.c: Use virStrerror, not strerror.
* src/iptables.c: Include "virterror_internal.h".
Use virStrerror, not strerror.
* src/iptables.c (notifyRulesUpdated): Use %s rather than
string-concatenation that made sc_unmarked_diagnostics report
a false-positive.
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>
use virReportOOMError rather than more verbose equivalent use virReportOOMError rather than more verbose equivalent

View File

@ -44,6 +44,7 @@
#include "iptables.h" #include "iptables.h"
#include "util.h" #include "util.h"
#include "memory.h" #include "memory.h"
#include "virterror_internal.h"
#define qemudLog(level, msg...) fprintf(stderr, msg) #define qemudLog(level, msg...) fprintf(stderr, msg)
@ -98,9 +99,10 @@ notifyRulesUpdated(const char *table,
argv[2] = arg; argv[2] = arg;
argv[3] = NULL; argv[3] = NULL;
char ebuf[1024];
if (virRun(NULL, argv, NULL) < 0) if (virRun(NULL, argv, NULL) < 0)
qemudLog(QEMUD_WARN, _("Failed to run '" LOKKIT_PATH qemudLog(QEMUD_WARN, _("Failed to run '%s %s': %s"),
" %s' : %s"), arg, strerror(errno)); LOKKIT_PATH, arg, virStrerror(errno, ebuf, sizeof ebuf));
} }
static int static int
@ -174,10 +176,11 @@ notifyRulesRemoved(const char *table,
return; return;
write_error: write_error:;
char ebuf[1024];
qemudLog(QEMUD_WARN, _("Failed to write to " SYSCONF_DIR qemudLog(QEMUD_WARN, _("Failed to write to " SYSCONF_DIR
"/sysconfig/system-config-firewall : %s"), "/sysconfig/system-config-firewall : %s"),
strerror(errno)); virStrerror(errno, ebuf, sizeof ebuf));
if (f) if (f)
fclose(f); fclose(f);
VIR_FREE(content); VIR_FREE(content);
@ -239,15 +242,16 @@ iptRulesSave(iptRules *rules)
#ifdef ENABLE_IPTABLES_LOKKIT #ifdef ENABLE_IPTABLES_LOKKIT
int err; int err;
char ebuf[1024];
if ((err = virFileMakePath(rules->dir))) { if ((err = virFileMakePath(rules->dir))) {
qemudLog(QEMUD_WARN, _("Failed to create directory %s : %s"), qemudLog(QEMUD_WARN, _("Failed to create directory %s : %s"),
rules->dir, strerror(err)); rules->dir, virStrerror(err, ebuf, sizeof ebuf));
return; return;
} }
if ((err = writeRules(rules->path, rules->rules, rules->nrules))) { if ((err = writeRules(rules->path, rules->rules, rules->nrules))) {
qemudLog(QEMUD_WARN, _("Failed to saves iptables rules to %s : %s"), qemudLog(QEMUD_WARN, _("Failed to saves iptables rules to %s : %s"),
rules->path, strerror(err)); rules->path, virStrerror(err, ebuf, sizeof ebuf));
return; return;
} }
@ -537,6 +541,7 @@ static void
iptRulesReload(iptRules *rules) iptRulesReload(iptRules *rules)
{ {
int i; int i;
char ebuf[1024];
for (i = 0; i < rules->nrules; i++) { for (i = 0; i < rules->nrules; i++) {
iptRule *rule = &rules->rules[i]; iptRule *rule = &rules->rules[i];
@ -549,7 +554,8 @@ iptRulesReload(iptRules *rules)
qemudLog(QEMUD_WARN, qemudLog(QEMUD_WARN,
_("Failed to remove iptables rule '%s'" _("Failed to remove iptables rule '%s'"
" from chain '%s' in table '%s': %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; rule->argv[rule->command_idx] = orig;
} }
@ -558,7 +564,8 @@ iptRulesReload(iptRules *rules)
if (virRun(NULL, rules->rules[i].argv, NULL) < 0) if (virRun(NULL, rules->rules[i].argv, NULL) < 0)
qemudLog(QEMUD_WARN, _("Failed to add iptables rule '%s'" qemudLog(QEMUD_WARN, _("Failed to add iptables rule '%s'"
" to chain '%s' in table '%s': %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));
} }
/** /**