Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
STR*EQ: use macros where possible
Baptiste Daroussin committed 1 year ago
commit 053f4a2a09ad837b30d2085829753421d31e4013
parent a3109ca
56 files changed +315 -293
modified libpkg/clean_cache.c
@@ -61,7 +61,7 @@ rm_rf(int basefd, const char *path)

	d = fdopendir(dirfd);
	while ((e = readdir(d)) != NULL) {
-
		if (strcmp(e->d_name, ".") == 0 || strcmp(e->d_name, "..") == 0)
+
		if (STREQ(e->d_name, ".") || STREQ(e->d_name, ".."))
			continue;
		if (fstatat(dirfd, e->d_name, &st, AT_SYMLINK_NOFOLLOW) != 0) {
			pkg_emit_errno("fstatat", path);
modified libpkg/elfhints.c
@@ -184,7 +184,7 @@ add_dir(const char *hintsfile, const char *name, int trusted)
	}

	for (i = 0;  i < ndirs;  i++)
-
		if (strcmp(dirs[i], name) == 0)
+
		if (STREQ(dirs[i], name))
			return;
	if (ndirs >= MAXDIRS)
		errx(1, "\"%s\": Too many directories in path", hintsfile);
modified libpkg/fetch_libfetch.c
@@ -132,7 +132,7 @@ fetch_connect(struct pkg_repo *repo, struct url *u)
			} else if (repo != NULL && repo->mirror_type == HTTP &&
			    strncmp(u->scheme, "http", 4) == 0) {
				if (u->port == 0) {
-
					if (strcmp(u->scheme, "https") == 0)
+
					if (STREQ(u->scheme, "https"))
						u->port = 443;
					else
						u->port = 80;
modified libpkg/lua.c
@@ -557,7 +557,7 @@ lua_readdir(lua_State *L)
	int i = 0;
	while ((e = readdir(dir))) {
		char *name = e->d_name;
-
		if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
+
		if (STREQ(name, ".") || STREQ(name, ".."))
			continue;
		lua_pushinteger(L, ++i);
		lua_pushstring(L, name);
modified libpkg/packing.c
@@ -424,15 +424,15 @@ packing_format_from_string(const char *str)
{
	if (str == NULL)
		return DEFAULT_COMPRESSION;
-
	if (strcmp(str, "tzst") == 0)
+
	if (STREQ(str, "tzst"))
		return TZS;
-
	if (strcmp(str, "txz") == 0)
+
	if (STREQ(str, "txz"))
		return TXZ;
-
	if (strcmp(str, "tbz") == 0)
+
	if (STREQ(str, "tbz"))
		return TBZ;
-
	if (strcmp(str, "tgz") == 0)
+
	if (STREQ(str, "tgz"))
		return TGZ;
-
	if (strcmp(str, "tar") == 0)
+
	if (STREQ(str, "tar"))
		return TAR;
	pkg_emit_error("unknown format %s, using txz", str);
	return TXZ;
@@ -443,12 +443,12 @@ packing_is_valid_format(const char *str)
{
	if (str == NULL)
		return (false);
-
	if ((strcmp(str, "pkg") == 0) ||
-
	    (strcmp(str, "tzst") == 0) ||
-
	    (strcmp(str, "txz") == 0) ||
-
	    (strcmp(str, "tbz") == 0) ||
-
	    (strcmp(str, "tgz") == 0) ||
-
	    (strcmp(str, "tar") == 0))
+
	if (STREQ(str, "pkg") ||
+
	    STREQ(str, "tzst") ||
+
	    STREQ(str, "txz") ||
+
	    STREQ(str, "tbz") ||
+
	    STREQ(str, "tgz") ||
+
	    STREQ(str, "tar"))
	    return (true);
	return (false);
}
modified libpkg/pkg.c
@@ -402,7 +402,7 @@ pkg_adduser(struct pkg *pkg, const char *name)
	assert(name != NULL && name[0] != '\0');

	tll_foreach(pkg->users, u) {
-
		if (strcmp(u->item, name) != 0)
+
		if (!STREQ(u->item, name))
			continue;
		if (ctx.developer_mode) {
			pkg_emit_error("duplicate user listing: %s, fatal (developer mode)", name);
@@ -424,7 +424,7 @@ pkg_addgroup(struct pkg *pkg, const char *name)
	assert(name != NULL && name[0] != '\0');

	tll_foreach(pkg->groups, g) {
-
		if (strcmp(g->item, name) != 0)
+
		if (!STREQ(g->item, name))
			continue;
		if (ctx.developer_mode) {
			pkg_emit_error("duplicate group listing: %s, fatal (developer mode)", name);
@@ -600,7 +600,7 @@ pkg_addstring(stringlist_t *list, const char *val, const char *title)
	assert(title != NULL);

	tll_foreach(*list, v) {
-
		if (strcmp(v->item, val) != 0)
+
		if (!STREQ(v->item, val))
			continue;
		if (ctx.developer_mode) {
			pkg_emit_error("duplicate %s listing: %s, fatal"
@@ -633,7 +633,7 @@ pkg_adddir_attr(struct pkg *pkg, const char *path, const char *uname,
	assert(pkg != NULL);
	assert(path != NULL && path[0] != '\0');

-
	if (strcmp(path, "/") == 0) {
+
	if (STREQ(path, "/")) {
		pkg_emit_error("skipping useless directory: '%s'\n", path);
		return (EPKG_OK);
	}
@@ -710,13 +710,13 @@ pkg_addluascript_fileat(int fd, struct pkg *pkg, const char *filename)
	if ((ret = file_to_bufferat(fd, filename, &data, &sz)) != EPKG_OK)
		return (ret);

-
	if (strcmp(filename, "pkg-pre-install.lua") == 0) {
+
	if (STREQ(filename, "pkg-pre-install.lua")) {
		type = PKG_LUA_PRE_INSTALL;
-
	} else if (strcmp(filename, "pkg-post-install.lua") == 0) {
+
	} else if (STREQ(filename, "pkg-post-install.lua")) {
		type = PKG_LUA_POST_INSTALL;
-
	} else if (strcmp(filename, "pkg-pre-deinstall.lua") == 0) {
+
	} else if (STREQ(filename, "pkg-pre-deinstall.lua")) {
		type = PKG_LUA_PRE_DEINSTALL;
-
	} else if (strcmp(filename, "pkg-post-deinstall.lua") == 0) {
+
	} else if (STREQ(filename, "pkg-post-deinstall.lua")) {
		type = PKG_LUA_POST_DEINSTALL;
	} else {
		pkg_emit_error("unknown lua script '%s'", filename);
@@ -746,23 +746,23 @@ pkg_addscript_fileat(int fd, struct pkg *pkg, const char *filename)
	if ((ret = file_to_bufferat(fd, filename, &data, &sz)) != EPKG_OK)
		return (ret);

-
	if (strcmp(filename, "pkg-pre-install") == 0 ||
-
			strcmp(filename, "+PRE_INSTALL") == 0) {
+
	if (STREQ(filename, "pkg-pre-install") ||
+
			STREQ(filename, "+PRE_INSTALL")) {
		type = PKG_SCRIPT_PRE_INSTALL;
-
	} else if (strcmp(filename, "pkg-post-install") == 0 ||
-
			strcmp(filename, "+POST_INSTALL") == 0) {
+
	} else if (STREQ(filename, "pkg-post-install") ||
+
			STREQ(filename, "+POST_INSTALL")) {
		type = PKG_SCRIPT_POST_INSTALL;
-
	} else if (strcmp(filename, "pkg-install") == 0 ||
-
			strcmp(filename, "+INSTALL") == 0) {
+
	} else if (STREQ(filename, "pkg-install") ||
+
			STREQ(filename, "+INSTALL")) {
		type = PKG_SCRIPT_INSTALL;
-
	} else if (strcmp(filename, "pkg-pre-deinstall") == 0 ||
-
			strcmp(filename, "+PRE_DEINSTALL") == 0) {
+
	} else if (STREQ(filename, "pkg-pre-deinstall") ||
+
			STREQ(filename, "+PRE_DEINSTALL")) {
		type = PKG_SCRIPT_PRE_DEINSTALL;
-
	} else if (strcmp(filename, "pkg-post-deinstall") == 0 ||
-
			strcmp(filename, "+POST_DEINSTALL") == 0) {
+
	} else if (STREQ(filename, "pkg-post-deinstall") ||
+
			STREQ(filename, "+POST_DEINSTALL")) {
		type = PKG_SCRIPT_POST_DEINSTALL;
-
	} else if (strcmp(filename, "pkg-deinstall") == 0 ||
-
			strcmp(filename, "+DEINSTALL") == 0) {
+
	} else if (STREQ(filename, "pkg-deinstall") ||
+
			STREQ(filename, "+DEINSTALL")) {
		type = PKG_SCRIPT_DEINSTALL;
	} else {
		pkg_emit_error("unknown script '%s'", filename);
@@ -901,7 +901,7 @@ pkg_addshlib_required(struct pkg *pkg, const char *name)

	/* silently ignore duplicates in case of shlibs */
	tll_foreach(pkg->shlibs_required, s) {
-
		if (strcmp(s->item, name) == 0)
+
		if (STREQ(s->item, name))
			return (EPKG_OK);
	}

@@ -924,7 +924,7 @@ pkg_addshlib_provided(struct pkg *pkg, const char *name)

	/* silently ignore duplicates in case of shlibs */
	tll_foreach(pkg->shlibs_provided, s) {
-
		if (strcmp(s->item, name) == 0)
+
		if (STREQ(s->item, name))
			return (EPKG_OK);
	}

@@ -966,7 +966,7 @@ pkg_addrequire(struct pkg *pkg, const char *name)

	/* silently ignore duplicates in case of conflicts */
	tll_foreach(pkg->requires, p) {
-
		if (strcmp(p->item, name) == 0)
+
		if (STREQ(p->item, name))
			return (EPKG_OK);
	}

@@ -983,7 +983,7 @@ pkg_addprovide(struct pkg *pkg, const char *name)

	/* silently ignore duplicates in case of conflicts */
	tll_foreach(pkg->provides, p) {
-
		if (strcmp(p->item, name) == 0)
+
		if (STREQ(p->item, name))
			return (EPKG_OK);
	}

@@ -998,7 +998,7 @@ pkg_kv_get(const kvlist_t *kv, const char *tag)
	assert(tag != NULL);

	tll_foreach(*kv, k) {
-
		if (strcmp(k->item->key, tag) == 0)
+
		if (STREQ(k->item->key, tag))
			return (k->item->value);
	}

@@ -1014,7 +1014,7 @@ pkg_kv_add(kvlist_t *list, const char *key, const char *val, const char *title)
	assert(title != NULL);

	tll_foreach(*list, k) {
-
		if (strcmp(k->item->key, key) != 0)
+
		if (!STREQ(k->item->key, key))
			continue;
		if (ctx.developer_mode) {
			pkg_emit_error("duplicate %s: %s, fatal"
@@ -1232,7 +1232,7 @@ pkg_open2(struct pkg **pkg_p, struct archive **a, struct archive_entry **ae,

		if (!manifest &&
			(flags & PKG_OPEN_MANIFEST_COMPACT) &&
-
			strcmp(fpath, "+COMPACT_MANIFEST") == 0) {
+
			STREQ(fpath, "+COMPACT_MANIFEST")) {
			manifest = true;

			ret = pkg_parse_archive(pkg, *a, archive_entry_size(*ae));
@@ -1243,7 +1243,7 @@ pkg_open2(struct pkg **pkg_p, struct archive **a, struct archive_entry **ae,
			/* Do not read anything more */
			break;
		}
-
		if (!manifest && strcmp(fpath, "+MANIFEST") == 0) {
+
		if (!manifest && STREQ(fpath, "+MANIFEST")) {
			manifest = true;

			ret = pkg_parse_archive(pkg, *a, archive_entry_size(*ae));
@@ -1502,11 +1502,11 @@ pkg_message_from_ucl(struct pkg *pkg, const ucl_object_t *obj)
		msg->type = PKG_MESSAGE_ALWAYS;
		elt = ucl_object_find_key(cur, "type");
		if (elt != NULL && ucl_object_type(elt) == UCL_STRING) {
-
			if (strcasecmp(ucl_object_tostring(elt), "install") == 0)
+
			if (STRIEQ(ucl_object_tostring(elt), "install"))
				msg->type = PKG_MESSAGE_INSTALL;
-
			else if (strcasecmp(ucl_object_tostring(elt), "remove") == 0)
+
			else if (STRIEQ(ucl_object_tostring(elt), "remove"))
				msg->type = PKG_MESSAGE_REMOVE;
-
			else if (strcasecmp(ucl_object_tostring(elt), "upgrade") == 0)
+
			else if (STRIEQ(ucl_object_tostring(elt), "upgrade"))
				msg->type = PKG_MESSAGE_UPGRADE;
			else
				pkg_emit_error("Unknown message type,"
modified libpkg/pkg_add.c
@@ -98,7 +98,7 @@ attempt_to_merge(int rootfd, struct pkg_config_file *rcf, struct pkg *local,
		pkg_debug(2, "Ancient vanilla and deployed conf are the same size testing checksum");
		localsum = pkg_checksum_data(localconf, sz,
		    PKG_HASH_TYPE_SHA256_HEX);
-
		if (localsum && strcmp(localsum, lf->sum) == 0) {
+
		if (localsum && STREQ(localsum, lf->sum)) {
			pkg_debug(2, "Checksum are the same %jd", (intmax_t)strlen(localconf));
			free(localconf);
			free(localsum);
@@ -136,7 +136,7 @@ get_uid_from_archive(struct archive_entry *ae)
	int err;

	user = archive_entry_uname(ae);
-
	if (pwent.pw_name != NULL && strcmp(user, pwent.pw_name) == 0)
+
	if (pwent.pw_name != NULL && STREQ(user, pwent.pw_name))
		goto out;
	pwent.pw_name = NULL;
	err = getpwnam_r(user, &pwent, user_buffer, sizeof(user_buffer),
@@ -161,7 +161,7 @@ get_gid_from_archive(struct archive_entry *ae)
	int err;

	group = archive_entry_gname(ae);
-
	if (grent.gr_name != NULL && strcmp(group, grent.gr_name) == 0)
+
	if (grent.gr_name != NULL && STREQ(group, grent.gr_name))
		goto out;
	grent.gr_name = NULL;
	err = getgrnam_r(group, &grent, group_buffer, sizeof(group_buffer),
@@ -886,7 +886,7 @@ backup_file_if_needed(struct pkg *p, struct pkg_file *f)
		if (sum == NULL)
			return;

-
		if (strcmp(sum, f->sum) == 0) {
+
		if (STREQ(sum, f->sum)) {
			free(sum);
			return;
		}
@@ -1081,7 +1081,7 @@ pkg_add_check_pkg_archive(struct pkgdb *db, struct pkg *pkg,
	 * reading from a file descriptor or a unix domain socket or
	 * whatever, there's no valid directory to search.
	 */
-
	fromstdin = (strcmp(path, "-") == 0);
+
	fromstdin = STREQ(path, "-");
	strlcpy(bd, path, sizeof(bd));
	if (!fromstdin) {
		basedir = get_dirname(bd);
modified libpkg/pkg_attributes.c
@@ -357,7 +357,7 @@ bool
stringlist_contains(stringlist_t *l, const char *name)
{
	tll_foreach(*l, e) {
-
		if (strcmp(e->item, name) == 0)
+
		if (STREQ(e->item, name))
			return (true);
	}
	return (false);
modified libpkg/pkg_audit.c
@@ -356,50 +356,50 @@ vulnxml_start_element(struct vulnxml_userdata *ud, yxml_t *xml)
	struct pkg_audit_pkgname *name_entry;
	struct pkg_audit_package *pkg_entry;

-
	if (ud->state == VULNXML_PARSE_INIT && strcasecmp(xml->elem, "vuln") == 0) {
+
	if (ud->state == VULNXML_PARSE_INIT && STRIEQ(xml->elem, "vuln")) {
		ud->cur_entry = xcalloc(1, sizeof(struct pkg_audit_entry));
		ud->cur_entry->next = ud->audit->entries;
		ud->state = VULNXML_PARSE_VULN;
	}
-
	else if (ud->state == VULNXML_PARSE_VULN && strcasecmp(xml->elem, "topic") == 0) {
+
	else if (ud->state == VULNXML_PARSE_VULN && STRIEQ(xml->elem, "topic")) {
		ud->state = VULNXML_PARSE_TOPIC;
	}
-
	else if (ud->state == VULNXML_PARSE_VULN && strcasecmp(xml->elem, "package") == 0) {
+
	else if (ud->state == VULNXML_PARSE_VULN && STRIEQ(xml->elem, "package")) {
		pkg_entry = xcalloc(1, sizeof(struct pkg_audit_package));
		LL_PREPEND(ud->cur_entry->packages, pkg_entry);
		ud->state = VULNXML_PARSE_PACKAGE;
	}
-
	else if (ud->state == VULNXML_PARSE_VULN && strcasecmp(xml->elem, "cvename") == 0) {
+
	else if (ud->state == VULNXML_PARSE_VULN && STRIEQ(xml->elem, "cvename")) {
		ud->state = VULNXML_PARSE_CVE;
	}
-
	else if (ud->state == VULNXML_PARSE_PACKAGE && strcasecmp(xml->elem, "name") == 0) {
+
	else if (ud->state == VULNXML_PARSE_PACKAGE && STRIEQ(xml->elem, "name")) {
		ud->state = VULNXML_PARSE_PACKAGE_NAME;
		name_entry = xcalloc(1, sizeof(struct pkg_audit_pkgname));
		LL_PREPEND(ud->cur_entry->packages->names, name_entry);
	}
-
	else if (ud->state == VULNXML_PARSE_PACKAGE && strcasecmp(xml->elem, "range") == 0) {
+
	else if (ud->state == VULNXML_PARSE_PACKAGE && STRIEQ(xml->elem, "range")) {
		ud->state = VULNXML_PARSE_RANGE;
		vers = xcalloc(1, sizeof(struct pkg_audit_versions_range));
		LL_PREPEND(ud->cur_entry->packages->versions, vers);
		ud->range_num = 0;
	}
-
	else if (ud->state == VULNXML_PARSE_RANGE && strcasecmp(xml->elem, "gt") == 0) {
+
	else if (ud->state == VULNXML_PARSE_RANGE && STRIEQ(xml->elem, "gt")) {
		ud->range_num ++;
		ud->state = VULNXML_PARSE_RANGE_GT;
	}
-
	else if (ud->state == VULNXML_PARSE_RANGE && strcasecmp(xml->elem, "ge") == 0) {
+
	else if (ud->state == VULNXML_PARSE_RANGE && STRIEQ(xml->elem, "ge")) {
		ud->range_num ++;
		ud->state = VULNXML_PARSE_RANGE_GE;
	}
-
	else if (ud->state == VULNXML_PARSE_RANGE && strcasecmp(xml->elem, "lt") == 0) {
+
	else if (ud->state == VULNXML_PARSE_RANGE && STRIEQ(xml->elem, "lt")) {
		ud->range_num ++;
		ud->state = VULNXML_PARSE_RANGE_LT;
	}
-
	else if (ud->state == VULNXML_PARSE_RANGE && strcasecmp(xml->elem, "le") == 0) {
+
	else if (ud->state == VULNXML_PARSE_RANGE && STRIEQ(xml->elem, "le")) {
		ud->range_num ++;
		ud->state = VULNXML_PARSE_RANGE_LE;
	}
-
	else if (ud->state == VULNXML_PARSE_RANGE && strcasecmp(xml->elem, "eq") == 0) {
+
	else if (ud->state == VULNXML_PARSE_RANGE && STRIEQ(xml->elem, "eq")) {
		ud->range_num ++;
		ud->state = VULNXML_PARSE_RANGE_EQ;
	}
@@ -414,48 +414,48 @@ vulnxml_end_element(struct vulnxml_userdata *ud, yxml_t *xml)
	int range_type = -1;

	fflush(ud->content->fp);
-
	if (ud->state == VULNXML_PARSE_VULN && strcasecmp(xml->elem, "vuxml") == 0) {
+
	if (ud->state == VULNXML_PARSE_VULN && STRIEQ(xml->elem, "vuxml")) {
		pkg_audit_expand_entry(ud->cur_entry, &ud->audit->entries);
		ud->state = VULNXML_PARSE_INIT;
	}
-
	else if (ud->state == VULNXML_PARSE_TOPIC && strcasecmp(xml->elem, "vuln") == 0) {
+
	else if (ud->state == VULNXML_PARSE_TOPIC && STRIEQ(xml->elem, "vuln")) {
		ud->cur_entry->desc = xstrdup(ud->content->buf);
		ud->state = VULNXML_PARSE_VULN;
	}
-
	else if (ud->state == VULNXML_PARSE_CVE && strcasecmp(xml->elem, "references") == 0) {
+
	else if (ud->state == VULNXML_PARSE_CVE && STRIEQ(xml->elem, "references")) {
		entry = ud->cur_entry;
		cve = xmalloc(sizeof(struct pkg_audit_cve));
		cve->cvename = xstrdup(ud->content->buf);
		LL_PREPEND(entry->cve, cve);
		ud->state = VULNXML_PARSE_VULN;
	}
-
	else if (ud->state == VULNXML_PARSE_PACKAGE && strcasecmp(xml->elem, "affects") == 0) {
+
	else if (ud->state == VULNXML_PARSE_PACKAGE && STRIEQ(xml->elem, "affects")) {
		ud->state = VULNXML_PARSE_VULN;
	}
-
	else if (ud->state == VULNXML_PARSE_PACKAGE_NAME && strcasecmp(xml->elem, "package") == 0) {
+
	else if (ud->state == VULNXML_PARSE_PACKAGE_NAME && STRIEQ(xml->elem, "package")) {
		ud->cur_entry->packages->names->pkgname = xstrdup(ud->content->buf);
		ud->state = VULNXML_PARSE_PACKAGE;
	}
-
	else if (ud->state == VULNXML_PARSE_RANGE && strcasecmp(xml->elem, "package") == 0) {
+
	else if (ud->state == VULNXML_PARSE_RANGE && STRIEQ(xml->elem, "package")) {
		ud->state = VULNXML_PARSE_PACKAGE;
	}
-
	else if (ud->state == VULNXML_PARSE_RANGE_GT && strcasecmp(xml->elem, "range") == 0) {
+
	else if (ud->state == VULNXML_PARSE_RANGE_GT && STRIEQ(xml->elem, "range")) {
		range_type = GT;
		ud->state = VULNXML_PARSE_RANGE;
	}
-
	else if (ud->state == VULNXML_PARSE_RANGE_GE && strcasecmp(xml->elem, "range") == 0) {
+
	else if (ud->state == VULNXML_PARSE_RANGE_GE && STRIEQ(xml->elem, "range")) {
		range_type = GTE;
		ud->state = VULNXML_PARSE_RANGE;
	}
-
	else if (ud->state == VULNXML_PARSE_RANGE_LT && strcasecmp(xml->elem, "range") == 0) {
+
	else if (ud->state == VULNXML_PARSE_RANGE_LT && STRIEQ(xml->elem, "range")) {
		range_type = LT;
		ud->state = VULNXML_PARSE_RANGE;
	}
-
	else if (ud->state == VULNXML_PARSE_RANGE_LE && strcasecmp(xml->elem, "range") == 0) {
+
	else if (ud->state == VULNXML_PARSE_RANGE_LE && STRIEQ(xml->elem, "range")) {
		range_type = LTE;
		ud->state = VULNXML_PARSE_RANGE;
	}
-
	else if (ud->state == VULNXML_PARSE_RANGE_EQ && strcasecmp(xml->elem, "range") == 0) {
+
	else if (ud->state == VULNXML_PARSE_RANGE_EQ && STRIEQ(xml->elem, "range")) {
		range_type = EQ;
		ud->state = VULNXML_PARSE_RANGE;
	}
@@ -480,7 +480,7 @@ vulnxml_start_attribute(struct vulnxml_userdata *ud, yxml_t *xml)
	if (ud->state != VULNXML_PARSE_VULN)
		return;

-
	if (strcasecmp(xml->attr, "vid") == 0)
+
	if (STRIEQ(xml->attr, "vid"))
		ud->attr = VULNXML_ATTR_VID;
}

@@ -683,8 +683,7 @@ pkg_audit_preprocess(struct pkg_audit_entry *h)
			for (i = 0; tofill > 1; i++, tofill--)
				base[i].next_pfx_incr = tofill;
			tofill = 1;
-
		} else if (strcmp(ret[n - 1].e->pkgname,
-
		    ret[n].e->pkgname) == 0) {
+
		} else if (STREQ(ret[n - 1].e->pkgname, ret[n].e->pkgname)) {
			tofill++;
		} else {
			tofill = 1;
modified libpkg/pkg_checksum.c
@@ -583,7 +583,7 @@ pkg_checksum_type_from_string(const char *name)
{
	int i;
	for (i = 0; i < PKG_HASH_TYPE_UNKNOWN; i ++) {
-
		if (strcasecmp(name, checksum_types[i].name) == 0)
+
		if (STRIEQ(name, checksum_types[i].name))
			return (i);
	}

@@ -793,7 +793,7 @@ pkg_checksum_validate_fileat(int rootfd, const char *path, const char *sum)
	if (newsum == NULL)
		return (-1);

-
	if (strcmp(sum, newsum) != 0) {
+
	if (!STREQ(sum, newsum)) {
		free(newsum);
		return (-1);
	}
modified libpkg/pkg_config.c
@@ -653,7 +653,7 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
		if (key == NULL)
			continue;

-
		if (strcasecmp(key, "url") == 0) {
+
		if (STRIEQ(key, "url")) {
			if (cur->type != UCL_STRING) {
				pkg_emit_error("Expecting a string for the "
				    "'%s' key of the '%s' repo",
@@ -661,7 +661,7 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
				return;
			}
			url = ucl_object_tostring(cur);
-
		} else if (strcasecmp(key, "pubkey") == 0) {
+
		} else if (STRIEQ(key, "pubkey")) {
			if (cur->type != UCL_STRING) {
				pkg_emit_error("Expecting a string for the "
				    "'%s' key of the '%s' repo",
@@ -669,7 +669,7 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
				return;
			}
			pubkey = ucl_object_tostring(cur);
-
		} else if (strcasecmp(key, "mirror_type") == 0) {
+
		} else if (STRIEQ(key, "mirror_type")) {
			if (cur->type != UCL_STRING) {
				pkg_emit_error("Expecting a string for the "
				    "'%s' key of the '%s' repo",
@@ -677,7 +677,7 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
				return;
			}
			mirror_type = ucl_object_tostring(cur);
-
		} else if (strcasecmp(key, "signature_type") == 0) {
+
		} else if (STRIEQ(key, "signature_type")) {
			if (cur->type != UCL_STRING) {
				pkg_emit_error("Expecting a string for the "
				    "'%s' key of the '%s' repo",
@@ -685,7 +685,7 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
				return;
			}
			signature_type = ucl_object_tostring(cur);
-
		} else if (strcasecmp(key, "fingerprints") == 0) {
+
		} else if (STRIEQ(key, "fingerprints")) {
			if (cur->type != UCL_STRING) {
				pkg_emit_error("Expecting a string for the "
				    "'%s' key of the '%s' repo",
@@ -693,7 +693,7 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
				return;
			}
			fingerprints = ucl_object_tostring(cur);
-
		} else if (strcasecmp(key, "type") == 0) {
+
		} else if (STRIEQ(key, "type")) {
			if (cur->type != UCL_STRING) {
				pkg_emit_error("Expecting a string for the "
					"'%s' key of the '%s' repo",
@@ -701,7 +701,7 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
				return;
			}
			type = ucl_object_tostring(cur);
-
		} else if (strcasecmp(key, "ip_version") == 0) {
+
		} else if (STRIEQ(key, "ip_version")) {
			if (cur->type != UCL_INT) {
				pkg_emit_error("Expecting a integer for the "
					"'%s' key of the '%s' repo",
@@ -711,7 +711,7 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
			use_ipvx = ucl_object_toint(cur);
			if (use_ipvx != 4 && use_ipvx != 6)
				use_ipvx = 0;
-
		} else if (strcasecmp(key, "priority") == 0) {
+
		} else if (STRIEQ(key, "priority")) {
			if (cur->type != UCL_INT) {
				pkg_emit_error("Expecting a integer for the "
					"'%s' key of the '%s' repo",
@@ -719,7 +719,7 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
				return;
			}
			priority = ucl_object_toint(cur);
-
		} else if (strcasecmp(key, "env") == 0) {
+
		} else if (STRIEQ(key, "env")) {
			if (cur->type != UCL_OBJECT) {
				pkg_emit_error("Expecting an object for the "
					"'%s' key of the '%s' repo",
@@ -740,9 +740,9 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
		pkg_repo_overwrite(r, rname, url, type);

	if (signature_type != NULL) {
-
		if (strcasecmp(signature_type, "pubkey") == 0)
+
		if (STRIEQ(signature_type, "pubkey"))
			r->signature_type = SIG_PUBKEY;
-
		else if (strcasecmp(signature_type, "fingerprints") == 0)
+
		else if (STRIEQ(signature_type, "fingerprints"))
			r->signature_type = SIG_FINGERPRINT;
		else
			r->signature_type = SIG_NONE;
@@ -763,9 +763,9 @@ add_repo(const ucl_object_t *obj, struct pkg_repo *r, const char *rname, pkg_ini
	r->priority = priority;

	if (mirror_type != NULL) {
-
		if (strcasecmp(mirror_type, "srv") == 0)
+
		if (STRIEQ(mirror_type, "srv"))
			r->mirror_type = SRV;
-
		else if (strcasecmp(mirror_type, "http") == 0)
+
		else if (STRIEQ(mirror_type, "http"))
			r->mirror_type = HTTP;
		else
			r->mirror_type = NOMIRROR;
@@ -915,7 +915,7 @@ configfile(const struct dirent *dp)
		return (0);

	p = &dp->d_name[n - 5];
-
	if (strcmp(p, ".conf") != 0)
+
	if (!STREQ(p, ".conf"))
		return (0);
	return (1);
}
@@ -1377,7 +1377,7 @@ pkg_ini(const char *path, const char *reposdir, pkg_init_flags flags)
	ucl_parser_free(p);

	if (pkg_object_string(pkg_config_get("ABI")) == NULL ||
-
	    strcmp(pkg_object_string(pkg_config_get("ABI")), "unknown") == 0) {
+
	    STREQ(pkg_object_string(pkg_config_get("ABI")), "unknown")) {
		pkg_emit_error("Unable to determine ABI");
		err = EPKG_FATAL;
		goto out;
@@ -1496,7 +1496,7 @@ pkg_repo_find_type(const char *type)

	cur = &repos_ops[0];
	while (*cur != NULL) {
-
		if (strcasecmp(type, (*cur)->type) == 0) {
+
		if (STRIEQ(type, (*cur)->type)) {
			found = *cur;
		}
		cur ++;
@@ -1688,7 +1688,7 @@ pkg_repo_find(const char *reponame)
	struct pkg_repo *r;

	LL_FOREACH(repos, r) {
-
		if (strcmp(r->name, reponame) == 0)
+
		if (STREQ(r->name, reponame))
			return (r);
	}
	return (NULL);
modified libpkg/pkg_create.c
@@ -275,15 +275,15 @@ pkg_create_free(struct pkg_create *pc)
bool
pkg_create_set_format(struct pkg_create *pc, const char *format)
{
-
	if (strcmp(format, "tzst") == 0)
+
	if (STREQ(format, "tzst"))
		pc->format = TZS;
-
	else if (strcmp(format, "txz") == 0)
+
	else if (STREQ(format, "txz"))
		pc->format = TXZ;
-
	else if (strcmp(format, "tbz") == 0)
+
	else if (STREQ(format, "tbz"))
		pc->format = TBZ;
-
	else if (strcmp(format, "tgz") == 0)
+
	else if (STREQ(format, "tgz"))
		pc->format = TGZ;
-
	else if (strcmp(format, "tar") == 0)
+
	else if (STREQ(format, "tar"))
		pc->format = TAR;
	else
		return (false);
modified libpkg/pkg_cudf.c
@@ -454,7 +454,7 @@ pkg_jobs_cudf_parse_output(struct pkg_jobs *j, FILE *f)
		while(begin != NULL)
			value = strsep(&begin, " \t");

-
		if (strcmp(param, "package") == 0) {
+
		if (STREQ(param, "package")) {
			if (cur_pkg.uid != NULL) {
				if (pkg_jobs_cudf_add_package(j, &cur_pkg) != EPKG_OK)  {
					free(line);
@@ -466,7 +466,7 @@ pkg_jobs_cudf_parse_output(struct pkg_jobs *j, FILE *f)
			cur_pkg.installed = false;
			cur_pkg.version = NULL;
		}
-
		else if (strcmp(param, "version") == 0) {
+
		else if (STREQ(param, "version")) {
			if (cur_pkg.uid == NULL) {
				pkg_emit_error("version line has no corresponding uid in CUDF output");
				free(line);
@@ -474,7 +474,7 @@ pkg_jobs_cudf_parse_output(struct pkg_jobs *j, FILE *f)
			}
			cur_pkg.version = cudf_strdup(value);
		}
-
		else if (strcmp(param, "installed") == 0) {
+
		else if (STREQ(param, "installed")) {
			if (cur_pkg.uid == NULL) {
				pkg_emit_error("installed line has no corresponding uid in CUDF output");
				free(line);
@@ -483,7 +483,7 @@ pkg_jobs_cudf_parse_output(struct pkg_jobs *j, FILE *f)
			if (strncmp(value, "true", 4) == 0)
				cur_pkg.installed = true;
		}
-
		else if (strcmp(param, "was-installed") == 0) {
+
		else if (STREQ(param, "was-installed")) {
			if (cur_pkg.uid == NULL) {
				pkg_emit_error("was-installed line has no corresponding uid in CUDF output");
				free(line);
modified libpkg/pkg_delete.c
@@ -213,7 +213,7 @@ rmdir_p(struct pkgdb *db, struct pkg *pkg, char *dir, const char *prefix_r)
	if (cnt > 0)
		return;

-
	if (strcmp(prefix_r, fullpath + 1) == 0)
+
	if (STREQ(prefix_r, fullpath + 1))
		return;

	pkg_debug(1, "removing directory %s", fullpath);
modified libpkg/pkg_elf.c
@@ -137,7 +137,7 @@ add_shlibs_to_pkg(struct pkg *pkg, const char *fpath, const char *name,
			nsz = strlen(name);

			if (fsz >= nsz &&
-
			    strcmp(&filepath[fsz - nsz], name) == 0) {
+
			    STREQ(&filepath[fsz - nsz], name)) {
				pkg_addshlib_required(pkg, name);
				return (EPKG_OK);
			}
@@ -214,7 +214,7 @@ shlib_valid_abi(const char *fpath, GElf_Ehdr *hdr, const char *abi)
		return (false);
	}

-
	if (strcmp(shlib_arch, arch) != 0) {
+
	if (!STREQ(shlib_arch, arch)) {
		pkg_debug(1, "not valid abi for shlib: %s: %s", shlib_arch,
		    fpath);
		return (false);
@@ -582,7 +582,7 @@ elf_string_to_corres(const struct _elf_corres* m, const char *s)
	int i = 0;

	for (i = 0; m[i].string != NULL; i++)
-
		if (strcmp(m[i].string, s) == 0)
+
		if (STREQ(m[i].string, s))
			return (m[i].elf_nb);

	return (-1);
@@ -956,7 +956,7 @@ pkg_get_myarch_elfparse(char *dest, size_t sz, struct os_info *oi)
				    shdr.sh_name);
				if (sh_name == NULL)
					continue;
-
				if (strcmp(".ARM.attributes", sh_name) == 0)
+
				if (STREQ(".ARM.attributes", sh_name))
					break;
			}
			if (scn != NULL && sh_name != NULL) {
@@ -1116,7 +1116,7 @@ pkg_arch_to_legacy(const char *arch, char *dest, size_t sz)

	for (arch_trans = machine_arch_translation; arch_trans->elftype != NULL;
	    arch_trans++) {
-
		if (strcmp(arch + i, arch_trans->archid) == 0) {
+
		if (STREQ(arch + i, arch_trans->archid)) {
			strlcpy(dest + i, arch_trans->elftype,
			    sz - (arch + i - dest));
			return (0);
@@ -1181,7 +1181,7 @@ pkg_get_myarch(char *dest, size_t sz, struct os_info *oi)
	arch_tweak++;
	for (arch_trans = machine_arch_translation; arch_trans->elftype != NULL;
	    arch_trans++) {
-
		if (strcmp(arch_tweak, arch_trans->elftype) == 0) {
+
		if (STREQ(arch_tweak, arch_trans->elftype)) {
			strlcpy(arch_tweak, arch_trans->archid,
			    sz - (arch_tweak - dest));
			oi->arch = xstrdup(arch_tweak);
modified libpkg/pkg_jobs.c
@@ -217,12 +217,12 @@ pkg_jobs_maybe_match_file(struct job_pattern *jp, const char *pattern)
		 * Compare suffix with .txz or .tbz
		 */
		dot_pos ++;
-
		if (strcmp(dot_pos, "pkg") == 0 ||
-
		    strcmp(dot_pos, "tzst") == 0 ||
-
		    strcmp(dot_pos, "txz") == 0 ||
-
		    strcmp(dot_pos, "tbz") == 0 ||
-
		    strcmp(dot_pos, "tgz") == 0 ||
-
		    strcmp(dot_pos, "tar") == 0) {
+
		if (STREQ(dot_pos, "pkg") ||
+
		    STREQ(dot_pos, "tzst") ||
+
		    STREQ(dot_pos, "txz") ||
+
		    STREQ(dot_pos, "tbz") ||
+
		    STREQ(dot_pos, "tgz") ||
+
		    STREQ(dot_pos, "tar")) {
			if ((pkg_path = realpath(pattern, NULL)) != NULL) {
				/* Dot pos is one character after the dot */
				int len = dot_pos - pattern;
@@ -237,7 +237,7 @@ pkg_jobs_maybe_match_file(struct job_pattern *jp, const char *pattern)
			}
		}
	}
-
	else if (strcmp(pattern, "-") == 0) {
+
	else if (STREQ(pattern, "-")) {
		/*
		 * Read package from stdin
		 */
@@ -470,7 +470,7 @@ delete_process_provides(struct pkg_jobs *j, struct pkg *lp, const char *provide,
	pkg = NULL;
	while (pkgdb_it_next(lit, &pkg, PKG_LOAD_BASIC) == EPKG_OK) {
		/* skip myself */
-
		if (strcmp(pkg->uid, lp->uid) == 0)
+
		if (STREQ(pkg->uid, lp->uid))
			continue;
		req = pkghash_get_value(j->request_delete, pkg->uid);
		/*
@@ -874,7 +874,7 @@ pkg_jobs_has_replacement(struct pkg_jobs *j, const char *uid)
	struct pkg_job_replace *cur;

	LL_FOREACH(j->universe->uid_replaces, cur) {
-
		if (strcmp (cur->new_uid, uid) == 0) {
+
		if (STREQ(cur->new_uid, uid)) {
			return (true);
		}
	}
@@ -1148,7 +1148,7 @@ pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp)
	}

	if (lp->digest != NULL && rp->digest != NULL &&
-
	    strcmp(lp->digest, rp->digest) == 0) {
+
	    STREQ(lp->digest, rp->digest)) {
		/* Remote and local packages has the same digest, hence they are the same */
		return (false);
	}
@@ -1163,7 +1163,7 @@ pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp)
		return (true);

	/* Compare archs */
-
	if (strcmp (lp->arch, rp->arch) != 0) {
+
	if (!STREQ(lp->arch, rp->arch)) {
		free(rp->reason);
		xasprintf(&rp->reason, "ABI changed: '%s' -> '%s'",
		    lp->arch, rp->arch);
@@ -1190,8 +1190,8 @@ pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp)
			return (true);
		}
		if (ret1 == EPKG_OK) {
-
			if (strcmp(lo->key, ro->key) != 0 ||
-
			    strcmp(lo->value, ro->value) != 0) {
+
			if (!STREQ(lo->key, ro->key) ||
+
			    !STREQ(lo->value, ro->value)) {
				free(rp->reason);
				xasprintf(&rp->reason, "options changed");
				return (true);
@@ -1220,8 +1220,8 @@ pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp)
			return (true);
		}
		if (ret1 == EPKG_OK) {
-
			if ((strcmp(rd->name, ld->name) != 0) ||
-
			    (strcmp(rd->origin, ld->origin) != 0)) {
+
			if (!STREQ(rd->name, ld->name) ||
+
			    !STREQ(rd->origin, ld->origin)) {
				free(rp->reason);
				xasprintf(&rp->reason, "direct dependency changed: %s",
				    rd->name);
@@ -1243,7 +1243,7 @@ pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp)
			return (true);
		}
		if (ret1 == EPKG_OK) {
-
			if (strcmp(rc->uid, lc->uid) != 0) {
+
			if (!STREQ(rc->uid, lc->uid)) {
				free(rp->reason);
				rp->reason = xstrdup("direct conflict changed");
				return (true);
@@ -1266,7 +1266,7 @@ pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp)
	}
	i = 0;
	tll_foreach(rp->provides, r) {
-
		if (strcmp(r->item, l1[i]) != 0) {
+
		if (!STREQ(r->item, l1[i])) {
			free(rp->reason);
			rp->reason = xstrdup("provides changed");
			free(l1);
@@ -1288,7 +1288,7 @@ pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp)
	}
	i = 0;
	tll_foreach(rp->requires, r) {
-
		if (strcmp(r->item, l1[i]) != 0) {
+
		if (!STREQ(r->item, l1[i])) {
			free(rp->reason);
			rp->reason = xstrdup("requires changed");
			free(l1);
@@ -1310,7 +1310,7 @@ pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp)
	}
	i = 0;
	tll_foreach(rp->shlibs_provided, r) {
-
		if (strcmp(r->item, l1[i]) != 0) {
+
		if (!STREQ(r->item, l1[i])) {
			free(rp->reason);
			rp->reason = xstrdup("provided shared library changed");
			free(l1);
@@ -1332,7 +1332,7 @@ pkg_jobs_need_upgrade(struct pkg *rp, struct pkg *lp)
	}
	i = 0;
	tll_foreach(rp->shlibs_required, r) {
-
		if (strcmp(r->item, l1[i]) != 0) {
+
		if (!STREQ(r->item, l1[i])) {
			free(rp->reason);
			rp->reason = xstrdup("required shared library changed");
			free(l1);
@@ -1567,7 +1567,7 @@ pkg_jobs_check_remote_candidate(struct pkg_jobs *j, struct pkg *pkg)
			 * Check package with the same uid and explore whether digest
			 * has been changed
			 */
-
			if (strcmp(p->digest, pkg->digest) != 0)
+
			if (!STREQ(p->digest, pkg->digest))
				npkg ++;

			pkg_free(p);
@@ -2199,8 +2199,8 @@ pkg_jobs_execute(struct pkg_jobs *j)
					retcode = EPKG_FATAL;
					goto cleanup;
				}
-
				if (strcmp(p->name, "pkg") == 0 ||
-
				    strcmp(p->name, "pkg-devel") == 0) {
+
				if (STREQ(p->name, "pkg") ||
+
				    STREQ(p->name, "pkg-devel")) {
					if (j->patterns->match == MATCH_ALL)
						continue;
					pkg_emit_error(
modified libpkg/pkg_jobs_conflicts.c
@@ -83,7 +83,7 @@ pkg_conflicts_request_resolve_chain(struct pkg *req, conflict_chain_t *chain)
	tll_foreach(*chain, e) {
		slash_pos = strrchr(e->item->item->pkg->origin, '/');
		if (slash_pos != NULL) {
-
			if (strcmp(slash_pos + 1, req->name) == 0) {
+
			if (STREQ(slash_pos + 1, req->name)) {
				selected = e->item;
				break;
			}
@@ -312,7 +312,7 @@ pkg_conflicts_check_local_path(const char *path, const char *uid,
			uid_local, 0);
		assert(p != NULL);

-
		assert(strcmp(uid, p->uid) != 0);
+
		assert(!STREQ(uid, p->uid));

		if (pkghash_get(p->conflictshash, uid) == NULL) {
			/* We need to register the conflict between two universe chains */
@@ -352,7 +352,7 @@ pkg_conflicts_check_all_paths(struct pkg_jobs *j, const char *path,

		uid1 = it->pkg->uid;
		uid2 = cit->item->pkg->uid;
-
		if (strcmp(uid1, uid2) == 0) {
+
		if (STREQ(uid1, uid2)) {
			/* The same upgrade chain, just upgrade item for speed */
			cit->item = it;
			return (NULL);
modified libpkg/pkg_jobs_universe.c
@@ -172,9 +172,9 @@ pkg_jobs_universe_add_pkg(struct pkg_jobs_universe *universe, struct pkg *pkg,

		DL_FOREACH(seen, tmp) {
			if (tmp->pkg == pkg || (tmp->pkg->type == pkg->type &&
-
			    strcmp(tmp->pkg->digest, pkg->digest) == 0)) {
+
			    STREQ(tmp->pkg->digest, pkg->digest))) {
				if (tmp->pkg->reponame != NULL) {
-
					if (strcmp(tmp->pkg->reponame, pkg->reponame) == 0) {
+
					if (STREQ(tmp->pkg->reponame, pkg->reponame)) {
						same_package = true;
						break;
					}
@@ -319,7 +319,7 @@ pkg_jobs_universe_process_deps(struct pkg_jobs_universe *universe,
			rpkg = rit->item;

			if (pkg->reponame && rpkg->reponame &&
-
					strcmp (pkg->reponame, rpkg->reponame) == 0) {
+
					STREQ(pkg->reponame, rpkg->reponame)) {
				found = true;
				break;
			}
@@ -887,7 +887,7 @@ pkg_jobs_universe_change_uid(struct pkg_jobs_universe *universe,

			if (found != NULL) {
				while (pkg_deps(found->pkg, &d) == EPKG_OK) {
-
					if (strcmp(d->uid, unit->pkg->uid) == 0) {
+
					if (STREQ(d->uid, unit->pkg->uid)) {
						free(d->uid);
						d->uid = xstrdup(new_uid);
					}
@@ -1144,8 +1144,7 @@ pkg_jobs_universe_process_upgrade_chains(struct pkg_jobs *j)
			 * and if it has the same digest we proceed only if we have a
			 * forced job
			 */
-
			if (local != NULL && strcmp(local->pkg->digest,
-
				selected->pkg->digest) == 0 &&
+
			if (local != NULL && STREQ(local->pkg->digest, selected->pkg->digest) &&
				(j->flags & PKG_FLAG_FORCE) == 0) {
				pkg_debug (1, "removing %s from the request as it is the "
								"same as local", selected->pkg->uid);
modified libpkg/pkg_macho.c
@@ -118,7 +118,7 @@ analyse_macho(struct pkg *pkg, const char *fpath,
			/* Prevent cyclic self-references. A valid dylib shouldn't include a
			 * LC_LOAD_DYLIB referencing itself, but there's nothing that would
			 * actually prevent it */
-
			if (strcmp(cmd->mlt_install_name, march->mat_install_name) == 0)
+
			if (STREQ(cmd->mlt_install_name, march->mat_install_name))
				continue;

			/* Skip non-resolvable library paths. */
modified libpkg/pkg_manifest.c
@@ -283,13 +283,13 @@ urldecode(const char *src, xstring **dest)
static int
lua_script_type_str(const char *str)
{
-
	if (strcmp(str, "pre-install") == 0)
+
	if (STREQ(str, "pre-install"))
		return (PKG_LUA_PRE_INSTALL);
-
	if (strcmp(str, "post-install") == 0)
+
	if (STREQ(str, "post-install"))
		return (PKG_LUA_POST_INSTALL);
-
	if (strcmp(str, "pre-deinstall") == 0)
+
	if (STREQ(str, "pre-deinstall"))
		return (PKG_LUA_PRE_DEINSTALL);
-
	if (strcmp(str, "post-deinstall") == 0)
+
	if (STREQ(str, "post-deinstall"))
		return (PKG_LUA_POST_DEINSTALL);
	return (PKG_LUA_UNKNOWN);
}
@@ -297,17 +297,17 @@ lua_script_type_str(const char *str)
static int
script_type_str(const char *str)
{
-
	if (strcmp(str, "pre-install") == 0)
+
	if (STREQ(str, "pre-install"))
		return (PKG_SCRIPT_PRE_INSTALL);
-
	if (strcmp(str, "install") == 0)
+
	if (STREQ(str, "install"))
		return (PKG_SCRIPT_INSTALL);
-
	if (strcmp(str, "post-install") == 0)
+
	if (STREQ(str, "post-install"))
		return (PKG_SCRIPT_POST_INSTALL);
-
	if (strcmp(str, "pre-deinstall") == 0)
+
	if (STREQ(str, "pre-deinstall"))
		return (PKG_SCRIPT_PRE_DEINSTALL);
-
	if (strcmp(str, "deinstall") == 0)
+
	if (STREQ(str, "deinstall"))
		return (PKG_SCRIPT_DEINSTALL);
-
	if (strcmp(str, "post-deinstall") == 0)
+
	if (STREQ(str, "post-deinstall"))
		return (PKG_SCRIPT_POST_DEINSTALL);
	return (PKG_SCRIPT_UNKNOWN);
}
@@ -322,13 +322,13 @@ pkg_string(struct pkg *pkg, const ucl_object_t *obj, uint32_t offset)
	str = ucl_object_tostring_forced(obj);

	if (offset & STRING_FLAG_LICENSE) {
-
		if (!strcmp(str, "single"))
+
		if (STREQ(str, "single"))
			pkg->licenselogic = LICENSE_SINGLE;
-
		else if (!strcmp(str, "or") ||
-
				!strcmp(str, "dual"))
+
		else if (STREQ(str, "or") ||
+
				STREQ(str, "dual"))
			pkg->licenselogic = LICENSE_OR;
-
		else if (!strcmp(str, "and") ||
-
				!strcmp(str, "multi"))
+
		else if (STREQ(str, "and") ||
+
				STREQ(str, "multi"))
			pkg->licenselogic = LICENSE_AND;
		else {
			pkg_emit_error("Unknown license logic: %s", str);
@@ -622,15 +622,15 @@ pkg_set_files_from_object(struct pkg *pkg, const ucl_object_t *obj)
		key = ucl_object_key(cur);
		if (key == NULL)
			continue;
-
		if (!strcasecmp(key, "uname") && cur->type == UCL_STRING)
+
		if (STRIEQ(key, "uname") && cur->type == UCL_STRING)
			uname = ucl_object_tostring(cur);
-
		else if (!strcasecmp(key, "gname") && cur->type == UCL_STRING)
+
		else if (STRIEQ(key, "gname") && cur->type == UCL_STRING)
			gname = ucl_object_tostring(cur);
-
		else if (!strcasecmp(key, "sum") && cur->type == UCL_STRING &&
-
		    strlen(ucl_object_tostring(cur)) == 64)
+
		else if (STRIEQ(key, "sum") && cur->type == UCL_STRING &&
+
			 strlen(ucl_object_tostring(cur)) == 64)
			sum = ucl_object_tostring(cur);
-
		else if (!strcasecmp(key, "perm") &&
-
		    (cur->type == UCL_STRING || cur->type == UCL_INT)) {
+
		else if (STRIEQ(key, "perm") &&
+
			 (cur->type == UCL_STRING || cur->type == UCL_INT)) {
			if ((set = setmode(ucl_object_tostring_forced(cur))) == NULL)
				pkg_emit_error("Not a valid mode: %s",
				    ucl_object_tostring(cur));
@@ -669,18 +669,18 @@ pkg_set_dirs_from_object(struct pkg *pkg, const ucl_object_t *obj)
		key = ucl_object_key(cur);
		if (key == NULL)
			continue;
-
		if (!strcasecmp(key, "uname") && cur->type == UCL_STRING)
+
		if (STRIEQ(key, "uname") && cur->type == UCL_STRING)
			uname = ucl_object_tostring(cur);
-
		else if (!strcasecmp(key, "gname") && cur->type == UCL_STRING)
+
		else if (STRIEQ(key, "gname") && cur->type == UCL_STRING)
			gname = ucl_object_tostring(cur);
-
		else if (!strcasecmp(key, "perm") &&
-
		    (cur->type == UCL_STRING || cur->type == UCL_INT)) {
+
		else if (STRIEQ(key, "perm") &&
+
			 (cur->type == UCL_STRING || cur->type == UCL_INT)) {
			if ((set = setmode(ucl_object_tostring_forced(cur))) == NULL)
				pkg_emit_error("Not a valid mode: %s",
				    ucl_object_tostring(cur));
			else
				perm = getmode(set, 0);
-
		} else if (!strcasecmp(key, "try") && cur->type == UCL_BOOLEAN) {
+
		} else if (STRIEQ(key, "try") && cur->type == UCL_BOOLEAN) {
			/* ignore on purpose : compatibility*/
		} else {
			dbg(1, "Skipping unknown key for dir(%s): %s",
@@ -717,7 +717,7 @@ pkg_set_deps_from_object(struct pkg *pkg, const ucl_object_t *obj)
				continue;
			if (cur->type != UCL_STRING) {
				/* accept version to be an integer */
-
				if (cur->type == UCL_INT && strcasecmp(key, "version") == 0) {
+
				if (cur->type == UCL_INT && STRIEQ(key, "version")) {
					if (!noversion)
						version = ucl_object_tostring_forced(cur);
					continue;
@@ -727,9 +727,9 @@ pkg_set_deps_from_object(struct pkg *pkg, const ucl_object_t *obj)
						"for %s", okey);
				continue;
			}
-
			if (strcasecmp(key, "origin") == 0)
+
			if (STRIEQ(key, "origin"))
				origin = ucl_object_tostring(cur);
-
			if (strcasecmp(key, "version") == 0 && !noversion)
+
			if (STRIEQ(key, "version") && !noversion)
				version = ucl_object_tostring(cur);
		}
		if (origin != NULL)
@@ -745,7 +745,7 @@ static struct pkg_manifest_key *
select_manifest_key(const char *key)
{
	for (int i = 0; i < NELEM(manifest_keys); i++)
-
		if (strcmp(manifest_keys[i].key, key) == 0)
+
		if (STREQ(manifest_keys[i].key, key))
			return (&(manifest_keys[i]));
	return (NULL);
}
@@ -1125,8 +1125,8 @@ pkg_emit_object(struct pkg *pkg, short flags)
		if (map == NULL)
			map = ucl_object_typed_new(UCL_OBJECT);
		/* Add annotations except for internal ones. */
-
		if ((strcmp(kv->key, "repository") == 0 ||
-
		    strcmp(kv->key, "relocated") == 0) &&
+
		if ((STREQ(kv->key, "repository") ||
+
		     STREQ(kv->key, "relocated")) &&
		    (flags & PKG_MANIFEST_EMIT_LOCAL_METADATA) == 0)
			continue;
		ucl_object_insert_key(map, ucl_object_fromstring(kv->value),
modified libpkg/pkg_ports.c
@@ -589,17 +589,17 @@ parse_attributes(const ucl_object_t *o, struct file_attr **a)
		key = ucl_object_key(cur);
		if (key == NULL)
			continue;
-
		if (!strcasecmp(key, "owner") && cur->type == UCL_STRING) {
+
		if (STRIEQ(key, "owner") && cur->type == UCL_STRING) {
			free((*a)->owner);
			(*a)->owner = xstrdup(ucl_object_tostring(cur));
			continue;
		}
-
		if (!strcasecmp(key, "group") && cur->type == UCL_STRING) {
+
		if (STRIEQ(key, "group") && cur->type == UCL_STRING) {
			free((*a)->group);
			(*a)->group = xstrdup(ucl_object_tostring(cur));
			continue;
		}
-
		if (!strcasecmp(key, "mode")) {
+
		if (STRIEQ(key, "mode")) {
			if (cur->type == UCL_STRING) {
				void *set;
				if ((set = parse_mode(ucl_object_tostring(cur))) == NULL) {
@@ -698,11 +698,11 @@ apply_keyword_file(ucl_object_t *obj, struct plist *p, char *line, struct file_a
			msg->type = PKG_MESSAGE_ALWAYS;
			elt = ucl_object_find_key(cur, "type");
			if (elt != NULL) {
-
				if (strcasecmp(ucl_object_tostring(elt), "install") == 0)
+
				if (STRIEQ(ucl_object_tostring(elt), "install"))
					msg->type = PKG_MESSAGE_INSTALL;
-
				else if (strcasecmp(ucl_object_tostring(elt), "remove") == 0)
+
				else if (STRIEQ(ucl_object_tostring(elt), "remove"))
					msg->type = PKG_MESSAGE_REMOVE;
-
				else if (strcasecmp(ucl_object_tostring(elt), "upgrade") == 0)
+
				else if (STRIEQ(ucl_object_tostring(elt), "upgrade"))
					msg->type = PKG_MESSAGE_UPGRADE;
			}
			tll_push_back(p->pkg->message, msg);
@@ -1205,7 +1205,7 @@ add_variable(struct plist *p, char *line, struct file_attr *a __unused)
		val++;

	tll_foreach(p->variables, v) {
-
		if (strcmp(v->item->key, key) == 0) {
+
		if (STREQ(v->item->key, key)) {
			free(v->item->value);
			v->item->value = xstrdup(val);
			return (EPKG_OK);
modified libpkg/pkg_repo.c
@@ -132,7 +132,7 @@ pkg_repo_file_has_ext(const char *path, const char *ext)
	l = strlen(ext);
	p = &path[n - l];

-
	if (strcmp(p, ext) == 0)
+
	if (STREQ(p, ext))
		return (true);

	return (false);
@@ -281,13 +281,13 @@ pkg_repo_meta_extract_signature_pubkey(int fd, void *ud)
	archive_read_open_fd(a, cb->afd, 4096);

	while (archive_read_next_header(a, &ae) == ARCHIVE_OK) {
-
		if (cb->need_sig && strcmp(archive_entry_pathname(ae), "signature") == 0) {
+
		if (cb->need_sig && STREQ(archive_entry_pathname(ae), "signature")) {
			siglen = archive_entry_size(ae);
			rc = pkg_repo_write_sig_from_archive(a, fd, siglen);
			if (rc != EPKG_OK)
				break;
		}
-
		else if (strcmp(archive_entry_pathname(ae), cb->fname) == 0) {
+
		else if (STREQ(archive_entry_pathname(ae), cb->fname)) {
			if (archive_read_data_into_fd(a, cb->tfd) != 0) {
				pkg_emit_error("Error extracting the archive: '%s'", archive_error_string(a));
				rc = EPKG_FATAL;
@@ -444,7 +444,7 @@ pkg_repo_meta_extract_signature_fingerprints(int fd, void *ud)
			rc = EPKG_OK;
		}
		else {
-
			if (strcmp(archive_entry_pathname(ae), cb->fname) == 0) {
+
			if (STREQ(archive_entry_pathname(ae), cb->fname)) {
				if (archive_read_data_into_fd(a, cb->tfd) != 0) {
					pkg_emit_error("Error extracting the archive: '%s'", archive_error_string(a));
					rc = EPKG_FATAL;
@@ -775,7 +775,7 @@ pkg_repo_archive_extract_check_archive(int fd, const char *file,
			 * grab a new context for each one.  This is cheaper than it sounds,
			 * verifying contexts are stashed in a pkghash for re-use.
			 */
-
			if (sctx == NULL || strcmp(s->type, signer_name) != 0) {
+
			if (sctx == NULL || !STREQ(s->type, signer_name)) {
				ret = pkgsign_new_verify(s->type, &sctx);
				if (ret != EPKG_OK) {
					pkg_emit_error("'%s' signer not found", s->type);
@@ -943,7 +943,7 @@ pkg_repo_meta_extract_pubkey(int fd, void *ud)
		elt = ucl_object_find_key(cur, "name");
		if (elt == NULL || elt->type != UCL_STRING)
			continue;
-
		if (strcmp(ucl_object_tostring(elt), cbdata->name) != 0)
+
		if (!STREQ(ucl_object_tostring(elt), cbdata->name))
			continue;
		elt = ucl_object_find_key(cur, "data");
		if (elt == NULL || elt->type != UCL_STRING)
@@ -1123,7 +1123,7 @@ pkg_repo_fetch_meta(struct pkg_repo *repo, time_t *t)
			 * Just as above, each one may have a different type associated with
			 * it, so grab a new one each time.
			 */
-
			if (sctx == NULL || strcmp(s->type, signer_name) != 0) {
+
			if (sctx == NULL || !STREQ(s->type, signer_name)) {
				ret = pkgsign_new_verify(s->type, &sctx);
				if (ret != EPKG_OK) {
					pkg_emit_error("'%s' signer not found", s->type);
@@ -1191,12 +1191,12 @@ pkg_repo_parse_fingerprint(ucl_object_t *obj)
		if (cur->type != UCL_STRING)
			continue;

-
		if (strcasecmp(key, "function") == 0) {
+
		if (STRIEQ(key, "function")) {
			function = ucl_object_tostring(cur);
			continue;
		}

-
		if (strcasecmp(key, "fingerprint") == 0) {
+
		if (STRIEQ(key, "fingerprint")) {
			fp = ucl_object_tostring(cur);
			continue;
		}
@@ -1205,7 +1205,7 @@ pkg_repo_parse_fingerprint(ucl_object_t *obj)
	if (fp == NULL || function == NULL)
		return (NULL);

-
	if (strcasecmp(function, "sha256") == 0)
+
	if (STRIEQ(function, "sha256"))
		fct = HASH_SHA256;

	if (fct == HASH_UNKNOWN) {
@@ -1282,8 +1282,8 @@ pkg_repo_load_fingerprints_from_path(const char *path, pkghash **f)
	}

	while ((ent = readdir(d))) {
-
		if (strcmp(ent->d_name, ".") == 0 ||
-
		    strcmp(ent->d_name, "..") == 0)
+
		if (STREQ(ent->d_name, ".") ||
+
		    STREQ(ent->d_name, ".."))
			continue;
		finger = pkg_repo_load_fingerprint(path, ent->d_name);
		if (finger != NULL)
modified libpkg/pkg_repo_create.c
@@ -126,7 +126,7 @@ hash_file(struct pkg_repo_meta *meta, struct pkg *pkg, char *path)
		(void)pkg_mkdirs(rel_dir);
	}

-
	if (strcmp(path, hash_name) != 0) {
+
	if (!STREQ(path, hash_name)) {
		pkg_debug(1, "Rename the pkg from: %s to: %s", path, hash_name);
		if (rename(path, hash_name) == -1) {
			pkg_emit_errno("rename", hash_name);
@@ -226,7 +226,7 @@ pkg_create_repo_read_fts(fts_item_t *items, FTS *fts,
		if ((fts_ent->fts_info == FTS_D ||
		    fts_ent->fts_info == FTS_DP ||
		    fts_ent->fts_info == FTS_SL) &&
-
		    strcmp(fts_ent->fts_name, "Latest") == 0) {
+
		    STREQ(fts_ent->fts_name, "Latest")) {
			fts_set(fts, fts_ent, FTS_SKIP);
			continue;
		}
@@ -267,7 +267,7 @@ pkg_create_repo_read_fts(fts_item_t *items, FTS *fts,
			continue;

		/* skip all files which are not .pkg */
-
		if (!ctx.repo_accept_legacy_pkg && strcmp(ext + 1, "pkg") != 0)
+
		if (!ctx.repo_accept_legacy_pkg && !STREQ(ext + 1, "pkg"))
			continue;


@@ -277,7 +277,7 @@ pkg_create_repo_read_fts(fts_item_t *items, FTS *fts,
			unlink(fts_ent->fts_path);
			continue;
		}
-
		if (strcmp(fts_ent->fts_name, "meta") == 0 ||
+
		if (STREQ(fts_ent->fts_name, "meta") ||
				pkg_repo_meta_is_special_file(fts_ent->fts_name, meta)) {
			*ext = '.';
			continue;
@@ -545,7 +545,7 @@ pkg_repo_create_set_groups(struct pkg_repo_create *prc, const char *path)
		ext = strrchr(e->d_name, '.');
		if (ext == NULL)
			continue;
-
		if (strcmp(ext, ".ucl") != 0)
+
		if (!STREQ(ext, ".ucl"))
			continue;
		/* only regular files are considered */
		if (fstatat(dfd, e->d_name, &st, AT_SYMLINK_NOFOLLOW) != 0) {
@@ -632,7 +632,7 @@ pkg_repo_create_pack_and_sign(struct pkg_repo_create *prc)
		ret = EPKG_OK;
	}

-
	if (prc->sign.argc > 1 && strcmp(prc->sign.argv[0], "signing_command:") != 0)
+
	if (prc->sign.argc > 1 && !STREQ(prc->sign.argv[0], "signing_command:"))
		return (EPKG_FATAL);

	if (prc->sign.argc > 1) {
@@ -940,16 +940,16 @@ pkg_repo_sign(const char *path, char **argv, int argc, char **sig, size_t *sigle
	typestr = xstring_new();

	while ((linelen = getline(&line, &linecap, fp)) > 0 ) {
-
		if (strcmp(line, "SIGNATURE\n") == 0) {
+
		if (STREQ(line, "SIGNATURE\n")) {
			buf = sigstr;
			continue;
-
		} else if (strcmp(line, "CERT\n") == 0) {
+
		} else if (STREQ(line, "CERT\n")) {
			buf = certstr;
			continue;
-
		} else if (strcmp(line, "TYPE\n") == 0) {
+
		} else if (STREQ(line, "TYPE\n")) {
			buf = typestr;
			continue;
-
		} else if (strcmp(line, "END\n") == 0) {
+
		} else if (STREQ(line, "END\n")) {
			end_seen = true;
			break;
		}
@@ -967,7 +967,7 @@ pkg_repo_sign(const char *path, char **argv, int argc, char **sig, size_t *sigle
	 * END marker if we ran over it.
	 */
	if (!end_seen && *certlen >= 4 &&
-
	    strcmp(&(*cert)[*certlen - 4], "END\n") == 0)
+
	    STREQ(&(*cert)[*certlen - 4], "END\n"))
		*certlen -= 4;

	/* remove the latest \n */
@@ -1006,7 +1006,7 @@ pack_sign(struct packing *pack, struct pkgsign_ctx *sctx, const char *path,

	offset = 0;
	sigtype = pkgsign_impl_name(sctx);
-
	if (strcmp(sigtype, "rsa") != 0) {
+
	if (!STREQ(sigtype, "rsa")) {
		size = snprintf(buf, sizeof(buf), "%s%s$", PKGSIGN_HEAD, sigtype);
		if (size >= sizeof(buf)) {
			free(sigret);
@@ -1052,7 +1052,7 @@ pack_command_sign(struct packing *pack, const char *path, char **argv, int argc,

	offset = 0;
	snprintf(fname, sizeof(fname), "%s.sig", name);
-
	if (*sigtype != '\0' && strcmp(sigtype, "rsa") != 0) {
+
	if (*sigtype != '\0' && !STREQ(sigtype, "rsa")) {
		int typelen;

		typelen = strlen(sigtype);
modified libpkg/pkg_repo_meta.c
@@ -453,7 +453,7 @@ pkg_repo_meta_to_ucl(struct pkg_repo_meta *meta)
#undef META_EXPORT_FIELD_FUNC

#define META_SPECIAL_FILE(file, meta, field) \
-
	special || (meta->field == NULL ? false : (strcmp(file, meta->field) == 0))
+
	special || (meta->field == NULL ? false : STREQ(file, meta->field))

bool
pkg_repo_meta_is_special_file(const char *file, struct pkg_repo_meta *meta)
modified libpkg/pkg_solve.c
@@ -298,7 +298,7 @@ pkg_solve_handle_provide (struct pkg_solve_problem *problem,
		if (pr->is_shlib) {
			libfound = stringlist_contains(&pkg->shlibs_provided, pr->provide);
			/* Skip incompatible ABI as well */
-
			if (libfound && strcmp(pkg->arch, orig->arch) != 0) {
+
			if (libfound && !STREQ(pkg->arch, orig->arch)) {
				dbg(2, "require %s: package %s-%s(%c) provides wrong ABI %s, "
					"wanted %s", pr->provide, pkg->name, pkg->version,
					pkg->type == PKG_INSTALLED ? 'l' : 'r', pkg->arch, orig->arch);
@@ -426,7 +426,7 @@ pkg_solve_add_conflict_rule(struct pkg_solve_problem *problem,
		 * variables with mismatched digests
		 */
		if (conflict->digest) {
-
			if (strcmp (conflict->digest, other->digest) != 0)
+
			if (!STREQ(conflict->digest, other->digest))
				continue;
		}

@@ -916,8 +916,8 @@ pkg_solve_set_initial_assumption(struct pkg_solve_problem *problem,
			selected = pkg_jobs_universe_select_candidate(first, local,
			    conservative, assumed_reponame, true);

-
			if (local && (strcmp(selected->pkg->digest, local->pkg->digest) == 0 ||
-
			    !pkg_jobs_need_upgrade(selected->pkg, local->pkg))) {
+
			if (local && (STREQ(selected->pkg->digest, local->pkg->digest) ||
+
				      !pkg_jobs_need_upgrade(selected->pkg, local->pkg))) {
				selected = local;
			}
		}
modified libpkg/pkg_status.c
@@ -65,8 +65,8 @@ pkg_status(int *count)
	if (progname == NULL)
		return (PKG_STATUS_UNINSTALLED);

-
	if (strcmp(progname, PKG_EXEC_NAME) != 0   &&
-
	    strcmp(progname, PKG_STATIC_NAME) != 0 &&
+
	if (!STREQ(progname, PKG_EXEC_NAME)   &&
+
	    !STREQ(progname, PKG_STATIC_NAME) &&
	    !is_exec_at_localbase(PKG_EXEC_NAME)   &&
	    !is_exec_at_localbase(PKG_STATIC_NAME))
		return (PKG_STATUS_UNINSTALLED);
modified libpkg/pkgdb.c
@@ -813,7 +813,7 @@ pkgdb_open_repos(struct pkgdb *db, const char *reponame)
			continue;
		}

-
		if (reponame == NULL || strcasecmp(r->name, reponame) == 0) {
+
		if (reponame == NULL || STRIEQ(r->name, reponame)) {
			/* We need read only access here */
			if (r->ops->open(r, R_OK) == EPKG_OK) {
				r->ops->init(r);
modified libpkg/pkgdb_iterator.c
@@ -319,15 +319,9 @@ pkgdb_load_deps(sqlite3 *sqlite, struct pkg *pkg)

							while (sqlite3_step(opt_stmt) == SQLITE_ROW) {
								DL_FOREACH(fit->options, optit) {
-
									if(strcmp(optit->opt,
-
											sqlite3_column_text(opt_stmt, 0))
-
											== 0) {
-
										if ((strcmp(
-
												sqlite3_column_text(opt_stmt, 1),
-
												"on") && !optit->on)
-
											|| (strcmp(
-
												sqlite3_column_text(opt_stmt, 1),
-
												"off") && optit->on)) {
+
									if(STREQ(optit->opt, sqlite3_column_text(opt_stmt, 0))) {
+
										if ((!STREQ(sqlite3_column_text(opt_stmt, 1), "on") && !optit->on)
+
											|| (!STREQ(sqlite3_column_text(opt_stmt, 1), "off") && optit->on)) {
											pkg_debug(4, "incompatible option for"
													"%s: %s",
													sqlite3_column_text(opt_stmt, 1),
modified libpkg/pkgdb_query.c
@@ -392,7 +392,7 @@ pkgdb_repo_query_cond(struct pkgdb *db, const char *cond, const char *pattern, m
		return (NULL);

	tll_foreach(db->repos, cur) {
-
		if (repo == NULL || strcasecmp(cur->item->name, repo) == 0) {
+
		if (repo == NULL || STRIEQ(cur->item->name, repo)) {
			if (pattern != NULL && *pattern == '@')
				rit = cur->item->ops->groupquery(cur->item, pattern + 1, match);
			else
@@ -422,7 +422,7 @@ pkgdb_repo_shlib_require(struct pkgdb *db, const char *require, const char *repo
		return (NULL);

	tll_foreach(db->repos, cur) {
-
		if (repo == NULL || strcasecmp(cur->item->name, repo) == 0) {
+
		if (repo == NULL || STRIEQ(cur->item->name, repo)) {
			if (cur->item->ops->shlib_required != NULL) {
				rit = cur->item->ops->shlib_required(cur->item, require);
				if (rit != NULL)
@@ -445,7 +445,7 @@ pkgdb_repo_shlib_provide(struct pkgdb *db, const char *require, const char *repo
		return (NULL);

	tll_foreach(db->repos, cur) {
-
		if (repo == NULL || strcasecmp(cur->item->name, repo) == 0) {
+
		if (repo == NULL || STRIEQ(cur->item->name, repo)) {
			if (cur->item->ops->shlib_required != NULL) {
				rit = cur->item->ops->shlib_provided(cur->item, require);
				if (rit != NULL)
@@ -468,7 +468,7 @@ pkgdb_repo_require(struct pkgdb *db, const char *require, const char *repo)
		return (NULL);

	tll_foreach(db->repos, cur) {
-
		if (repo == NULL || strcasecmp(cur->item->name, repo) == 0) {
+
		if (repo == NULL || STRIEQ(cur->item->name, repo)) {
			if (cur->item->ops->required != NULL) {
				rit = cur->item->ops->required(cur->item, require);
				if (rit != NULL)
@@ -491,7 +491,7 @@ pkgdb_repo_provide(struct pkgdb *db, const char *require, const char *repo)
		return (NULL);

	tll_foreach(db->repos, cur) {
-
		if (repo == NULL || strcasecmp(cur->item->name, repo) == 0) {
+
		if (repo == NULL || STRIEQ(cur->item->name, repo)) {
			if (cur->item->ops->required != NULL) {
				rit = cur->item->ops->provided(cur->item, require);
				if (rit != NULL)
@@ -515,7 +515,7 @@ pkgdb_repo_search(struct pkgdb *db, const char *pattern, match_t match,
		return (NULL);

	tll_foreach(db->repos, cur) {
-
		if (repo == NULL || strcasecmp(cur->item->name, repo) == 0) {
+
		if (repo == NULL || STRIEQ(cur->item->name, repo)) {
			if (cur->item->ops->search != NULL) {
				rit = cur->item->ops->search(cur->item, pattern, match,
					field, sort);
@@ -543,7 +543,7 @@ pkgdb_all_search(struct pkgdb *db, const char *pattern, match_t match,
	it = pkgdb_query(db, pattern, match);

	tll_foreach(db->repos, cur) {
-
		if (repo == NULL || strcasecmp(cur->item->name, repo) == 0) {
+
		if (repo == NULL || STRIEQ(cur->item->name, repo)) {
			if (cur->item->ops->search != NULL) {
				rit = cur->item->ops->search(cur->item, pattern, match,
					field, sort);
modified libpkg/pkghash.c
@@ -74,7 +74,7 @@ pkghash_get(pkghash *table, const char *key)
	size_t index = (size_t)(hash & (uint64_t)(table->capacity -1));

	while (table->entries[index].key != NULL) {
-
		if (strcmp(key, table->entries[index].key) == 0)
+
		if (STREQ(key, table->entries[index].key))
			return (&table->entries[index]);
		index++;
		if (index >= table->capacity)
@@ -100,7 +100,7 @@ pkghash_set_entry(pkghash_entry *entries, size_t capacity,
	size_t index = (size_t)(hash & (uint64_t)(capacity - 1));

	while (entries[index].key != NULL) {
-
		if (strcmp(key, entries[index].key) == 0)
+
		if (STREQ(key, entries[index].key))
			return (false);
		index++;
		if (index >= capacity)
modified libpkg/pkgsign.c
@@ -84,7 +84,7 @@ pkgsign_new(const char *name, struct pkgsign_ctx **ctx)
	ops = NULL;
	for (size_t i = 0; i < nitems(pkgsign_builtins); i++) {
		impl = &pkgsign_builtins[i];
-
		if (strcmp(name, impl->pi_name) == 0) {
+
		if (STREQ(name, impl->pi_name)) {
			ops = impl->pi_ops;
			break;
		}
modified libpkg/pkgsign_ecc.c
@@ -1232,11 +1232,11 @@ ecc_new(const char *name __unused, struct pkgsign_ctx *sctx)
	int ret;

	ret = EPKG_FATAL;
-
	if (strcmp(name, "ecc") == 0 || strcmp(name, "eddsa") == 0) {
+
	if (STREQ(name, "ecc") || STREQ(name, "eddsa")) {
			keyinfo->sig_alg = EDDSA25519;
			keyinfo->sig_hash = SHA512;
			ret = import_params(&keyinfo->params, &wei25519_str_params);
-
	} else if (strcmp(name, "ecdsa") == 0) {
+
	} else if (STREQ(name, "ecdsa")) {
			keyinfo->sig_alg = ECDSA;
			keyinfo->sig_hash = SHA256;
			ret = import_params(&keyinfo->params, &secp256k1_str_params);
modified libpkg/private/utils.h
@@ -40,6 +40,7 @@

#define STARTS_WITH(string, needle) (strncasecmp(string, needle, strlen(needle)) == 0)
#define STRIEQ(string, needle) (strcasecmp(string, needle) == 0)
+
#define STREQ(string, needle) (strcmp(string, needle) == 0)
#define RELATIVE_PATH(p) (p + (*p == '/' ? 1 : 0))

typedef tll(char *) stringlist_t;
modified libpkg/repo/binary/query.c
@@ -575,15 +575,15 @@ pkg_repo_binary_groupsearch(struct pkg_repo *repo, const char *pattern, match_t
		case MATCH_ALL:
			break;
		case MATCH_INTERNAL:
-
			if (strcmp(cmp, pattern) != 0)
+
			if (!STREQ(cmp, pattern))
				continue;
			break;
		case MATCH_EXACT:
			if (pkgdb_case_sensitive()) {
-
				if (strcmp(cmp, pattern) != 0)
+
				if (!STREQ(cmp, pattern))
					continue;
			} else {
-
				if (strcasecmp(cmp, pattern) != 0)
+
				if (!STRIEQ(cmp, pattern))
					continue;
			}
			break;
modified libpkg/ssh.c
@@ -79,7 +79,7 @@ pkg_sshserve(int fd)
		if (line[linelen - 1] == '\n')
			line[linelen - 1] = '\0';

-
		if (strcmp(line, "quit") == 0)
+
		if (STREQ(line, "quit"))
			return (EPKG_OK);

		if (strncmp(line, "get ", 4) != 0) {
modified libpkg/triggers.c
@@ -52,7 +52,7 @@ static const unsigned char litchar[] =
static script_type_t
get_script_type(const char *str)
{
-
	if (strcasecmp(str, "lua") == 0)
+
	if (STRIEQ(str, "lua"))
		return (SCRIPT_LUA);
	return (SCRIPT_UNKNOWN);
}
@@ -329,7 +329,7 @@ triggers_load(bool cleanup_only)
		ext = strrchr(e->d_name, '.');
		if (ext == NULL)
			continue;
-
		if (strcmp(ext, ".ucl") != 0)
+
		if (!STREQ(ext, ".ucl"))
			continue;
		/* only regular files are considered */
		if (fstatat(dfd, e->d_name, &st, AT_SYMLINK_NOFOLLOW) != 0) {
@@ -518,7 +518,7 @@ trigger_check_match(struct trigger *t, char *dir)
	if (t->path != NULL) {
		it = NULL;
		while ((cur = ucl_iterate_object(t->path, &it, true))) {
-
			if (strcmp(dir, ucl_object_tostring(cur)) == 0) {
+
			if (STREQ(dir, ucl_object_tostring(cur))) {
				pkghash_safe_add(t->matched, dir, dir, NULL);
				return;
			}
modified libpkg/utils.c
@@ -988,7 +988,7 @@ open_tempdir(int rootfd, const char *path, stringlist_t *symlinks_allowed)
			int flag = AT_SYMLINK_NOFOLLOW;
			if (symlinks_allowed != NULL) {
				tll_foreach(*symlinks_allowed, t) {
-
					if (strcmp(RELATIVE_PATH(walk), RELATIVE_PATH(t->item)) == 0)
+
					if (STREQ(RELATIVE_PATH(walk), RELATIVE_PATH(t->item)))
						flag = 0;
				}
			}
modified src/add.c
@@ -162,7 +162,7 @@ exec_add(int argc, char **argv)
			   once per command line, but we aren't
			   testing for that at the moment */

-
			if (strcmp(file, "-") != 0 && access(file, F_OK) != 0) {
+
			if (!STREQ(file, "-") && access(file, F_OK) != 0) {
				warn("%s", file);
				if (errno == ENOENT)
					warnx("Was 'pkg install %s' meant?", file);
modified src/alias.c
@@ -95,7 +95,7 @@ exec_alias(int argc, char **argv)
	for (int i = 0; i < argc; i++) {
		it = NULL;
		while ((alias = pkg_object_iterate(all_aliases, &it))) {
-
			if (strcmp(argv[i], pkg_object_key(alias)) == 0)
+
			if (STREQ(argv[i], pkg_object_key(alias)))
				break;
		}
		if (alias) {
modified src/annotate.c
@@ -149,7 +149,7 @@ do_show(struct pkg *pkg, const char *tag)
	pkg_get(pkg, PKG_ATTR_ANNOTATIONS, &kl);
	kit = pkg_kvlist_iterator(kl);
	while ((note = pkg_kvlist_next(kit))) {
-
		if (strcmp(tag, note->key) == 0) {
+
		if (STREQ(tag, note->key)) {
			if (quiet)
				printf("%s\n", note->value);
			else
modified src/audit.c
@@ -231,13 +231,13 @@ exec_audit(int argc, char **argv)
		case 'R':
			if (optarg == NULL) {
				raw = UCL_EMIT_CONFIG;
-
			} else if (strcasecmp(optarg, "ucl") == 0) {
+
			} else if (STRIEQ(optarg, "ucl")) {
				raw = UCL_EMIT_CONFIG;
-
			} else if (strcasecmp(optarg, "json") == 0) {
+
			} else if (STRIEQ(optarg, "json")) {
				raw = UCL_EMIT_JSON;
-
			} else if (strcasecmp(optarg, "json-compact") == 0) {
+
			} else if (STRIEQ(optarg, "json-compact")) {
				raw = UCL_EMIT_JSON_COMPACT;
-
			} else if (strcasecmp(optarg, "yaml") == 0) {
+
			} else if (STRIEQ(optarg, "yaml")) {
				raw = UCL_EMIT_YAML;
			} else {
				errx(EXIT_FAILURE, "invalid argument %s for --raw option", optarg);
@@ -292,7 +292,7 @@ exec_audit(int argc, char **argv)
			char *ext = strrchr(fts_ent->fts_name, '.');
			if (ext == NULL)
				continue;
-
			if (strcmp(ext, ".pkg") != 0)
+
			if (!STREQ(ext, ".pkg"))
				continue;
			*ext = '\0';
			ext = strrchr(fts_ent->fts_name, '-');
modified src/check.c
@@ -111,7 +111,7 @@ add_missing_dep(struct pkg_dep *d, deps_entries *dh, int *nbpkgs)
	name = pkg_dep_name(d);

	tll_foreach(*dh, it) {
-
		if (strcmp(it->item, name) == 0)
+
		if (STREQ(it->item, name))
			return;
	}
	(*nbpkgs)++;
modified src/clean.c
@@ -214,8 +214,8 @@ recursive_analysis(int fd, struct pkgdb *db, const char *dir,
	}

	while ((ent = readdir(d)) != NULL) {
-
		if (strcmp(ent->d_name, ".") == 0 ||
-
		    strcmp(ent->d_name, "..") == 0)
+
		if (STREQ(ent->d_name, ".") ||
+
		    STREQ(ent->d_name, ".."))
			continue;
		snprintf(path, sizeof(path), "%s/%s", dir, ent->d_name);
		if (ent->d_type == DT_DIR) {
modified src/create.c
@@ -235,10 +235,10 @@ exec_create(int argc, char **argv)
			level = strtonum(optarg, -200, 200, &errstr);
			if (errstr == NULL)
				break;
-
			if (strcasecmp(optarg, "best") == 0) {
+
			if (STRIEQ(optarg, "best")) {
				level = INT_MAX;
				break;
-
			} else if (strcasecmp(optarg, "fast") == 0) {
+
			} else if (STRIEQ(optarg, "fast")) {
				level = INT_MIN;
				break;
			}
@@ -282,7 +282,7 @@ exec_create(int argc, char **argv)
			threads = strtonum(optarg, 0, INT_MAX, &errstr);
			if (errstr == NULL)
				break;
-
			if (strcasecmp(optarg, "auto") == 0) {
+
			if (STRIEQ(optarg, "auto")) {
				threads = 0;
				break;
			}
modified src/info.c
@@ -204,13 +204,13 @@ exec_info(int argc, char **argv)
			match = MATCH_REGEX;
			break;
		case 1:
-
			if (strcasecmp(optarg, "json") == 0)
+
			if (STRIEQ(optarg, "json"))
				opt |= INFO_RAW_JSON;
-
			else if (strcasecmp(optarg, "json-compact") == 0)
+
			else if (STRIEQ(optarg, "json-compact"))
				opt |= INFO_RAW_JSON_COMPACT;
-
			else if (strcasecmp(optarg, "yaml") == 0)
+
			else if (STRIEQ(optarg, "yaml"))
				opt |= INFO_RAW_YAML;
-
			else if (strcasecmp(optarg, "ucl") == 0)
+
			else if (STRIEQ(optarg, "ucl"))
				opt |= INFO_RAW_UCL;
			else
				errx(EXIT_FAILURE, "Invalid format '%s' for the "
modified src/install.c
@@ -91,7 +91,7 @@ exec_install(int argc, char **argv)

	nbactions = nbdone = 0;

-
	if (strcmp(argv[0], "add") == 0) {
+
	if (STREQ(argv[0], "add")) {
		auto_update = false;
		local_only = true;
		yes = true;
modified src/key.c
@@ -108,7 +108,7 @@ key_sign_data(struct pkg_key *key, const char *name)
	datafile = NULL;
	datastr = NULL;
	rc = EPKG_FATAL;
-
	if (strcmp(name, "-") == 0) {
+
	if (STREQ(name, "-")) {
		datafile = stdin;	/* XXX Make it configurable? */
		name = "stdin";
	} else {
modified src/main.c
@@ -228,13 +228,13 @@ exec_help(int argc, char **argv)
	const pkg_object *alias;
	pkg_iter it = NULL;

-
	if ((argc != 2) || (strcmp("help", argv[1]) == 0)) {
+
	if ((argc != 2) || STREQ("help", argv[1])) {
		usage_help();
		return(EXIT_FAILURE);
	}

	for (i = 0; i < cmd_len; i++) {
-
		if (strcmp(cmd[i].name, argv[1]) == 0) {
+
		if (STREQ(cmd[i].name, argv[1])) {
			xasprintf(&manpage, "/usr/bin/man pkg-%s", cmd[i].name);
			system(manpage);
			free(manpage);
@@ -247,7 +247,7 @@ exec_help(int argc, char **argv)

	if (plugins_enabled) {
		tll_foreach(plugins, it) {
-
			if (strcmp(it->item->name, argv[1]) == 0) {
+
			if (STREQ(it->item->name, argv[1])) {
				xasprintf(&manpage, "/usr/bin/man pkg-%s", it->item->name);
				system(manpage);
				free(manpage);
@@ -257,10 +257,10 @@ exec_help(int argc, char **argv)
		}
	}

-
	if (strcmp(argv[1], "pkg") == 0) {
+
	if (STREQ(argv[1], "pkg")) {
		system("/usr/bin/man 8 pkg");
		return (0);
-
	} else if (strcmp(argv[1], "pkg.conf") == 0) {
+
	} else if (STREQ(argv[1], "pkg.conf")) {
		system("/usr/bin/man 5 pkg.conf");
		return (0);
	}
@@ -268,7 +268,7 @@ exec_help(int argc, char **argv)
	/* Try aliases */
	all_aliases = pkg_config_get("ALIAS");
	while ((alias = pkg_object_iterate(all_aliases, &it))) {
-
		if (strcmp(argv[1], pkg_object_key(alias)) == 0) {
+
		if (STREQ(argv[1], pkg_object_key(alias))) {
			printf("`%s` is an alias to `%s`\n", argv[1], pkg_object_string(alias));
			return (0);
		}
@@ -508,7 +508,7 @@ expand_aliases(int argc, char ***argv)
	all_aliases = pkg_config_get("ALIAS");

	while ((alias = pkg_object_iterate(all_aliases, &it))) {
-
		if (strcmp(oldargv[0], pkg_object_key(alias)) == 0) {
+
		if (STREQ(oldargv[0], pkg_object_key(alias))) {
			matched = true;
			break;
		}
@@ -784,7 +784,7 @@ main(int argc, char **argv)
	if (activation_test)
		do_activation_test(argc);

-
	if (argc >= 1 && strcmp(argv[0], "bootstrap") == 0) {
+
	if (argc >= 1 && STREQ(argv[0], "bootstrap")) {
		int force = 0, yes = 0;
		while ((ch = getopt(argc, argv, "fy")) != -1) {
			switch (ch) {
@@ -853,7 +853,7 @@ main(int argc, char **argv)
		ret = EPKG_FATAL;
		if (plugins_enabled) {
			tll_foreach(plugins, it) {
-
				if (strcmp(it->item->name, argv[0]) == 0) {
+
				if (STREQ(it->item->name, argv[0])) {
					plugin_found = true;
					ret = it->item->exec(argc, argv);
					break;
modified src/repo.c
@@ -116,7 +116,7 @@ exec_repo(int argc, char **argv)
		return (EXIT_FAILURE);
	}

-
	if (argc > 2 && strcmp(argv[1], "signing_command:") != 0) {
+
	if (argc > 2 && !STREQ(argv[1], "signing_command:")) {
		usage_repo();
		return (EXIT_FAILURE);
	}
modified src/search.c
@@ -340,13 +340,13 @@ exec_search(int argc, char **argv)
			match = MATCH_REGEX;
			break;
		case 1:
-
			if (strcasecmp(optarg, "json") == 0)
+
			if (STRIEQ(optarg, "json"))
				opt |= INFO_RAW_JSON;
-
			else if (strcasecmp(optarg, "json-compact") == 0)
+
			else if (STRIEQ(optarg, "json-compact"))
				opt |= INFO_RAW_JSON_COMPACT;
-
			else if (strcasecmp(optarg, "yaml") == 0)
+
			else if (STRIEQ(optarg, "yaml"))
				opt |= INFO_RAW_YAML;
-
			else if (strcasecmp(optarg, "ucl") == 0)
+
			else if (STRIEQ(optarg, "ucl"))
				opt |= INFO_RAW_UCL;
			else
				errx(EXIT_FAILURE, "Invalid format '%s' for the "
modified src/update.c
@@ -62,7 +62,7 @@ pkgcli_update(bool force, bool strict, const char *reponame)

	while (pkg_repos(&r) == EPKG_OK) {
		if (reponame != NULL) {
-
			if (strcmp(pkg_repo_name(r), reponame) != 0)
+
			if (!STREQ(pkg_repo_name(r), reponame))
				continue;
		} else {
			if (!pkg_repo_enabled(r))
modified src/upgrade.c
@@ -206,7 +206,7 @@ add_vulnerable_upgrades(struct pkg_jobs *jobs, struct pkgdb *db)
			line[linelen - 1] = '\0';
		}

-
		if (strcmp(line, vuln_end_lit) == 0) {
+
		if (STREQ(line, vuln_end_lit)) {
			ret = EPKG_OK;
			break;
		}
modified src/utils.c
@@ -183,11 +183,11 @@ vquery_yesno(bool deft, const char *msg, va_list ap)
				}
			}
			else {
-
				if (strcasecmp(line, "yes\n") == 0) {
+
				if (STRIEQ(line, "yes\n")) {
					r = true;
					break;
				}
-
				else if (strcasecmp(line, "no\n") == 0) {
+
				else if (STRIEQ(line, "no\n")) {
					r = false;
					break;
				}
modified src/version.c
@@ -434,12 +434,12 @@ do_source_index(unsigned int opt, char limchar, char *pattern, match_t match,

		/* If -O was specified, check if this origin matches */
		if ((opt & VERSION_WITHORIGIN) &&
-
		    strcmp(origin, matchorigin) != 0)
+
		    !STREQ(origin, matchorigin))
			continue;

		/* If -n was specified, check if this name matches */
		if ((opt & VERSION_WITHNAME) &&
-
		    strcmp(name, matchname) != 0)
+
		    !STREQ(name, matchname))
			continue;

		ie = pkghash_get_value(index, name);
@@ -513,14 +513,14 @@ do_source_remote(unsigned int opt, char limchar, char *pattern, match_t match,

		/* If -O was specified, check if this origin matches */
		if ((opt & VERSION_WITHORIGIN) &&
-
		    strcmp(origin, matchorigin) != 0) {
+
		    !STREQ(origin, matchorigin)) {
		    	is_origin = true;
			continue;
		}

		/* If -n was specified, check if this name matches */
		if ((opt & VERSION_WITHNAME) &&
-
		    strcmp(name, matchname) != 0) {
+
		    !STREQ(name, matchname)) {
		    	is_origin = false;
			continue;
		}
@@ -672,7 +672,7 @@ validate_origin(int portsfd, const char *origin)
	buf = strrchr(origin, '/');
	buf++;

-
	if (strcmp(origin, "base") == 0)
+
	if (STREQ(origin, "base"))
		return (false);

	return (pkghash_get(cat->ports, buf) != NULL);
@@ -706,7 +706,7 @@ port_version(xstring *cmd, int portsfd, const char *origin, const char *pkgname)
					continue;
				walk[0] = '\0';
				walk++;
-
				if (strcmp(name, pkgname) == 0) {
+
				if (STREQ(name, pkgname)) {
					version = walk;
					break;
				}
@@ -761,12 +761,12 @@ do_source_ports(unsigned int opt, char limchar, char *pattern, match_t match,

		/* If -O was specified, check if this origin matches */
		if ((opt & VERSION_WITHORIGIN) &&
-
		    strcmp(origin, matchorigin) != 0)
+
		    !STREQ(origin, matchorigin))
			continue;

		/* If -n was specified, check if this name matches */
		if ((opt & VERSION_WITHNAME) &&
-
		    strcmp(name, matchname) != 0)
+
		    !STREQ(name, matchname))
			continue;

		version = port_version(cmd, portsfd, origin, name);
modified src/which.c
@@ -59,7 +59,7 @@ static bool
already_in_list(charlist *list, const char *pattern)
{
	tll_foreach(*list, it) {
-
		if (strcmp(it->item, pattern) == 0)
+
		if (STREQ(it->item, pattern))
			return (true);
	}

added tests/cocci/pkg/strieq.cocci
@@ -0,0 +1,29 @@
+
// Use STRIEQ/STRMACRO macro when possible
+

+
@@
+
expression E, E1;
+
@@
+

+
- (strcasecmp(E, E1) == 0)
+
+ STRIEQ(E, E1)
+

+
@@
+
expression E, E1;
+
@@
+

+
- (strcmp(E, E1) == 0)
+
+ STREQ(E, E1)
+

+
@@
+
expression E, E1;
+
@@
+

+
- (strcasecmp(E, E1) != 0)
+
+ !STRIEQ(E, E1)
+

+
@@
+
expression E, E1;
+
@@
+

+
- (strcmp(E, E1) != 0)
+
+ !STREQ(E, E1)