[cowdancer] 03/05: Fix miscellaneous issues found by clang-tidy
James Clarke
jrtc27 at moszumanska.debian.org
Wed Jan 18 18:50:40 UTC 2017
This is an automated email from the git hooks/post-receive script.
jrtc27 pushed a commit to branch master
in repository cowdancer.
commit 9e86b9f9fa17c721b51e0c59e4b00ecc32380285
Author: James Clarke <jrtc27 at debian.org>
Date: Wed Jan 18 17:43:30 2017 +0000
Fix miscellaneous issues found by clang-tidy
---
cowdancer.c | 2 ++
forkexec.c | 3 ++-
ilistcreate.c | 7 +++++++
qemubuilder.c | 16 +++++++++++++++-
4 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/cowdancer.c b/cowdancer.c
index 4ad4bc7..4e7332c 100644
--- a/cowdancer.c
+++ b/cowdancer.c
@@ -125,12 +125,14 @@ static int load_ilist(void) {
}
fread(&header, sizeof(struct ilist_header), 1, f);
if (verify_ilist_header(header)) {
+ free(local_ilist);
return 1;
}
fread(local_ilist, sizeof(struct ilist_struct), local_ilist_len, f);
fclose(f);
} else {
if (verify_ilist_header(*(struct ilist_header *)local_ilist)) {
+ munmap(local_ilist, stbuf.st_size);
return 1;
}
local_ilist = (void *)local_ilist + sizeof(struct ilist_header);
diff --git a/forkexec.c b/forkexec.c
index e3a2dfa..68fcc2c 100644
--- a/forkexec.c
+++ b/forkexec.c
@@ -19,11 +19,12 @@
*/
#define _GNU_SOURCE
+#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
-#include <stdarg.h>
#include "parameter.h"
/*
diff --git a/ilistcreate.c b/ilistcreate.c
index c7459c1..59c1818 100644
--- a/ilistcreate.c
+++ b/ilistcreate.c
@@ -38,6 +38,7 @@ int ilistcreate(const char *ilistpath, const char *findcommandline) {
ilist_len = 2000;
if (NULL == (inf = popen(findcommandline, "r"))) {
ilist_outofmemory("popen find failed");
+ free(ilist);
return 1;
}
@@ -56,6 +57,7 @@ int ilistcreate(const char *ilistpath, const char *findcommandline) {
if (!ilist) {
ilist_outofmemory("realloc failed");
pclose(inf);
+ free(ilist);
return 1;
}
}
@@ -64,6 +66,7 @@ int ilistcreate(const char *ilistpath, const char *findcommandline) {
if (pclose(inf)) {
ilist_outofmemory(
"pclose returned non-zero, probably the directory contains no hardlinked file, don't bother using cow-shell here.");
+ free(ilist);
return 1;
}
@@ -73,22 +76,26 @@ int ilistcreate(const char *ilistpath, const char *findcommandline) {
/* write out the ilist file */
if (NULL == (outf = fopen(ilistpath, "w"))) {
ilist_outofmemory("cannot open .ilist file");
+ free(ilist);
return 1;
}
if (1 != fwrite(&header, sizeof(struct ilist_header), 1, outf)) {
ilist_outofmemory("failed writing header to .ilist file");
+ free(ilist);
return 1;
}
if (ilist_len !=
fwrite(ilist, sizeof(struct ilist_struct), ilist_len, outf)) {
ilist_outofmemory("failed writing to .ilist file");
+ free(ilist);
return 1;
}
if (fclose(outf)) {
ilist_outofmemory("error flushing to .ilist file");
+ free(ilist);
return 1;
}
return 0;
diff --git a/qemubuilder.c b/qemubuilder.c
index 340bc5b..c6e81bf 100644
--- a/qemubuilder.c
+++ b/qemubuilder.c
@@ -408,7 +408,6 @@ fork_qemu(const char *hda, const char *hdb, const struct pbuilderconfig *pc) {
fd_set readfds;
int exit_code = -1;
const int buffer_size = 4096;
- char *buf = malloc(buffer_size);
size_t count;
if (-1 == socketpair(AF_UNIX, SOCK_STREAM, 0, sp)) {
@@ -421,6 +420,7 @@ fork_qemu(const char *hda, const char *hdb, const struct pbuilderconfig *pc) {
fflush(NULL);
if ((child = fork())) {
/* this is parent process */
+ char *buf = malloc(buffer_size);
close(sp[1]);
close(0);
@@ -476,6 +476,8 @@ fork_qemu(const char *hda, const char *hdb, const struct pbuilderconfig *pc) {
break;
}
}
+
+ free(buf);
} else if (child == 0) {
/* this is the child process */
const char *qemu = qemu_arch_qemu(pc->arch);
@@ -933,6 +935,9 @@ static int run_second_stage_script(
pc->basepath,
cowdevpath,
NULL);
+ if (ret) {
+ goto out;
+ }
fork_qemu(cowdevpath, workblockdevicepath, pc);
/* this will always return 0. */
@@ -941,6 +946,9 @@ static int run_second_stage_script(
if (save_result) {
log_printf(log_info, "committing changes to qemu image");
ret = forkexeclp("qemu-img", "qemu-img", "commit", cowdevpath, NULL);
+ if (ret) {
+ goto out;
+ }
}
/* after-run */
@@ -1129,10 +1137,16 @@ int cpbuilder_create(const struct pbuilderconfig *pc) {
s = 0;
ret = loop_umount(pc->buildplace);
+ if (ret) {
+ goto out;
+ }
/* create the temporary device for command-execution */
asprintf(&workblockdevicepath, "%s.dev", pc->buildplace);
ret = create_ext3_block_device(workblockdevicepath, 1);
+ if (ret) {
+ goto out;
+ }
loop_mount(workblockdevicepath, pc->buildplace);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pbuilder/cowdancer.git
More information about the Pbuilder-maint
mailing list