A fork of Gnome-control-center with some tweaks
Find a file
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
.gitlab/issue_templates gitlab, issue-templates: Drop "Feature" and "Epic" templates 2024-04-30 13:29:07 +00:00
.gitlab-ci ci: Change potfiles check regex 2024-04-15 11:42:45 +02:00
build-aux flatpak: Suffix app ID with .Devel 2024-03-21 16:14:31 +00:00
data/icons flatpak: Suffix app ID with .Devel 2024-03-21 16:14:31 +00:00
docs docs: Fix typo in CODEOWNERS path 2023-12-22 10:40:50 +01:00
gettext/its build: Fix translation context missing from keyboard entries 2018-01-24 20:43:34 +01:00
man update DocBook DTD version to latest stable 4.5 2024-03-21 15:56:33 +00:00
panels general: Fix various strict-aliasing warnings with g_clear_pointer() 2024-05-16 14:01:02 +00:00
po Update Catalan translation 2024-05-15 20:27:23 +00:00
search-provider search-provider: Connect signal handlers in swapped form 2023-06-07 09:14:28 +12:00
shell window: Port "Warning: Development Version" to AdwAlertDialog 2024-05-14 15:07:31 -03:00
subprojects subprojects: Update gvc to latest commit 2024-03-14 12:19:51 +00:00
tests test-network-panel: Allow separator in speed label 2024-04-08 13:02:40 +00:00
.clang-format Add style check to CI 2023-10-05 11:26:47 +00:00
.gitignore gitignore: Add flatpak-builder directory to .gitignore 2023-03-28 07:53:40 +00:00
.gitlab-ci.yml ci: Include gtk-doc in base container 2024-04-08 15:33:56 +02:00
.gitmodules Switch to GTK4 & libadwaita 2021-12-14 22:34:21 -03:00
COPYING build: Update COPYING with new mailing address 2012-08-22 15:33:18 +01:00
gnome-control-center.doap doap: Add Matthijs Velsink the list of maintainers 2024-04-26 15:48:45 +02:00
meson.build build, privacy: Make Location settings build conditional 2024-04-04 13:52:10 +02:00
meson_options.txt build: Enable "Location Services" by default 2024-05-02 09:27:38 +00:00
NEWS 46.rc 2024-03-03 18:35:24 +04:00
README.md README: Add proper links to CONTRIBUTING and CODING_STYLE 2024-04-08 23:05:10 +02:00

Build Status Coverage report License

GNOME Settings

GNOME Settings is GNOME's main interface for configuration of various aspects of your desktop.

If you are looking for usage tips and instructions, you can find it at the User Documentation (translated in various languages).

Reporting Issues

Before reporting any bugs or opening feature requests, read the communication guidelines.

Report issues to the GNOME issue tracking system.

Feature Requests

For feature requests or conceptual changes, please start a topic on GNOME Discourse.

Contributing

See docs/CONTRIBUTING.md for details on the contribution process, and docs/CODING_STYLE.md for the coding style guidelines.

Visit the Settings development wiki for more information.