1 |
commit: b7edba4e6c51901f40aefca78be5095e9dd434a4 |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Feb 7 02:58:50 2017 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Feb 7 02:58:50 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b7edba4e |
7 |
|
8 |
avoid assert() with active code |
9 |
|
10 |
Since assert can be compiled out via -DNDEBUG, make sure |
11 |
we don't put function calls in there we need to work. |
12 |
|
13 |
Reported-by: Ian Coolidge <icoolidge <AT> google.com> |
14 |
|
15 |
qmerge.c | 6 ++++-- |
16 |
qxpak.c | 4 +++- |
17 |
2 files changed, 7 insertions(+), 3 deletions(-) |
18 |
|
19 |
diff --git a/qmerge.c b/qmerge.c |
20 |
index e84fcbb..07da4cc 100644 |
21 |
--- a/qmerge.c |
22 |
+++ b/qmerge.c |
23 |
@@ -902,11 +902,13 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg) |
24 |
|
25 |
/* split the tbz and xpak data */ |
26 |
xasprintf(&tbz2, "%s/%s/%s.tbz2", pkgdir, pkg->CATEGORY, pkg->PF); |
27 |
- assert(run_applet_l("qtbz2", "-s", tbz2, NULL) == 0); |
28 |
+ if (run_applet_l("qtbz2", "-s", tbz2, NULL) != 0) |
29 |
+ err("`qtbz2 -s %s` failed", tbz2); |
30 |
|
31 |
mkdir("vdb", 0755); |
32 |
sprintf(tbz2, "%s.xpak", pkg->PF); |
33 |
- assert(run_applet_l("qxpak", "-d", "vdb", "-x", tbz2, NULL) == 0); |
34 |
+ if (run_applet_l("qxpak", "-d", "vdb", "-x", tbz2, NULL) != 0) |
35 |
+ err("`qxpak -d vdb -x %s` failed", tbz2); |
36 |
|
37 |
free(tbz2); |
38 |
|
39 |
|
40 |
diff --git a/qxpak.c b/qxpak.c |
41 |
index 58b29ef..95fb779 100644 |
42 |
--- a/qxpak.c |
43 |
+++ b/qxpak.c |
44 |
@@ -154,6 +154,7 @@ xpak_list(int dir_fd, const char *file, int argc, char **argv) |
45 |
{ |
46 |
_xpak_archive *x; |
47 |
char buf[BUFSIZE]; |
48 |
+ size_t ret; |
49 |
|
50 |
x = _xpak_open(file); |
51 |
if (!x) |
52 |
@@ -162,7 +163,8 @@ xpak_list(int dir_fd, const char *file, int argc, char **argv) |
53 |
x->dir_fd = dir_fd; |
54 |
x->index = buf; |
55 |
assert((size_t)x->index_len < sizeof(buf)); |
56 |
- assert(fread(x->index, 1, x->index_len, x->fp) == (size_t)x->index_len); |
57 |
+ ret = fread(x->index, 1, x->index_len, x->fp); |
58 |
+ assert(ret == (size_t)x->index_len); |
59 |
_xpak_walk_index(x, argc, argv, &_xpak_list_callback); |
60 |
|
61 |
_xpak_close(x); |