Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flac: foreign_metadata: fix -Walloc-size #654

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

thesamesam
Copy link
Contributor

GCC 14 introduces a new -Walloc-size included in -Wextra which gives:

src/flac/foreign_metadata.c:803:33: warning: allocation of insufficient size ‘1’ for type ‘foreign_metadata_t’ with size ‘64’ [-Walloc-size]

The calloc prototype is:

void *calloc(size_t nmemb, size_t size);

So, just swap the number of members and size arguments to match the prototype, as we're initialising 1 struct of size sizeof(foreign_metadata_t). GCC then sees we're not doing anything wrong.

GCC 14 introduces a new -Walloc-size included in -Wextra which gives:
```
src/flac/foreign_metadata.c:803:33: warning: allocation of insufficient size ‘1’ for type ‘foreign_metadata_t’ with size ‘64’ [-Walloc-size]
```

The calloc prototype is:
```
void *calloc(size_t nmemb, size_t size);
```

So, just swap the number of members and size arguments to match the prototype, as
we're initialising 1 struct of size `sizeof(foreign_metadata_t)`. GCC then sees we're not
doing anything wrong.

Signed-off-by: Sam James <sam@gentoo.org>
@ktmf01 ktmf01 merged commit e7d336c into xiph:master Mar 6, 2024
14 checks passed
@thesamesam thesamesam deleted the alloc-size branch March 6, 2024 11:56
@thesamesam
Copy link
Contributor Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants