Skip to content

Commit fdc4fad

Browse files
committed
lib: include assert per file, remove side effects from asserts
1 parent b3026da commit fdc4fad

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+176
-131
lines changed

bin/xbps-install/transaction.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ exec_transaction(struct xbps_handle *xhp, unsigned int maxcols, bool yes, bool d
400400
trans->d = xhp->transd;
401401
trans->iter = xbps_array_iter_from_dict(xhp->transd, "packages");
402402
assert(trans->iter);
403+
/* XXX: assert with side effect */
403404

404405
/*
405406
* dry-run mode, show what would be done but don't run anything.

include/xbps_api_impl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#ifndef _XBPS_API_IMPL_H_
2828
#define _XBPS_API_IMPL_H_
2929

30-
#include <assert.h>
3130
#include "xbps.h"
3231

3332
/*

lib/archive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
*/
2525

26-
#include <stdio.h>
26+
#include <assert.h> /* safe */
2727
#include <stdbool.h>
2828
#include <stdlib.h>
2929
#include <string.h>

lib/conf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@
2929
#ifdef __FreeBSD__
3030
#define _WITH_GETLINE /* getline() */
3131
#endif
32+
33+
#include <assert.h>
3234
#include <ctype.h>
3335
#include <dirent.h>
3436
#include <errno.h>
3537
#include <glob.h>
3638
#include <libgen.h>
3739
#include <limits.h>
3840
#include <stdarg.h>
39-
#include <stdio.h>
4041
#include <stdlib.h>
4142
#include <string.h>
4243
#include <strings.h>

lib/download.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,11 @@
3030
* $FreeBSD: src/usr.bin/fetch/fetch.c,v 1.84.2.1 2009/08/03 08:13:06 kensmith Exp $
3131
*/
3232

33-
#include <sys/param.h>
34-
#include <sys/types.h>
35-
#include <sys/stat.h>
36-
#include <sys/time.h>
37-
#include <stdio.h>
38-
#include <stdlib.h>
39-
#include <string.h>
33+
#include <assert.h> /* safe */
4034
#include <errno.h>
4135
#include <fcntl.h>
42-
#include <sys/wait.h>
43-
#include <libgen.h>
36+
#include <stdlib.h>
37+
#include <string.h>
4438

4539
#include <openssl/sha.h>
4640

lib/external/dewey.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31+
#include <assert.h>
3132
#include <stdio.h>
3233
#include <stdlib.h>
3334
#define _BSD_SOURCE

lib/initend.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626

2727
#include <sys/utsname.h>
28+
29+
#include <assert.h> /* safe */
2830
#include <errno.h>
2931
#include <stdlib.h>
3032
#include <string.h>

lib/package_alternatives.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
2626

27-
#include <stdio.h>
27+
#include <assert.h>
28+
#include <errno.h>
29+
#include <libgen.h>
2830
#include <stdbool.h>
2931
#include <stdlib.h>
3032
#include <string.h>
31-
#include <errno.h>
32-
#include <libgen.h>
3333

3434
#include "xbps_api_impl.h"
3535

lib/package_config_files.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
*/
2525

26+
#include <assert.h>
2627
#include <errno.h>
2728
#include <limits.h>
2829
#include <stdio.h>

lib/package_configure.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@
2323
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
*/
2525

26+
#include <assert.h> /* safe */
27+
#include <errno.h>
2628
#include <stdio.h>
2729
#include <stdlib.h>
2830
#include <string.h>
29-
#include <errno.h>
3031

3132
#include "xbps_api_impl.h"
3233
/**
@@ -96,7 +97,7 @@ xbps_configure_pkg(struct xbps_handle *xhp,
9697
pkg_state_t state = 0;
9798
mode_t myumask;
9899

99-
assert(pkgver != NULL);
100+
assert(pkgver);
100101

101102
if (!xbps_pkg_name(pkgname, sizeof(pkgname), pkgver)) {
102103
p = pkgver;

0 commit comments

Comments
 (0)