Skip to content

Fix -Wconst-qual warnings #11

@pattop

Description

@pattop

gcc correctly warns about a couple of dodgy casts when building Apex with -Wcast-qual.

In file included from /home/patrick/src/motec/adr2/apex/sys/include/arch.h:39,
                 from /home/patrick/src/motec/adr2/apex/sys/kern/syslog.c:8:
/home/patrick/src/motec/adr2/apex/sys/kern/syslog.c: In function 'syslog_output':
/home/patrick/src/motec/adr2/apex/sys/include/compiler.h:108:4: warning: to be safe all intermediate pointers in cast from 'void (**)(void)' to 'void (* volatile*)(void)' must be 'const' qualified [-Wcast-qual]
  108 |   *(volatile typeof(*(p)) *)(p) = v; \
      |    ^
/home/patrick/src/motec/adr2/apex/sys/kern/syslog.c:276:2: note: in expansion of macro 'write_once'
  276 |  write_once(&log_output, fn);
      |  ^~~~~~~~~~
/home/patrick/src/motec/adr2/apex/sys/arch/arm/v7m/context.c: In function 'fpu_load':
/home/patrick/src/motec/adr2/apex/sys/arch/arm/v7m/context.c:329:12: warning: cast discards 'const' qualifier from pointer target type [-Wcast-qual]
  329 |   : : "m"(*(const uint32_t(*)[16])(f->regs + 16)), "r"(f->regs + 16));
      |            ^

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions