[gimp] libgimpwidgets: use g_return_if_reached() in unreachable code path.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpwidgets: use g_return_if_reached() in unreachable code path.
- Date: Mon, 22 Jan 2018 10:29:02 +0000 (UTC)
commit 54a1e8f2b1b78d57c9157594027c3a64ad81dc0a
Author: Jehan <jehan girinstud io>
Date: Mon Jan 22 11:23:49 2018 +0100
libgimpwidgets: use g_return_if_reached() in unreachable code path.
This way, we get proper CRITICAL if ever there is a logic error (or in
this case, if we add new values to enums and forget to append them to
switch cases.
This will make these bugs much easier to debug if (when!) they happen.
libgimpwidgets/gimpcolorselect.c | 1 +
libgimpwidgets/gimpcolorselector.c | 3 +++
2 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorselect.c b/libgimpwidgets/gimpcolorselect.c
index b99ae47..be76efe 100644
--- a/libgimpwidgets/gimpcolorselect.c
+++ b/libgimpwidgets/gimpcolorselect.c
@@ -466,6 +466,7 @@ gimp_color_select_init (GimpColorSelect *select)
break;
default:
/* Should not happen. */
+ g_return_if_reached ();
break;
}
end_channel = channel + 3;
diff --git a/libgimpwidgets/gimpcolorselector.c b/libgimpwidgets/gimpcolorselector.c
index 0a03053..e98d077 100644
--- a/libgimpwidgets/gimpcolorselector.c
+++ b/libgimpwidgets/gimpcolorselector.c
@@ -421,8 +421,10 @@ gimp_color_selector_set_channel (GimpColorSelector *selector,
break;
case GIMP_COLOR_SELECTOR_ALPHA:
/* Alpha channel does not change the color model. */
+ break;
default:
/* Should not happen. */
+ g_return_if_reached ();
break;
}
@@ -508,6 +510,7 @@ gimp_color_selector_set_model (GimpColorSelector *selector,
break;
default:
/* Should not happen. */
+ g_return_if_reached ();
break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]