git: 79a4240b1359 - main - ctld: Use preferred style for evaluating result of strcmp

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 12 Feb 2025 19:34:33 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=79a4240b135952cb318adf216a9e5d3ccbd6e343

commit 79a4240b135952cb318adf216a9e5d3ccbd6e343
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2025-02-12 19:27:30 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2025-02-12 19:27:30 +0000

    ctld: Use preferred style for evaluating result of strcmp
    
    Reviewed by:    asomers
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D48932
---
 usr.sbin/ctld/uclparse.c | 86 ++++++++++++++++++++++++------------------------
 1 file changed, 43 insertions(+), 43 deletions(-)

diff --git a/usr.sbin/ctld/uclparse.c b/usr.sbin/ctld/uclparse.c
index 8654004d009e..b782779f4d0e 100644
--- a/usr.sbin/ctld/uclparse.c
+++ b/usr.sbin/ctld/uclparse.c
@@ -253,7 +253,7 @@ uclparse_toplevel(const ucl_object_t *top)
 	while ((obj = ucl_iterate_object(top, &it, true))) {
 		const char *key = ucl_object_key(obj);
 
-		if (!strcmp(key, "debug")) {
+		if (strcmp(key, "debug") == 0) {
 			if (obj->type == UCL_INT)
 				conf->conf_debug = ucl_object_toint(obj);
 			else {
@@ -262,7 +262,7 @@ uclparse_toplevel(const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "timeout")) {
+		if (strcmp(key, "timeout") == 0) {
 			if (obj->type == UCL_INT)
 				conf->conf_timeout = ucl_object_toint(obj);
 			else {
@@ -271,7 +271,7 @@ uclparse_toplevel(const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "maxproc")) {
+		if (strcmp(key, "maxproc") == 0) {
 			if (obj->type == UCL_INT)
 				conf->conf_maxproc = ucl_object_toint(obj);
 			else {
@@ -280,7 +280,7 @@ uclparse_toplevel(const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "pidfile")) {
+		if (strcmp(key, "pidfile") == 0) {
 			if (obj->type == UCL_STRING)
 				conf->conf_pidfile_path = strdup(
 				    ucl_object_tostring(obj));
@@ -290,7 +290,7 @@ uclparse_toplevel(const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "isns-server")) {
+		if (strcmp(key, "isns-server") == 0) {
 			if (obj->type == UCL_ARRAY) {
 				iter = NULL;
 				while ((child = ucl_iterate_object(obj, &iter,
@@ -309,7 +309,7 @@ uclparse_toplevel(const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "isns-period")) {
+		if (strcmp(key, "isns-period") == 0) {
 			if (obj->type == UCL_INT)
 				conf->conf_isns_period = ucl_object_toint(obj);
 			else {
@@ -318,7 +318,7 @@ uclparse_toplevel(const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "isns-timeout")) {
+		if (strcmp(key, "isns-timeout") == 0) {
 			if (obj->type == UCL_INT)
 				conf->conf_isns_timeout = ucl_object_toint(obj);
 			else {
@@ -327,7 +327,7 @@ uclparse_toplevel(const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "auth-group")) {
+		if (strcmp(key, "auth-group") == 0) {
 			if (obj->type == UCL_OBJECT) {
 				iter = NULL;
 				while ((child = ucl_iterate_object(obj, &iter, true))) {
@@ -339,7 +339,7 @@ uclparse_toplevel(const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "portal-group")) {
+		if (strcmp(key, "portal-group") == 0) {
 			if (obj->type == UCL_OBJECT) {
 				iter = NULL;
 				while ((child = ucl_iterate_object(obj, &iter, true))) {
@@ -351,7 +351,7 @@ uclparse_toplevel(const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "lun")) {
+		if (strcmp(key, "lun") == 0) {
 			if (obj->type == UCL_OBJECT) {
 				iter = NULL;
 				while ((child = ucl_iterate_object(obj, &iter, true))) {
@@ -369,7 +369,7 @@ uclparse_toplevel(const ucl_object_t *top)
 	while ((obj = ucl_iterate_object(top, &it, true))) {
 		const char *key = ucl_object_key(obj);
 
-		if (!strcmp(key, "target")) {
+		if (strcmp(key, "target") == 0) {
 			if (obj->type == UCL_OBJECT) {
 				iter = NULL;
 				while ((child = ucl_iterate_object(obj, &iter,
@@ -397,7 +397,7 @@ uclparse_auth_group(const char *name, const ucl_object_t *top)
 	const ucl_object_t *obj = NULL, *tmp = NULL;
 	const char *key;
 
-	if (!strcmp(name, "default") &&
+	if (strcmp(name, "default") == 0 &&
 	    conf->conf_default_ag_defined == false) {
 		auth_group = auth_group_find(conf, name);
 		conf->conf_default_ag_defined = true;
@@ -411,14 +411,14 @@ uclparse_auth_group(const char *name, const ucl_object_t *top)
 	while ((obj = ucl_iterate_object(top, &it, true))) {
 		key = ucl_object_key(obj);
 
-		if (!strcmp(key, "auth-type")) {
+		if (strcmp(key, "auth-type") == 0) {
 			const char *value = ucl_object_tostring(obj);
 
 			if (!auth_group_set_type(auth_group, value))
 				return (false);
 		}
 
-		if (!strcmp(key, "chap")) {
+		if (strcmp(key, "chap") == 0) {
 			if (obj->type != UCL_ARRAY) {
 				log_warnx("\"chap\" property of "
 				    "auth-group \"%s\" is not an array",
@@ -433,7 +433,7 @@ uclparse_auth_group(const char *name, const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "chap-mutual")) {
+		if (strcmp(key, "chap-mutual") == 0) {
 			if (obj->type != UCL_ARRAY) {
 				log_warnx("\"chap-mutual\" property of "
 				    "auth-group \"%s\" is not an array",
@@ -448,7 +448,7 @@ uclparse_auth_group(const char *name, const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "initiator-name")) {
+		if (strcmp(key, "initiator-name") == 0) {
 			if (obj->type != UCL_ARRAY) {
 				log_warnx("\"initiator-name\" property of "
 				    "auth-group \"%s\" is not an array",
@@ -466,7 +466,7 @@ uclparse_auth_group(const char *name, const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "initiator-portal")) {
+		if (strcmp(key, "initiator-portal") == 0) {
 			if (obj->type != UCL_ARRAY) {
 				log_warnx("\"initiator-portal\" property of "
 				    "auth-group \"%s\" is not an array",
@@ -597,7 +597,7 @@ uclparse_portal_group(const char *name, const ucl_object_t *top)
 	while ((obj = ucl_iterate_object(top, &it, true))) {
 		key = ucl_object_key(obj);
 
-		if (!strcmp(key, "discovery-auth-group")) {
+		if (strcmp(key, "discovery-auth-group") == 0) {
 			portal_group->pg_discovery_auth_group =
 			    auth_group_find(conf, ucl_object_tostring(obj));
 			if (portal_group->pg_discovery_auth_group == NULL) {
@@ -609,7 +609,7 @@ uclparse_portal_group(const char *name, const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "discovery-filter")) {
+		if (strcmp(key, "discovery-filter") == 0) {
 			if (obj->type != UCL_STRING) {
 				log_warnx("\"discovery-filter\" property of "
 				    "portal-group \"%s\" is not a string",
@@ -622,7 +622,7 @@ uclparse_portal_group(const char *name, const ucl_object_t *top)
 				return (false);
 		}
 
-		if (!strcmp(key, "listen")) {
+		if (strcmp(key, "listen") == 0) {
 			if (obj->type == UCL_STRING) {
 				if (!portal_group_add_listen(portal_group,
 				    ucl_object_tostring(obj), false))
@@ -644,7 +644,7 @@ uclparse_portal_group(const char *name, const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "listen-iser")) {
+		if (strcmp(key, "listen-iser") == 0) {
 			if (obj->type == UCL_STRING) {
 				if (!portal_group_add_listen(portal_group,
 				    ucl_object_tostring(obj), true))
@@ -666,7 +666,7 @@ uclparse_portal_group(const char *name, const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "redirect")) {
+		if (strcmp(key, "redirect") == 0) {
 			if (obj->type != UCL_STRING) {
 				log_warnx("\"listen\" property of "
 				    "portal-group \"%s\" is not a string",
@@ -679,7 +679,7 @@ uclparse_portal_group(const char *name, const ucl_object_t *top)
 				return (false);
 		}
 
-		if (!strcmp(key, "options")) {
+		if (strcmp(key, "options") == 0) {
 			if (obj->type != UCL_OBJECT) {
 				log_warnx("\"options\" property of portal group "
 				    "\"%s\" is not an object", portal_group->pg_name);
@@ -695,12 +695,12 @@ uclparse_portal_group(const char *name, const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "dscp")) {
+		if (strcmp(key, "dscp") == 0) {
 			if (!uclparse_dscp("portal", portal_group, obj))
 				return (false);
 		}
 
-		if (!strcmp(key, "pcp")) {
+		if (strcmp(key, "pcp") == 0) {
 			if (!uclparse_pcp("portal", portal_group, obj))
 				return (false);
 		}
@@ -724,7 +724,7 @@ uclparse_target(const char *name, const ucl_object_t *top)
 	while ((obj = ucl_iterate_object(top, &it, true))) {
 		key = ucl_object_key(obj);
 
-		if (!strcmp(key, "alias")) {
+		if (strcmp(key, "alias") == 0) {
 			if (obj->type != UCL_STRING) {
 				log_warnx("\"alias\" property of target "
 				    "\"%s\" is not a string", target->t_name);
@@ -734,7 +734,7 @@ uclparse_target(const char *name, const ucl_object_t *top)
 			target->t_alias = strdup(ucl_object_tostring(obj));
 		}
 
-		if (!strcmp(key, "auth-group")) {
+		if (strcmp(key, "auth-group") == 0) {
 			const char *ag;
 
 			if (target->t_auth_group != NULL) {
@@ -762,7 +762,7 @@ uclparse_target(const char *name, const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "auth-type")) {
+		if (strcmp(key, "auth-type") == 0) {
 			if (target->t_auth_group != NULL) {
 				if (target->t_auth_group->ag_name != NULL) {
 					log_warnx("cannot use both auth-group and "
@@ -782,7 +782,7 @@ uclparse_target(const char *name, const ucl_object_t *top)
 				return (false);
 		}
 
-		if (!strcmp(key, "chap")) {
+		if (strcmp(key, "chap") == 0) {
 			if (target->t_auth_group != NULL) {
 				if (target->t_auth_group->ag_name != NULL) {
 					log_warnx("cannot use both auth-group "
@@ -801,12 +801,12 @@ uclparse_target(const char *name, const ucl_object_t *top)
 				return (false);
 		}
 
-		if (!strcmp(key, "chap-mutual")) {
+		if (strcmp(key, "chap-mutual") == 0) {
 			if (!uclparse_chap_mutual(target->t_auth_group, obj))
 				return (false);
 		}
 
-		if (!strcmp(key, "initiator-name")) {
+		if (strcmp(key, "initiator-name") == 0) {
 			const struct auth_name *an;
 
 			if (target->t_auth_group != NULL) {
@@ -829,7 +829,7 @@ uclparse_target(const char *name, const ucl_object_t *top)
 				return (false);
 		}
 
-		if (!strcmp(key, "initiator-portal")) {
+		if (strcmp(key, "initiator-portal") == 0) {
 			const struct auth_portal *ap;
 
 			if (target->t_auth_group != NULL) {
@@ -852,7 +852,7 @@ uclparse_target(const char *name, const ucl_object_t *top)
 				return (false);
 		}
 
-		if (!strcmp(key, "portal-group")) {
+		if (strcmp(key, "portal-group") == 0) {
 			if (obj->type == UCL_OBJECT) {
 				if (!uclparse_target_portal_group(target, obj))
 					return (false);
@@ -868,14 +868,14 @@ uclparse_target(const char *name, const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "port")) {
+		if (strcmp(key, "port") == 0) {
 			const char *value;
 
 			value = ucl_object_tostring(obj);
 			target->t_pport = strdup(value);
 		}
 
-		if (!strcmp(key, "redirect")) {
+		if (strcmp(key, "redirect") == 0) {
 			if (obj->type != UCL_STRING) {
 				log_warnx("\"redirect\" property of target "
 				    "\"%s\" is not a string", target->t_name);
@@ -887,7 +887,7 @@ uclparse_target(const char *name, const ucl_object_t *top)
 				return (false);
 		}
 
-		if (!strcmp(key, "lun")) {
+		if (strcmp(key, "lun") == 0) {
 			while ((tmp = ucl_iterate_object(obj, &it2, true))) {
 				if (!uclparse_target_lun(target, tmp))
 					return (false);
@@ -913,7 +913,7 @@ uclparse_lun(const char *name, const ucl_object_t *top)
 	while ((obj = ucl_iterate_object(top, &it, true))) {
 		key = ucl_object_key(obj);
 
-		if (!strcmp(key, "backend")) {
+		if (strcmp(key, "backend") == 0) {
 			if (obj->type != UCL_STRING) {
 				log_warnx("\"backend\" property of lun "
 				    "\"%s\" is not a string",
@@ -924,7 +924,7 @@ uclparse_lun(const char *name, const ucl_object_t *top)
 			lun_set_backend(lun, ucl_object_tostring(obj));
 		}
 
-		if (!strcmp(key, "blocksize")) {
+		if (strcmp(key, "blocksize") == 0) {
 			if (obj->type != UCL_INT) {
 				log_warnx("\"blocksize\" property of lun "
 				    "\"%s\" is not an integer", lun->l_name);
@@ -934,7 +934,7 @@ uclparse_lun(const char *name, const ucl_object_t *top)
 			lun_set_blocksize(lun, ucl_object_toint(obj));
 		}
 
-		if (!strcmp(key, "device-id")) {
+		if (strcmp(key, "device-id") == 0) {
 			if (obj->type != UCL_STRING) {
 				log_warnx("\"device-id\" property of lun "
 				    "\"%s\" is not an integer", lun->l_name);
@@ -944,7 +944,7 @@ uclparse_lun(const char *name, const ucl_object_t *top)
 			lun_set_device_id(lun, ucl_object_tostring(obj));
 		}
 
-		if (!strcmp(key, "options")) {
+		if (strcmp(key, "options") == 0) {
 			if (obj->type != UCL_OBJECT) {
 				log_warnx("\"options\" property of lun "
 				    "\"%s\" is not an object", lun->l_name);
@@ -960,7 +960,7 @@ uclparse_lun(const char *name, const ucl_object_t *top)
 			}
 		}
 
-		if (!strcmp(key, "path")) {
+		if (strcmp(key, "path") == 0) {
 			if (obj->type != UCL_STRING) {
 				log_warnx("\"path\" property of lun "
 				    "\"%s\" is not a string", lun->l_name);
@@ -970,7 +970,7 @@ uclparse_lun(const char *name, const ucl_object_t *top)
 			lun_set_path(lun, ucl_object_tostring(obj));
 		}
 
-		if (!strcmp(key, "serial")) {
+		if (strcmp(key, "serial") == 0) {
 			if (obj->type != UCL_STRING) {
 				log_warnx("\"serial\" property of lun "
 				    "\"%s\" is not a string", lun->l_name);
@@ -980,7 +980,7 @@ uclparse_lun(const char *name, const ucl_object_t *top)
 			lun_set_serial(lun, ucl_object_tostring(obj));
 		}
 
-		if (!strcmp(key, "size")) {
+		if (strcmp(key, "size") == 0) {
 			if (obj->type != UCL_INT) {
 				log_warnx("\"size\" property of lun "
 				    "\"%s\" is not an integer", lun->l_name);