Skip to content

Commit

Permalink
AP_InertialSensor: Specify the number of arrays by sizeof
Browse files Browse the repository at this point in the history
  • Loading branch information
muramura committed Jan 3, 2024
1 parent 68d8a26 commit 9b50f26
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions libraries/AP_InertialSensor/AP_InertialSensor_SITL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void AP_InertialSensor_SITL::read_gyro_from_file()
{
if (gyro_fd == -1) {
char namebuf[32];
snprintf(namebuf, 32, "/tmp/gyro%d.dat", gyro_instance);
snprintf(namebuf, sizeof(namebuf), "/tmp/gyro%d.dat", gyro_instance);
gyro_fd = AP::FS().open(namebuf, O_RDONLY);
if (gyro_fd == -1) {
AP_HAL::panic("gyro data file %s not found", namebuf);
Expand Down Expand Up @@ -462,7 +462,7 @@ void AP_InertialSensor_SITL::write_gyro_to_file(const Vector3f& gyro)
{
if (gyro_fd == -1) {
char namebuf[32];
snprintf(namebuf, 32, "/tmp/gyro%d.dat", gyro_instance);
snprintf(namebuf, sizeof(namebuf), "/tmp/gyro%d.dat", gyro_instance);
gyro_fd = open(namebuf, O_WRONLY|O_TRUNC|O_CREAT, S_IRWXU|S_IRGRP|S_IROTH);
}

Expand All @@ -477,7 +477,7 @@ void AP_InertialSensor_SITL::read_accel_from_file()
{
if (accel_fd == -1) {
char namebuf[32];
snprintf(namebuf, 32, "/tmp/accel%d.dat", accel_instance);
snprintf(namebuf, sizeof(namebuf), "/tmp/accel%d.dat", accel_instance);
accel_fd = open(namebuf, O_RDONLY|O_CLOEXEC);
if (accel_fd == -1) {
AP_HAL::panic("accel data file %s not found", namebuf);
Expand Down Expand Up @@ -534,7 +534,7 @@ void AP_InertialSensor_SITL::write_accel_to_file(const Vector3f& accel)

if (accel_fd == -1) {
char namebuf[32];
snprintf(namebuf, 32, "/tmp/accel%d.dat", accel_instance);
snprintf(namebuf, sizeof(namebuf), "/tmp/accel%d.dat", accel_instance);
accel_fd = open(namebuf, O_WRONLY|O_TRUNC|O_CREAT, S_IRWXU|S_IRGRP|S_IROTH);
}

Expand Down

0 comments on commit 9b50f26

Please sign in to comment.