You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "fjpanag (via GitHub)" <gi...@apache.org> on 2023/05/11 10:48:05 UTC
[GitHub] [nuttx] fjpanag opened a new pull request, #9251: rtc: Fix compiler warning in driver initialization.
fjpanag opened a new pull request, #9251:
URL: https://github.com/apache/nuttx/pull/9251
## Summary
The RTC driver causes the following warning:
```
timers/rtc.c: In function ‘rtc_initialize’:
timers/rtc.c:851:34: warning: ‘%d’ directive output may be truncated writing between 1 and 11 bytes into a region of size 8 [-Wformat-truncation=]
851 | snprintf(devpath, 16, "/dev/rtc%d", minor);
| ^~
timers/rtc.c:851:25: note: directive argument in the range [-2147483648, 999]
851 | snprintf(devpath, 16, "/dev/rtc%d", minor);
| ^~~~~~~~~~~~
timers/rtc.c:851:3: note: ‘snprintf’ output between 10 and 20 bytes into a destination of size 16
851 | snprintf(devpath, 16, "/dev/rtc%d", minor);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
This PR fixes this warning.
The `devpath` is slightly enlarged, to ensure that all possible numbers can be reliably printed.
## Impact
Practically none.
The buffer is enlarged by just 4 bytes, but it is also located in the stack. So it shouldn't have any actual impact on any practical application.
## Testing
Build test only.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] acassis commented on a diff in pull request #9251: rtc: Fix compiler warning in driver initialization.
Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #9251:
URL: https://github.com/apache/nuttx/pull/9251#discussion_r1191252240
##########
drivers/timers/rtc.c:
##########
@@ -844,11 +844,11 @@ int rtc_initialize(int minor, FAR struct rtc_lowerhalf_s *lower)
upper->unlinked = false; /* Driver is not unlinked */
#endif
- /* Create the driver name. There is space for the a minor number up to 6
+ /* Create the driver name. There is space for the a minor number up to 10
* characters
*/
- snprintf(devpath, 16, "/dev/rtc%d", minor);
+ snprintf(devpath, 20, "/dev/rtc%d", minor);
Review Comment:
Please use `sizeof(devpath)` instead of hard-code value 20
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] pkarashchenko merged pull request #9251: rtc: Fix compiler warning in driver initialization.
Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko merged PR #9251:
URL: https://github.com/apache/nuttx/pull/9251
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nuttx] fjpanag commented on a diff in pull request #9251: rtc: Fix compiler warning in driver initialization.
Posted by "fjpanag (via GitHub)" <gi...@apache.org>.
fjpanag commented on code in PR #9251:
URL: https://github.com/apache/nuttx/pull/9251#discussion_r1191386462
##########
drivers/timers/rtc.c:
##########
@@ -844,11 +844,11 @@ int rtc_initialize(int minor, FAR struct rtc_lowerhalf_s *lower)
upper->unlinked = false; /* Driver is not unlinked */
#endif
- /* Create the driver name. There is space for the a minor number up to 6
+ /* Create the driver name. There is space for the a minor number up to 10
* characters
*/
- snprintf(devpath, 16, "/dev/rtc%d", minor);
+ snprintf(devpath, 20, "/dev/rtc%d", minor);
Review Comment:
Done.
--
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: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org