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:
Peter Barker 2019-10-28 16:24:06 +11:00 committed by Andrew Tridgell
parent f5635a557a
commit cbe73b91d5
2 changed files with 3 additions and 4 deletions

View File

@ -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) {

View File

@ -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;
}