Fix error: '%s' directive output may be truncated#8658
Conversation
|
Are there any limitations for |
gpio_pin_register defines a local char array with 32bytes and forward this array to gpio_pin_register_byname, so compiler assume that pinname may have 32bytes long in extreme case. |
pkarashchenko
left a comment
There was a problem hiding this comment.
Seems like an increase to 40 should be enough, but we can go with 64 bytes as well
|
The only bad thing about increasing the sizes of stacked strings is that eventually we have to increase task stack sizes too, or we will face stack overflows. I don't know what to suggest, though. Heap allocation will introduce overhead and could contribute to memory fragmentation on systems with tiny memory resources. A static global scratch space is not re-entrant. Ever-growing stack footprints cause a cascade effect where we have to grow the stack sizes of our threads. |
|
Yes. Maybe we can decrease buffer size in |
Right. How many GPIO pins could we possibly have? If the MCU is a 212-pin BGA you'll have 3 digits; that will support up to 999 GPIO pins. We could splurge and say 4 digits ("gpioXXXX"), allowing for some obscenely large SoCs. With trailing NUL this is 9 chars, and "/dev/gpioXXXX" with trailing NUL is total of 14 characters. We can round up to 16. This solves problem and reduces stack usage instead of increasing it. |
writing up to 31 bytes into a region of size 27 [-Werror=format-truncation=] Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
|
Done. |
davids5
left a comment
There was a problem hiding this comment.
The Logic is sound. 999 gpios on the soc, 999 gpios, take one down....
Summary
writing up to 31 bytes into a region of size 27 [-Werror=format-truncation=]
Impact
gpio driver
Testing
CI