[PATCH 0/3] A few fixes to placate Coverity
by Laine Stump
Admittedly patch 1 was a legitimate leak....
Laine Stump (3):
Fix memory leak in aug_match_mac()
remove unused variable in aug_match_mac()
Make the empty body of for loops more obvious
src/dutil_linux.c | 4 ++--
src/ncftool.c | 9 ++++++---
2 files changed, 8 insertions(+), 5 deletions(-)
--
2.14.4
5 years, 7 months
[PATCH] build: Silence gcc warnings
by Eric Blake
The first warning is obvious:
xslt_ext.c: In function 'ipcalc_netmask':
xslt_ext.c:72:53: warning: format '%d' expects argument of type 'int', but argument 5 has type 'long unsigned int' [-Wformat=]
"ipcalc:netmask: prefix %d not in the range 1 to 32", prefix);
~^ ~~~~~~
%ld
The second warning looks like it was intended to have a const pointer
to const contents, where the second 'const' was misplaced instead of
duplicated:
ncftool.c:96:33: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
static const struct command_def const *commands[];
^~~~~
ncftool.c:676:33: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]
static const struct command_def const *commands[] = {
^~~~~
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/ncftool.c | 4 ++--
src/xslt_ext.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/ncftool.c b/src/ncftool.c
index f1b5642..382c91d 100644
--- a/src/ncftool.c
+++ b/src/ncftool.c
@@ -93,7 +93,7 @@ struct command_opt {
/* Global variables */
-static const struct command_def const *commands[];
+static const struct command_def *const commands[];
struct netcf *ncf;
static const char *const progname = "ncftool";
@@ -673,7 +673,7 @@ static int parseline(struct command *cmd, char *line) {
return 0;
}
-static const struct command_def const *commands[] = {
+static const struct command_def *const commands[] = {
&cmd_list_def,
&cmd_dump_xml_def,
&cmd_define_def,
diff --git a/src/xslt_ext.c b/src/xslt_ext.c
index fec2c21..14e5f23 100644
--- a/src/xslt_ext.c
+++ b/src/xslt_ext.c
@@ -69,6 +69,6 @@ static void ipcalc_netmask(xmlXPathParserContextPtr ctxt, int nargs) {
if (prefix == 0 || prefix > 32) {
xsltTransformError(xsltXPathGetTransformContext(ctxt), NULL, NULL,
- "ipcalc:netmask: prefix %d not in the range 1 to 32", prefix);
+ "ipcalc:netmask: prefix %lu not in the range 1 to 32", prefix);
goto error;
}
--
2.17.1
5 years, 7 months
[PATCH] dutil_posix: Fix incorrect logic on waitpid
by Eric Blake
Detected by dcb:
dutil_posix.c:225]: (style) Suspicious condition (assignment + comparison); Clarify expression with parentheses.
Without the patch, waitret can only ever be 0 or 1, which renders
the next line's check for -1 dead code.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/dutil_posix.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/dutil_posix.c b/src/dutil_posix.c
index 1313514..11ccff6 100644
--- a/src/dutil_posix.c
+++ b/src/dutil_posix.c
@@ -220,7 +220,7 @@ int run_program(struct netcf *ncf, const char *const *argv, char **output)
fclose(outfile);
outfile = NULL;
- while ((waitret = waitpid(childpid, &exitstatus, 0) == -1) &&
+ while (((waitret = waitpid(childpid, &exitstatus, 0)) == -1) &&
errno == EINTR) {
/* empty loop */
}
--
2.17.1
5 years, 7 months