Browse Source

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.
c415-sdk
Peter Barker 5 years ago committed by Andrew Tridgell
parent
commit
cbe73b91d5
  1. 3
      libraries/AP_HAL_Linux/SPIDevice.cpp
  2. 4
      libraries/AP_HAL_Linux/Storage.cpp

3
libraries/AP_HAL_Linux/SPIDevice.cpp

@ -205,13 +205,12 @@ void SPIBus::end_cb() @@ -205,13 +205,12 @@ void SPIBus::end_cb()
void SPIBus::open(uint16_t subdev)
{
char path[sizeof("/dev/spidevXXXXX.XXXXX")];
/* Already open by another device */
if (fd[subdev] >= 0) {
return;
}
char path[32];
snprintf(path, sizeof(path), "/dev/spidev%u.%u", bus, subdev);
fd[subdev] = ::open(path, O_RDWR | O_CLOEXEC);
if (fd[subdev] < 0) {

4
libraries/AP_HAL_Linux/Storage.cpp

@ -115,8 +115,8 @@ int Storage::_storage_create(const char *dpath) @@ -115,8 +115,8 @@ int Storage::_storage_create(const char *dpath)
// take up all needed space
if (ftruncate(fd, sizeof(_buffer)) == -1) {
fprintf(stderr, "Failed to set file size to %lu kB (%m)\n",
sizeof(_buffer) / 1024);
fprintf(stderr, "Failed to set file size to %u kB (%m)\n",
unsigned(sizeof(_buffer) / 1024));
goto fail;
}

Loading…
Cancel
Save