From 5aa42683eebeee6ab8dfdb612d1b39df4176225d Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Thu, 13 Feb 2025 18:56:04 +0000 Subject: [PATCH] gfilemonitor: Use an enum for properties to allow -Wswitch-enum MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This lets the compiler tell us if we’ve accidentally missed a property implementation from `get_property()` or `set_property()`. Signed-off-by: Philip Withnall --- gio/gfilemonitor.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/gio/gfilemonitor.c b/gio/gfilemonitor.c index f78fad2e9..ebb9e6fdb 100644 --- a/gio/gfilemonitor.c +++ b/gio/gfilemonitor.c @@ -64,12 +64,11 @@ struct _GFileMonitorPrivate G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GFileMonitor, g_file_monitor, G_TYPE_OBJECT) -enum +typedef enum { - PROP_0, - PROP_RATE_LIMIT, + PROP_RATE_LIMIT = 1, PROP_CANCELLED -}; +} GFileMonitorProperty; static guint g_file_monitor_changed_signal; @@ -79,16 +78,17 @@ g_file_monitor_set_property (GObject *object, const GValue *value, GParamSpec *pspec) { - //GFileMonitor *monitor; - - //monitor = G_FILE_MONITOR (object); - - switch (prop_id) + switch ((GFileMonitorProperty) prop_id) { case PROP_RATE_LIMIT: /* not supported by default */ break; + case PROP_CANCELLED: + /* Read only */ + g_assert_not_reached (); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -101,7 +101,7 @@ g_file_monitor_get_property (GObject *object, GValue *value, GParamSpec *pspec) { - switch (prop_id) + switch ((GFileMonitorProperty) prop_id) { case PROP_RATE_LIMIT: /* we expect this to be overridden... */