From 73288eefe0d3b96f9fd5dbb67c89187a01826420 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 27 Sep 2023 13:27:43 +1000 Subject: [PATCH] Switch strcmp to g_str_equal() The latter is less errorprone for equality comparisons. --- test/test-tablet-svg-validity.c | 4 ++-- test/test-tablet-validity.c | 2 +- tools/list-compatible-styli.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/test/test-tablet-svg-validity.c b/test/test-tablet-svg-validity.c index 8b351b746..bb3b2d09d 100644 --- a/test/test-tablet-svg-validity.c +++ b/test/test-tablet-svg-validity.c @@ -69,7 +69,7 @@ class_found (gchar **classes, gchar *value) { gchar **ptr = classes; while (*ptr) { - if (strcmp (*ptr++, value) == 0) + if (g_str_equal (*ptr++, value)) return TRUE; } @@ -365,7 +365,7 @@ static void setup_tests(WacomDevice *device) const char *name; name = libwacom_get_name(device); - if (strcmp(name, "Generic") == 0) + if (g_str_equal(name, "Generic")) return; add_test(device, test_filename); diff --git a/test/test-tablet-validity.c b/test/test-tablet-validity.c index 209508979..4b7983d56 100644 --- a/test/test-tablet-validity.c +++ b/test/test-tablet-validity.c @@ -327,7 +327,7 @@ static void setup_tests(WacomDevice *device) WacomClass cls; name = libwacom_get_name(device); - if (strcmp(name, "Generic") == 0) + if (g_str_equal(name, "Generic")) return; add_test(device, test_class); diff --git a/tools/list-compatible-styli.c b/tools/list-compatible-styli.c index 1233a20e9..0e2643cfe 100644 --- a/tools/list-compatible-styli.c +++ b/tools/list-compatible-styli.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "libwacom.h" static void @@ -72,7 +73,7 @@ int main(int argc, char **argv) if (argc > 1) { printf("Usage: %s [--help] - list compatible styli\n", basename(argv[0])); - return !!(strcmp(argv[1], "--help")); + return g_str_equal(argv[1], "--help"); } db = libwacom_database_new_for_path(DATABASEPATH);