royzah opened a new pull request, #20199:
URL: https://github.com/apache/nuttx/pull/20199
## Summary
GCC 15 added `-Wunterminated-string-initialization`. Both ChaCha constants
fill their array exactly, leaving no room for the terminator, so the warning
fires and `crypto/Makefile` turns it into an error:
```
chacha_private.h:61:31: error: initializer-string for array of 'char'
truncates
NUL terminator but destination lacks 'nonstring' attribute (17 chars into 16
available) [-Werror=unterminated-string-initialization]
61 | static const char sigma[16] = "expand 32-byte k";
```
Any build of https://github.com/apache/nuttx/blob/master/crypto/chachapoly.c
with that compiler stops there.
## Change
Neither constant is used as a string. Both are read as sixteen bytes through
`U8TO32_LITTLE()`, and `hchacha20()` and `chacha_keysetup()` never look past
index 15. Letting the array size follow the literal keeps them readable, costs
one byte each, and needs no attribute that only some compilers have.
`__attribute__((nonstring))` would be the narrower fix, but
https://github.com/apache/nuttx/blob/master/include/nuttx/compiler.h has no
macro for it and adding one across every compiler block is a larger change than
this warrants. Happy to go that way instead if preferred.
## Testing
Before and after, same file, GCC 15.3.0 for `aarch64-none-elf`:
```
before: 2 diagnostics
after: 0 diagnostics
```
`chacha_keysetup()` then `chacha_ivsetup()` produce a byte-identical
`input[16]` at both 256 and 128 bits:
```
617078653320646e79622d326b20657403020100... (256-bit, before and after)
617078653120646e79622d366b20657403020100... (128-bit, before and after)
```
`tools/nxstyle` clean.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]