[gtk/wip/smcv/aboutdialog-licenses: 1/2] aboutdialog: Update precondition checks for new licenses added in 3.24.20
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/smcv/aboutdialog-licenses: 1/2] aboutdialog: Update precondition checks for new licenses added in 3.24.20
- Date: Mon, 11 May 2020 17:36:50 +0000 (UTC)
commit 177aeca5a1fc4dc6f1a5897af516798716a9944b
Author: Simon McVittie <smcv debian org>
Date: Mon May 11 18:12:08 2020 +0100
aboutdialog: Update precondition checks for new licenses added in 3.24.20
To avoid making this mistake again, add a static assertion that the
enum is in sync with gtk_license_info, and use the length of
gtk_license_info for the precondition check.
Signed-off-by: Simon McVittie <smcv debian org>
Resolves: #2734
gtk/gtkaboutdialog.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c
index 8bfbdac52e..adb0515aa9 100644
--- a/gtk/gtkaboutdialog.c
+++ b/gtk/gtkaboutdialog.c
@@ -130,6 +130,9 @@ static const LicenseInfo gtk_license_info [] = {
{ N_("Apache License, Version 2.0"), "https://opensource.org/licenses/Apache-2.0" },
{ N_("Mozilla Public License 2.0"), "https://opensource.org/licenses/MPL-2.0" }
};
+/* Keep this static assertion updated with the last element of the
+ * enumeration, and make sure it matches the last element of the array */
+G_STATIC_ASSERT (G_N_ELEMENTS (gtk_license_info) - 1 == GTK_LICENSE_MPL_2_0);
typedef struct
{
@@ -2467,7 +2470,7 @@ gtk_about_dialog_set_license_type (GtkAboutDialog *about,
g_return_if_fail (GTK_IS_ABOUT_DIALOG (about));
g_return_if_fail (license_type >= GTK_LICENSE_UNKNOWN &&
- license_type <= GTK_LICENSE_AGPL_3_0_ONLY);
+ license_type < G_N_ELEMENTS (gtk_license_info));
priv = about->priv;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]