mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-05 07:28:29 -04:00
AP_HAL_Linux: correct format-string warnings
Using the string template to determine the size of the array to print into strikes issues as varargs passes the stack variables as integer types, so the perceived range is larger.
This commit is contained in:
parent
f5635a557a
commit
cbe73b91d5
@ -205,13 +205,12 @@ void SPIBus::end_cb()
|
|||||||
|
|
||||||
void SPIBus::open(uint16_t subdev)
|
void SPIBus::open(uint16_t subdev)
|
||||||
{
|
{
|
||||||
char path[sizeof("/dev/spidevXXXXX.XXXXX")];
|
|
||||||
|
|
||||||
/* Already open by another device */
|
/* Already open by another device */
|
||||||
if (fd[subdev] >= 0) {
|
if (fd[subdev] >= 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char path[32];
|
||||||
snprintf(path, sizeof(path), "/dev/spidev%u.%u", bus, subdev);
|
snprintf(path, sizeof(path), "/dev/spidev%u.%u", bus, subdev);
|
||||||
fd[subdev] = ::open(path, O_RDWR | O_CLOEXEC);
|
fd[subdev] = ::open(path, O_RDWR | O_CLOEXEC);
|
||||||
if (fd[subdev] < 0) {
|
if (fd[subdev] < 0) {
|
||||||
|
@ -115,8 +115,8 @@ int Storage::_storage_create(const char *dpath)
|
|||||||
|
|
||||||
// take up all needed space
|
// take up all needed space
|
||||||
if (ftruncate(fd, sizeof(_buffer)) == -1) {
|
if (ftruncate(fd, sizeof(_buffer)) == -1) {
|
||||||
fprintf(stderr, "Failed to set file size to %lu kB (%m)\n",
|
fprintf(stderr, "Failed to set file size to %u kB (%m)\n",
|
||||||
sizeof(_buffer) / 1024);
|
unsigned(sizeof(_buffer) / 1024));
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user