Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Cosmetic changes
Alexandre Perrin committed 11 years ago
commit 734943426a1c525fc35b38aa50a59b717bcfb43e
parent 157666d
7 files changed +10 -11
modified libpkg/pkg.h.in
@@ -72,6 +72,10 @@
#define __DECONST(type, var)    ((type)(uintptr_t)(const void *)(var))
#endif

+
#ifndef NELEM
+
#define NELEM(array)    (sizeof(array) / sizeof((array)[0]))
+
#endif
+

/* Special exit status for worker processes indicating that a restart
 * is desired -- eg. after a child has updated pkg(8) itself.  Don't
 * clash with any of the sysexits values */
modified libpkg/pkg_repo.c
@@ -339,7 +339,7 @@ pkg_repo_meta_extract_signature_fingerprints(int fd, void *ud)
			iov[3].iov_len = sizeof(siglen);
			iov[4].iov_base = sig;
			iov[4].iov_len = siglen;
-
			if (writev(fd, iov, sizeof(iov) / sizeof(iov[0])) == -1) {
+
			if (writev(fd, iov, NELEM(iov)) == -1) {
				pkg_emit_errno("pkg_repo_meta_extract_signature",
						"writev failed");
				free(sig);
@@ -378,7 +378,7 @@ pkg_repo_meta_extract_signature_fingerprints(int fd, void *ud)
			iov[3].iov_len = sizeof(siglen);
			iov[4].iov_base = sig;
			iov[4].iov_len = siglen;
-
			if (writev(fd, iov, sizeof(iov) / sizeof(iov[0])) == -1) {
+
			if (writev(fd, iov, NELEM(iov)) == -1) {
				pkg_emit_errno("pkg_repo_meta_extract_signature",
						"writev failed");
				free(sig);
modified libpkg/private/utils.h
@@ -53,10 +53,6 @@
#define HASH_ADD_INO(head,ino,add)                                          \
	HASH_ADD(hh,head,ino,sizeof(ino_t),add)

-
#ifndef NELEM
-
#define	NELEM(array)	(sizeof(array) / sizeof((array)[0]))
-
#endif
-

struct hardlinks {
	ino_t inode;
	UT_hash_handle hh;
modified libpkg/repo/binary/update.c
@@ -534,8 +534,7 @@ cleanup:
			rc = EPKG_FATAL;
	}

-
	if (pkg != NULL)
-
		pkg_free(pkg);
+
	pkg_free(pkg);
	if (map != NULL && map != MAP_FAILED)
		munmap(map, len);

modified src/main.c
@@ -116,7 +116,7 @@ static struct commands {
	{ "which", "Displays which package installed a specific file", exec_which, usage_which},
};

-
static const unsigned int cmd_len = sizeof(cmd) / sizeof(cmd[0]);
+
static const unsigned int cmd_len = NELEM(cmd);

static STAILQ_HEAD(, plugcmd) plugins = STAILQ_HEAD_INITIALIZER(plugins);
struct plugcmd {
modified src/query.c
@@ -818,7 +818,7 @@ exec_query(int argc, char **argv)
	char			 multiline = 0;
	char			*condition = NULL;
	struct sbuf		*sqlcond = NULL;
-
	const unsigned int	 q_flags_len = (sizeof(accepted_query_flags)/sizeof(accepted_query_flags[0]));
+
	const unsigned int	 q_flags_len = NELEM(accepted_query_flags);

	struct option longopts[] = {
		{ "all",		no_argument,		NULL,	'a' },
modified src/rquery.c
@@ -118,7 +118,7 @@ exec_rquery(int argc, char **argv)
	char			*condition = NULL;
	const char		*portsdir;
	struct sbuf		*sqlcond = NULL;
-
	const unsigned int	 q_flags_len = (sizeof(accepted_rquery_flags)/sizeof(accepted_rquery_flags[0]));
+
	const unsigned int	 q_flags_len = NELEM(accepted_rquery_flags);
	const char		*reponame = NULL;
	bool			 auto_update;
	bool			 onematched = false;