diff mbox series

Cleanup: using strtobool where needed

Message ID 20240215151714.115528-1-stefano.babic@swupdate.org
State Accepted
Delegated to: Stefano Babic
Headers show
Series Cleanup: using strtobool where needed | expand

Commit Message

Stefano Babic Feb. 15, 2024, 3:17 p.m. UTC
Replacing occurencies of string comparison with the global function.

Signed-off-by: Stefano Babic <stefano.babic@swupdate.org>
---
 handlers/btrfs_handler.c      | 2 +-
 handlers/diskformat_handler.c | 2 +-
 handlers/diskpart_handler.c   | 2 +-
 handlers/ucfw_handler.c       | 5 ++---
 4 files changed, 5 insertions(+), 6 deletions(-)

--
2.34.1
diff mbox series

Patch

diff --git a/handlers/btrfs_handler.c b/handlers/btrfs_handler.c
index c7be1153..32ecfa6c 100644
--- a/handlers/btrfs_handler.c
+++ b/handlers/btrfs_handler.c
@@ -43,7 +43,7 @@  static int btrfs(struct img_type *img,
 		ERROR("Wrong operation of btrfs filesystem: %s", cmd);
 		return -EINVAL;
 	}
-	bool tomount = IS_STR_EQUAL(dict_get_value(&img->properties, "mount"), "true");
+	bool tomount = strtobool(dict_get_value(&img->properties, "mount"));
 	if (tomount) {
 		if (!strlen(img->device)) {
 			ERROR("btrfs must be mounted, no device set");
diff --git a/handlers/diskformat_handler.c b/handlers/diskformat_handler.c
index 742954ab..635cea92 100644
--- a/handlers/diskformat_handler.c
+++ b/handlers/diskformat_handler.c
@@ -35,7 +35,7 @@  static int diskformat(struct img_type *img,

 	char *force = dict_get_value(&img->properties, "force");

-	if (force != NULL && strcmp(force, "true") == 0) {
+	if (force != NULL && strtobool(force)) {
 		; /* Skip file system exists check */
 	} else {
 		/* Check if file system exists */
diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c
index 84f1bd7c..4c2b902b 100644
--- a/handlers/diskpart_handler.c
+++ b/handlers/diskpart_handler.c
@@ -1275,7 +1275,7 @@  static int diskpart(struct img_type *img,
 						part->flags |= DOS_FLAG_ACTIVE;
 						break;
 					case PART_FORCE:
-						part->force = strcmp(equal, "true") == 0;
+						part->force = strtobool(equal);
 						TRACE("Force flag explicitly mentioned, value %d", part->force);
 						break;
 					}
diff --git a/handlers/ucfw_handler.c b/handlers/ucfw_handler.c
index 842018e6..0834ead5 100644
--- a/handlers/ucfw_handler.c
+++ b/handlers/ucfw_handler.c
@@ -672,8 +672,7 @@  static int get_gpio_from_property(struct dict_list *prop, struct mode_setup *gpi
 					return -EINVAL;
 				break;
 			case 2:
-				if (!strcmp(s, "true"))
-					gpio->active_low = true;
+				gpio->active_low = strtobool(s);
 				break;
 			}

@@ -731,7 +730,7 @@  static int install_uc_firmware_image(struct img_type *img,
 	properties = dict_get_list(&img->properties, "debug");
 	if (properties) {
 		entry = LIST_FIRST(properties);
-		if (entry && !strcmp(entry->value, "true"))
+		if (entry && strtobool(entry->value))
 			hnd_data.debug = true;
 	}