diff mbox series

[v2,09/18] common: Drop GLib use from gprs_proto_to_string

Message ID 20240202225405.993792-9-denkenz@gmail.com (mailing list archive)
State Accepted
Commit c934b708742c6cf7ca8d44fff769c05ecc642f99
Headers show
Series [v2,01/18] umlrunner: Also mount /var/lib as tmpfs | expand

Commit Message

Denis Kenzior Feb. 2, 2024, 10:53 p.m. UTC
Refactor this function to use bool from stdbool.h as well as drop usage
of GLib in favor of ell.
---
 src/common.c | 16 ++++++++--------
 src/common.h |  2 +-
 src/gprs.c   |  4 ++--
 3 files changed, 11 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/src/common.c b/src/common.c
index 79094ee4906c..abb151b6e8a1 100644
--- a/src/common.c
+++ b/src/common.c
@@ -778,19 +778,19 @@  const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth)
 	return NULL;
 }
 
-gboolean gprs_auth_method_from_string(const char *str,
+bool gprs_auth_method_from_string(const char *str,
 					enum ofono_gprs_auth_method *auth)
 {
-	if (g_str_equal(str, "chap")) {
+	if (l_streq0(str, "chap")) {
 		*auth = OFONO_GPRS_AUTH_METHOD_CHAP;
-		return TRUE;
-	} else if (g_str_equal(str, "pap")) {
+		return true;
+	} else if (l_streq0(str, "pap")) {
 		*auth = OFONO_GPRS_AUTH_METHOD_PAP;
-		return TRUE;
-	} else if (g_str_equal(str, "none")) {
+		return true;
+	} else if (l_streq0(str, "none")) {
 		*auth = OFONO_GPRS_AUTH_METHOD_NONE;
-		return TRUE;
+		return true;
 	}
 
-	return FALSE;
+	return false;
 }
diff --git a/src/common.h b/src/common.h
index 779de7278446..bfbf2cff0437 100644
--- a/src/common.h
+++ b/src/common.h
@@ -189,5 +189,5 @@  const char *gprs_proto_to_string(enum ofono_gprs_proto proto);
 bool gprs_proto_from_string(const char *str, enum ofono_gprs_proto *proto);
 
 const char *gprs_auth_method_to_string(enum ofono_gprs_auth_method auth);
-gboolean gprs_auth_method_from_string(const char *str,
+bool gprs_auth_method_from_string(const char *str,
 					enum ofono_gprs_auth_method *auth);
diff --git a/src/gprs.c b/src/gprs.c
index 3eb7df83ac54..dbf9b0605b7c 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -1201,7 +1201,7 @@  static DBusMessage *pri_set_auth_method(struct pri_context *ctx,
 	GKeyFile *settings = ctx->gprs->settings;
 	enum ofono_gprs_auth_method auth;
 
-	if (gprs_auth_method_from_string(str, &auth) == FALSE)
+	if (!gprs_auth_method_from_string(str, &auth))
 		return __ofono_error_invalid_format(msg);
 
 	if (ctx->context.auth_method == auth)
@@ -3183,7 +3183,7 @@  static gboolean load_context(struct ofono_gprs *gprs, const char *group)
 	if (authstr == NULL)
 		authstr = g_strdup("chap");
 
-	if (gprs_auth_method_from_string(authstr, &auth) == FALSE)
+	if (!gprs_auth_method_from_string(authstr, &auth))
 		goto error;
 
 	if (strlen(password) > OFONO_GPRS_MAX_PASSWORD_LENGTH)