Skip to content

smatch does not support annotations #36

@marek22k

Description

@marek22k
[[gnu::nonnull(1, 2),
  gnu::null_terminated_string_arg(1),
  gnu::access(read_only, 1),
  gnu::access(read_write, 2)]] static inline void
    open_audio_file(const char filename[], AUDIOFILE * const af)
{
    ASSERT(filename != NULL);
    ASSERT(af != NULL);

    af->file = sf_open(filename, SFM_READ, &af->info);
    if (af->file == NULL)
    {
        fprintf(stderr, "Could not open file: %s\n", sf_strerror(af->file));
        exit(EXIT_FAILURE);
    }
}

results in

src/audio.h:20:2: error: Expected ] in abstract_array_declarator
src/audio.h:20:2: error: got [
src/audio.h:26:5: error: Trying to use reserved word 'else' as identifier
src/audio.h:26:5: error: Expected ; at end of declaration
src/audio.h:26:5: error: got __assert_fail
src/audio.h:26:5: error: Expected ; at the end of type declaration
src/audio.h:26:5: error: got }
src/audio.h:27:5: error: Expected ) in nested declarator
src/audio.h:27:5: error: got sizeof
src/audio.h:27:5: error: Trying to use reserved word 'void' as identifier
src/audio.h:27:5: error: Trying to use reserved word 'else' as identifier
src/audio.h:27:5: error: Expected ; at end of declaration
src/audio.h:27:5: error: got __assert_fail
src/audio.h:27:5: error: Expected ; at the end of type declaration
src/audio.h:27:5: error: got }
src/audio.h:29:7: error: Expected ; at end of declaration
src/audio.h:29:7: error: got ->
src/audio.h:30:11: error: Expected ) in function declarator
src/audio.h:30:11: error: got ->
src/audio.h:30:5: error: Trying to use reserved word 'if' as identifier
src/audio.h:33:14: error: Expected ) in function declarator
src/audio.h:33:14: error: got 1

source: https://codeberg.org/mark22k/resonancekey/src/commit/f499d04ba1b39a293a4b2bcc071c9b6e17d70ddbc7acd0c81819f5ab6a07dffe/src/audio.h#L20

It seems that smatch isn't recognizing annotations and is interpreting them as array declarations.

$ smatch --version
0.6.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions