Skip to content
This repository was archived by the owner on Feb 15, 2023. It is now read-only.
This repository was archived by the owner on Feb 15, 2023. It is now read-only.

gcc -Wall warnings #377

@alexcohn

Description

@alexcohn

When Android NDK compiles char_ref.c with -DNDEBUG -Wall, we see warnings:

char_ref.rl: In function 'consume_named_ref':
char_ref.rl:2498:12: warning: unused variable 'matched' [-Wunused-variable]
char_ref.rl:2512:12: warning: unused variable 'matched' [-Wunused-variable]

More warnings are triggered by -Wall -Wextra:

utf8.c:88:1: warning: 'static' is not at beginning of declaration [-Wold-style-declaration]
 uint32_t static inline decode(uint32_t* state, uint32_t* codep, uint32_t byte) {
 ^
utf8.c:88:1: warning: 'inline' is not at beginning of declaration [-Wold-style-declaration]

Another set of warnings (49) is triggered by -Wunused-variable, which is turned on by default with Clang -Wextra, e.g.:

error.c: In function 'find_next_newline':
error.c:150:17: warning: unused parameter 'original_text' [-Wunused-parameter]

Possible workarounds:

These unused-variable warnings could be addressed by #348, but the pull request has not been merged yet.

With GCC toolchain, I can hide all these warnings with LOCAL_CFLAGS=-Wno-unused-variable -Wno-unused-parameter -Wno-old-style-declaration for the gumbo-parser library, but not for Clang, which has been declared the only supported compiler in NDK 14.

The best fix for unused-variable and unused-parameter would be to add __attribute__ ((unused)) in relevant positions in source code.

Regarding utf8.c, the fix is simply to shuffle the keywords:

static inline uint32_t decode(uint32_t* state, uint32_t* codep, uint32_t byte) {

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