Skip to content

fix(esp_codec): calloc argument warning#65

Open
bryghtlabs-richard wants to merge 2 commits into
espressif:masterfrom
bryghtlabs-richard:fix/esp_codec_calloc_ordering
Open

fix(esp_codec): calloc argument warning#65
bryghtlabs-richard wants to merge 2 commits into
espressif:masterfrom
bryghtlabs-richard:fix/esp_codec_calloc_ordering

Conversation

@bryghtlabs-richard
Copy link
Copy Markdown

Description

Fix order of calloc arguments to address the following GCC warning:

esp_codec/audio_sonic.c:
warning: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
sonic->inbuf = (short *)calloc(sizeof(short), BUF_SIZE);

The code above is attempting to allocate a buffer of type short, with BUF_SIZE elements, but is actually asking calloc to allocate space for 2x adjacent BUF_SIZE buffers. Swap the order to address this. On ESP32, the allocated memory would be the same size anyhow.

Testing

Testing in progress. Should be a side-effect-free warning fix, but still working on getting initial examples to compile.


Checklist

Before submitting a Pull Request, please ensure the following:

  • 🚨 This PR does not introduce breaking changes.
  • All CI checks (GH Actions) pass.
  • Documentation is updated as needed.
  • Tests are updated or added as necessary.
  • Code is well-commented, especially in complex areas.
  • Git history is clean — commits are squashed to the minimum necessary.

Fix order of calloc arguments to address the following warning:

esp_codec/audio_sonic.c:
warning: 'calloc' sizes specified with 'sizeof' in the earlier
argument and not in the later argument [-Wcalloc-transposed-args]
  sonic->inbuf = (short *)calloc(sizeof(short), BUF_SIZE);
@bryghtlabs-richard bryghtlabs-richard marked this pull request as draft January 21, 2026 15:53
@bryghtlabs-richard bryghtlabs-richard marked this pull request as ready for review January 28, 2026 16:14
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.

1 participant