From 401ff0661406f14b03226fe566830662ed10ff86 Mon Sep 17 00:00:00 2001 From: Emmanuel Fleury Date: Thu, 15 Apr 2021 11:00:18 +0200 Subject: [PATCH] Fix signedness warning in gio/gkeyfilesettingsbackend.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gio/gkeyfilesettingsbackend.c: In function ‘convert_path’: gio/gkeyfilesettingsbackend.c:155:15: warning: comparison of integer expressions of different signedness: ‘gsize’ {aka ‘long unsigned int’} and ‘gint’ {aka ‘int’} 155 | if (key_len < kfsb->prefix_len || | ^ --- gio/gkeyfilesettingsbackend.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gio/gkeyfilesettingsbackend.c b/gio/gkeyfilesettingsbackend.c index 094be3f91..9319491d5 100644 --- a/gio/gkeyfilesettingsbackend.c +++ b/gio/gkeyfilesettingsbackend.c @@ -66,9 +66,9 @@ typedef struct GHashTable *system_locks; /* Used as a set, owning the strings it contains */ gchar *prefix; - gint prefix_len; + gsize prefix_len; gchar *root_group; - gint root_group_len; + gsize root_group_len; GFile *file; GFileMonitor *file_monitor; @@ -173,7 +173,9 @@ convert_path (GKeyfileSettingsBackend *kfsb, /* if a root_group was specified, make sure the user hasn't given * a path that ghosts that group name */ - if (last_slash != NULL && (last_slash - key) == kfsb->root_group_len && memcmp (key, kfsb->root_group, last_slash - key) == 0) + if (last_slash != NULL && last_slash - key >= 0 && + (gsize) (last_slash - key) == kfsb->root_group_len && + memcmp (key, kfsb->root_group, last_slash - key) == 0) return FALSE; } else