Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 858
    • Issues 858
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 57
    • Merge requests 57
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • GLib
  • Merge requests
  • !2114

Coerce type cast to void* because it causes compiler warnings

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Emmanuel Fleury requested to merge emmanuel.fleury/glib:fix_atomic_cast into main May 26, 2021
  • Overview 6
  • Commits 1
  • Pipelines 18
  • Changes 1

clang compiler with level 3 warning set is displaying a lot of warnings about the type of some arguments in some glib/gatomic.h macros. There are mainly two warnings:

glib/gtestutils.c:4261:11: warning: incompatible pointer types passing 'gpointer *' (aka 'void **') to parameter of type 'GSList **' (aka 'struct _GSList **') [-Wincompatible-pointer-types]
  while (!g_atomic_pointer_compare_and_exchange (test_filename_free_list, node->next, node));
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
glib/gatomic.h:215:44: note: expanded from macro 'g_atomic_pointer_compare_and_exchange'
    __atomic_compare_exchange_n ((atomic), &gapcae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \
                                           ^~~~~~~~~~~~~~

And, the other one:

glib/tests/atomic.c:40:9: warning: passing 'gint *' (aka 'int *') to parameter of type 'guint *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]
  res = g_atomic_int_compare_and_exchange (&u, 6, 7);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
glib/gatomic.h:164:44: note: expanded from macro 'g_atomic_int_compare_and_exchange'
    __atomic_compare_exchange_n ((atomic), &gaicae_oldval, (newval), FALSE, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST) ? TRUE : FALSE; \
                                           ^~~~~~~~~~~~~~

This patch just add a coerced cast in the macro to avoid these warnings.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: fix_atomic_cast