gnome-control-center/panels/common
Philip Withnall ea014f24eb general: Fix various strict-aliasing warnings with g_clear_pointer()
This is just unfortunate. It’s an aliasing violation to cast a pointer
to a pointer (and there’s no way round that), although in practice it
will not cause a problem. People do quite often compile with
`-Werror=strict-aliasing`, though, so fixing the warnings is helpful.

Warnings are of the form:
```
../../source/gnome-control-center/panels/keyboard/cc-keyboard-shortcut-dialog.c: In function ‘cc_keyboard_shortcut_dialog_finalize’:
../../source/gnome-control-center/panels/keyboard/cc-keyboard-shortcut-dialog.c:518:20: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  518 |   g_clear_pointer ((GtkWindow**)&self->shortcut_editor, gtk_window_destroy);
/opt/gnome/install/include/glib-2.0/glib/gmacros.h:871:47: note: in definition of macro ‘G_STATIC_ASSERT’
  871 | #define G_STATIC_ASSERT(expr) _Static_assert (expr, "Expression evaluates to false")
      |                                               ^~~~
../../source/gnome-control-center/panels/keyboard/cc-keyboard-shortcut-dialog.c:518:3: note: in expansion of macro ‘g_clear_pointer’
  518 |   g_clear_pointer ((GtkWindow**)&self->shortcut_editor, gtk_window_destroy);
      |   ^~~~~~~~~~~~~~~
In file included from /opt/gnome/install/include/glib-2.0/glib/gatomic.h:30,
                 from /opt/gnome/install/include/glib-2.0/glib/gthread.h:34,
                 from /opt/gnome/install/include/glib-2.0/glib/gasyncqueue.h:34,
                 from /opt/gnome/install/include/glib-2.0/glib.h:34:
../../source/gnome-control-center/panels/keyboard/cc-keyboard-shortcut-dialog.c:518:20: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  518 |   g_clear_pointer ((GtkWindow**)&self->shortcut_editor, gtk_window_destroy);
/opt/gnome/install/include/glib-2.0/glib/glib-typeof.h:39:36: note: in definition of macro ‘glib_typeof’
   39 | #define glib_typeof(t) __typeof__ (t)
      |                                    ^
../../source/gnome-control-center/panels/keyboard/cc-keyboard-shortcut-dialog.c:518:3: note: in expansion of macro ‘g_clear_pointer’
  518 |   g_clear_pointer ((GtkWindow**)&self->shortcut_editor, gtk_window_destroy);
      |   ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
```

I believe it’s better to fix these by expanding out the
`g_clear_pointer()` call, than by changing the types of variables — the
latter approach means everything becomes a `GtkWidget` or a `GtkWindow`,
which loses type specificity. So this approach is in contrast to that
taken in commit 1bafd46ea3, for example.

Alternative approaches would be:
 1. Add internal `cc_clear_window()` and `cc_clear_widget()` helpers
    which do this in a single line without aliasing violations.
 2. Enforce compiling with `-Wno-strict-aliasing` if strict aliasing is
    not something that g-c-c maintainers want to care about (which would
    be fine, aliasing checks probably won’t catch any bugs in this kind
    of code).

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Fixes: #2563
2024-05-16 14:01:02 +00:00
..
cc-common-language.c common: Use g_auto for variables 2018-06-07 01:08:07 +00:00
cc-common-language.h common: sharing: Replace ifdefs with #pragma once 2018-06-01 21:41:34 +00:00
cc-hostname-entry.c general: Use g_clear_handle_id to remove GSources 2024-02-06 09:22:07 +00:00
cc-hostname-entry.h common: Make CcHostnameEntry use CcHostname to access hostnamed 2024-01-30 13:34:10 +00:00
cc-hostname.c common: Introduce CcHostname 2024-01-30 13:34:10 +00:00
cc-hostname.h common: Introduce CcHostname 2024-01-30 13:34:10 +00:00
cc-illustrated-row.c illustrated-row, split-row: Add widget name and css class 2023-03-28 13:52:12 +00:00
cc-illustrated-row.h common, multitasking: Introduce CcIllustratedRow 2023-02-14 13:31:23 -03:00
cc-illustrated-row.ui illustrated-row: Use correct property to scale down image 2023-10-10 12:39:39 +00:00
cc-language-chooser.c Remove unnecessary visibility change 2023-03-29 14:26:55 +13:00
cc-language-chooser.h Use GtkDialog instead of HdyDialog 2020-07-20 08:04:28 +02:00
cc-language-chooser.ui general: Add placeholder text to various search entries 2023-04-21 12:40:42 +00:00
cc-language-row.c region: Fix creating rows for locales without country 2022-05-26 19:05:16 +00:00
cc-language-row.h common: Split out CcLanguageRow from CcLanguageChooser 2021-02-01 04:02:22 +00:00
cc-language-row.ui common: Rename 'check' to 'check_image' 2021-02-23 10:28:22 -03:00
cc-list-row-info-button.c common: Fix name of internal InfoButton get/set functions 2023-05-31 21:34:03 +00:00
cc-list-row-info-button.h common: Introduce CcListRowInfoButton widget 2023-05-16 13:32:21 +00:00
cc-list-row-info-button.ui common: Replace info-symbolic icon with info-outline-symbolic 2024-03-11 15:06:26 +00:00
cc-list-row.c cc-list-row: Describe the row by the secondary label 2024-04-29 22:00:56 +02:00
cc-list-row.h common: Remove switch feature to CcListRow 2023-06-30 09:06:56 +00:00
cc-list-row.ui cc-list-row: Add use-underline property 2023-11-13 09:55:36 +00:00
cc-number-list.c number-list: Add docstrings to props and methods 2024-05-14 21:29:02 +02:00
cc-number-list.h number-list: Add docstrings to props and methods 2024-05-14 21:29:02 +02:00
cc-permission-infobar.c permission-infobar: Use em dash 2024-04-18 08:50:12 +00:00
cc-permission-infobar.h common: Port to GTK4 2021-12-14 22:34:21 -03:00
cc-permission-infobar.ui permission-infobar: Remove placeholder title 2024-04-18 08:50:12 +00:00
cc-split-row.c split-row: Add :compact property 2023-08-25 08:00:43 +00:00
cc-split-row.h split-row: Add :compact property 2023-08-25 08:00:43 +00:00
cc-split-row.ui cc-split-row: Add use-underline property 2023-11-06 17:46:25 +00:00
cc-time-editor.c common: Fix time entry for RTL languages 2023-05-26 01:03:45 +00:00
cc-time-editor.h common: Port to GTK4 2021-12-14 22:34:21 -03:00
cc-time-editor.ui common: Port to GTK4 2021-12-14 22:34:21 -03:00
cc-time-entry.c common: Connect signal handlers in swapped form 2023-06-07 09:12:54 +12:00
cc-time-entry.h common: Port to GTK4 2021-12-14 22:34:21 -03:00
cc-util.c common: Check for valid GDateTime object before comparing 2024-03-27 13:13:13 +00:00
cc-util.h panels: cc-util: a smart date time 2022-10-25 23:49:16 +00:00
cc-vertical-row.c general: Fix various strict-aliasing warnings with g_clear_pointer() 2024-05-16 14:01:02 +00:00
cc-vertical-row.h common, multitasking: Introduce CcIllustratedRow 2023-02-14 13:31:23 -03:00
cc-vertical-row.ui common, multitasking: Introduce CcIllustratedRow 2023-02-14 13:31:23 -03:00
common.gresource.xml common: Add small cross icon 2024-04-29 11:01:18 -02:30
cross-small-symbolic.svg common: Add small cross icon 2024-04-29 11:01:18 -02:30
gnome-control-center.rules.in common: Add polkit rules for modem management 2021-08-13 19:25:41 +00:00
gnome-settings-bus.h common: Port to GTK4 2021-12-14 22:34:21 -03:00
gsd-device-manager.c common: Query Virtual core pointer for currently used tablet 2023-12-20 20:57:52 +01:00
gsd-device-manager.h common: Add GsdDevice API to tell whether 2 devices are grouped 2020-09-04 21:46:19 +00:00
gsd-input-helper.c common: Port to GTK4 2021-12-14 22:34:21 -03:00
gsd-input-helper.h common: Remove unused X11/XI1/XI2 API 2019-08-08 15:18:07 +00:00
hostname-helper.c trivial: Replace g_memmove by memmove 2020-02-02 12:25:42 -03:00
hostname-helper.h common: sharing: Replace ifdefs with #pragma once 2018-06-01 21:41:34 +00:00
info-outline-symbolic.svg common: Replace info-symbolic icon with info-outline-symbolic 2024-03-11 15:06:26 +00:00
meson.build common: Add CcNumberObject and CcNumberList 2024-05-14 21:29:02 +02:00