Skip to content

Commit

Permalink
config.mak.dev: enable -Wwrite-strings warning
Browse files Browse the repository at this point in the history
Writing to string constants is undefined behaviour and must be avoided
in C. Even so, the compiler does not help us with this by default
because those constants are not in fact marked as `const`. This makes it
rather easy to accidentally assign a constant to a non-const variable or
field and then later on try to either free it or write to it.

Enable `-Wwrite-strings` to catch such mistakes. With this warning
enabled, the type of string constants is changed to `const char[]` and
will thus cause compiler warnings when being assigned to non-const
fields and variables.

Signed-off-by: Patrick Steinhardt <[email protected]>
  • Loading branch information
pks-t committed May 29, 2024
1 parent a0cbfe7 commit 366f6e0
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions config.mak.dev
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ DEVELOPER_CFLAGS += -Wpointer-arith
DEVELOPER_CFLAGS += -Wstrict-prototypes
DEVELOPER_CFLAGS += -Wunused
DEVELOPER_CFLAGS += -Wvla
DEVELOPER_CFLAGS += -Wwrite-strings
DEVELOPER_CFLAGS += -fno-common

ifneq ($(filter clang4,$(COMPILER_FEATURES)),)
Expand Down

0 comments on commit 366f6e0

Please sign in to comment.