Commit Graph

66575 Commits

Author SHA1 Message Date
Peter Barker
4e35eb3673 SITL: fix array-bounds warning in tsys01 sim
... if the driver ever asked for prom0 then we would do Very Bad Things here.

File:	build/sitl/../../libraries/SITL/SIM_Temperature_TSYS01.cpp
Warning:	line 38, column 13
Assigned value is garbage or undefined
2025-02-01 16:52:26 +11:00
Thomas Watson
63afcae8a7 AP_Filesystem: ROMFS: fix open race conditions
Lua opens scripts to load them into memory, then the logger opens them
after to stream them into the dataflash log. When loading multiple large
Lua scripts from ROMFS, decompression takes a significant amount of
time. This creates the opportunity for the Lua interpreter and logging
threads to both be inside `AP_Filesystem_ROMFS::open()` decompressing a
file.

If this happens, the function can return the same `fd` for two different
calls as the `fd` is chosen before decompression starts, but only marked
as being used after that finishes. The read pointers then stomp on each
other, so Lua loads garbled scripts (usually resulting in a syntax
error) and the logger dumps garbled data.

Fix the issue by locking before searching for a free record (or marking
a record as free). Apply the same fix to directories as well. This
doesn't protect against using the same `fd`/`dirp` from multiple
threads, but that behavior is to be discouraged anyway and is not the
root cause here.
2025-02-01 16:51:49 +11:00
Peter Barker
6bf29eca70 AP_AIS: remove incorrect use of strncat
the third argument is space remaining in buffer, not size of buffer...

../../libraries/AP_AIS/AP_AIS.cpp:183:71: warning: Potential buffer overflow. Replace with 'sizeof(multi) - strlen(multi) - 1' or use a safer 'strlcat' API [unix.cstring.BadSizeArg]
                    strncat(multi,_AIVDM_buffer[msg_parts[i]].payload,sizeof(multi));
                                                                      ^~~~~~~~~~~~~
../../libraries/AP_AIS/AP_AIS.cpp:185:49: warning: Potential buffer overflow. Replace with 'sizeof(multi) - strlen(multi) - 1' or use a safer 'strlcat' API [unix.cstring.BadSizeArg]
                strncat(multi,_incoming.payload,sizeof(multi));
2025-01-31 15:52:50 +11:00
Peter Barker
c3f2b4013f Copter: free allocations in case of allocation failure
these would be leaked if the "new" call for the ModeGuidedCustom object failed.

Since resgister_custom_mode may be called multiple times we could leak memory continuously
2025-01-31 08:53:20 +09:00
Peter Barker
2ef98e18ce Tools: size_compare_branches.py: mark navigator64 as a Linux board
... so we don't try to buld bootloaders for it
2025-01-31 09:20:03 +11:00
Peter Barker
46973652d4 AP_HAL_ESP32: add get_device_ptr to HAL I2CDevice API 2025-01-31 09:19:33 +11:00
Peter Barker
d5922b2cf1 AP_Notify: avoid use of OwnPtr for ToshibaLED 2025-01-31 09:19:33 +11:00
Peter Barker
51d1cee5eb AP_HAL_SITL: add get_device_ptr to HAL I2CDevice API 2025-01-31 09:19:33 +11:00
Peter Barker
049ad3928d AP_HAL_QURT: add get_device_ptr to HAL I2CDevice API 2025-01-31 09:19:33 +11:00
Peter Barker
07d5938d68 AP_HAL_Linux: add get_device_ptr to HAL I2CDevice API 2025-01-31 09:19:33 +11:00
Peter Barker
0a617b500b AP_HAL: add get_device_ptr to HAL I2CDevice API 2025-01-31 09:19:33 +11:00
Peter Barker
45db7d2231 AP_HAL_Empty: add get_device_ptr to HAL I2CDevice API 2025-01-31 09:19:33 +11:00
Peter Barker
97e87dfcdb AP_HAL_ChibiOS: add get_device_ptr to HAL I2CDevice API 2025-01-31 09:19:33 +11:00
Peter Barker
061f3825a7 AP_Logger: use GCS_SEND_TEXT for error message rather than stdout
This one is line noise before this patch:
Failed to create log directory /APM/LOGS : ENOSPC
2025-01-31 08:32:29 +11:00
Shiv Tyagi
dba4136f95 Tools: create and use AP_PERIPH_BARO_ENABLED 2025-01-31 08:25:28 +11:00
Shiv Tyagi
4fca0ccd0b AP_Scripting: use AP_PERIPH_BARO_ENABLED in place of HAL_PERIPH_ENABLE_BRO 2025-01-31 08:25:28 +11:00
Shiv Tyagi
c4654c9828 AP_HAL_ChibiOS: use AP_PERIPH_BARO_ENABLED in place of HAL_PERIPH_ENABLE_BRO 2025-01-31 08:25:28 +11:00
Shiv Tyagi
c7217528b1 AP_HAL_ChibiOS: fix incorrect definition of AP_PERIPH_MAG_ENABLED for Here4AP 2025-01-31 08:24:50 +11:00
rubenp02
d529601af6 AP_L1_Control: Fix NAVL1_PERIOD description typo 2025-01-30 20:53:17 +11:00
rubenp02
5c1b768738 AP_L1_Control: Improve comment format consistency 2025-01-30 20:53:17 +11:00
Peter Barker
a829cd3e60 AP_Logger: log IOMCU cpu id and mcu id
Co-authored-by: Michelle Rossouw <michelleros128@gmail.com>
2025-01-30 08:52:49 +11:00
Shiv Tyagi
d96439dbc5 AP_HAL_ChibiOS: use AP_PERIPH_MAG_ENABLED in place of HAL_PERIPH_ENABLE_MAG 2025-01-30 08:49:03 +11:00
Shiv Tyagi
1060d6703b Tools: create and use AP_PERIPH_MAG_ENABLED 2025-01-30 08:49:03 +11:00
Peter Barker
f18c458b39 Tools: create_OEM_board.py: correct help string 2025-01-30 08:48:19 +11:00
Peter Barker
fe9fc8817b autotest: correct python used for clang-scan-build 2025-01-30 08:48:19 +11:00
Peter Barker
99aff5f0cf SITL: remove variable dead stores 2025-01-30 08:47:34 +11:00
Peter Barker
f9d970c474 AP_ADC: remove variable dead stores 2025-01-30 08:47:34 +11:00
Peter Barker
a01b7e74f1 SITL: remove dead stores from rangefinder_range
roll and pitch are unused if !SITL_RANGEFINDER_AS_OBJECT_SENSOR

../../libraries/SITL/SIM_Aircraft.cpp:546:13: warning: Value stored to 'roll' is never read [deadcode.DeadStores]
            roll = 0;
            ^      ~
../../libraries/SITL/SIM_Aircraft.cpp:551:13: warning: Value stored to 'roll' is never read [deadcode.DeadStores]
            roll = 0;
            ^      ~
../../libraries/SITL/SIM_Aircraft.cpp:557:13: warning: Value stored to 'pitch' is never read [deadcode.DeadStores]
            pitch = 0;
            ^       ~
../../libraries/SITL/SIM_Aircraft.cpp:562:13: warning: Value stored to 'pitch' is never read [deadcode.DeadStores]
            pitch = 0;
2025-01-30 08:24:27 +11:00
Peter Barker
9bfba32803 GCS_MAVLink: correct resetting of parity after passthhru is done
this might have worked if parity1 and parity2 were static values - but theyr're not.  I'm guessing the code evolved
2025-01-29 21:45:37 +11:00
Peter Barker
0a5d450c44 AP_Frsky_Telem: remove dead variable write
this is falsified at the top of the function

../../libraries/AP_Frsky_Telem/AP_Frsky_SPort_Passthrough.cpp:238:13: warning: Value stored to 'packet_ready' is never read [deadcode.DeadStores]
            packet_ready = false;
            ^              ~~~~~
1 warning generated.
2025-01-29 21:41:51 +11:00
Peter Barker
4ecfacbbd0 Blimp: make compass LearnType enum-class and parameter AP_Enum 2025-01-29 19:21:59 +11:00
Peter Barker
12ca8ec473 ArduSub: make compass LearnType enum-class and parameter AP_Enum 2025-01-29 19:21:59 +11:00
Peter Barker
d2c24efd83 ArduCopter: make compass LearnType enum-class and parameter AP_Enum 2025-01-29 19:21:59 +11:00
Peter Barker
6cd862709b RC_Channel: make compass LearnType enum-class and parameter AP_Enum 2025-01-29 19:21:59 +11:00
Peter Barker
6298f7dc58 AP_Compass: make compass LearnType enum-class and parameter AP_Enum 2025-01-29 19:21:59 +11:00
Peter Barker
a2322abe02 AP_Periph: adjust for new type-safety for AP_Enum 2025-01-29 19:21:59 +11:00
Peter Barker
870b626f0e SRV_Channel: remove buggy, unused method
... this may not fit in an int8_t!
2025-01-29 19:21:59 +11:00
Peter Barker
c7b0ba04ef AP_Relay: adjust for new type-safety for AP_Enum 2025-01-29 19:21:59 +11:00
Peter Barker
9255054826 AP_Param: add a set_and_save method to AP_Enum
... and AP_Enum16

to allow for better type-safety in users
2025-01-29 19:21:59 +11:00
Peter Barker
13980eb518 AP_HAL_ChibiOS: chibios_hwdef.py tidy embedding of files into ROMFS 2025-01-29 19:06:11 +11:00
Peter Barker
8425bf46dd Copter: remove unused hgt_variance_filt
this filter is populated but never checked when checking variances
2025-01-29 18:52:35 +11:00
Andy Piper
29655d149c AP_InertialSensor: remove changes to primary accel since it is always the same as the gyro 2025-01-29 18:47:51 +11:00
Andy Piper
9da365398a AP_AHRS: remove changes to primary accel since it is always the same as the gyro 2025-01-29 18:47:51 +11:00
Andy Piper
a5d04eb291 AP_InertialSensor: only update the primary once. scale FIFO reads to 2x loop rate.
only increase FIFO buffer when compiled with fast rate
2025-01-29 18:47:51 +11:00
Andy Piper
da447fd378 AP_InertialSensor: remove rate config include 2025-01-29 18:47:51 +11:00
Andy Piper
51a61b99ea AP_InertialSensor: remove dynamic fifo mask 2025-01-29 18:47:51 +11:00
Andy Piper
32632a06a8 AP_InertialSensor: have a single callback for primary switching 2025-01-29 18:47:51 +11:00
Andy Piper
45242de521 AP_InertialSensor: periodically notify of primary gyro and accels 2025-01-29 18:47:51 +11:00
Andy Piper
981826dca3 AP_InertialSensor: only use dynamic FIFO when using fast rate loop 2025-01-29 18:47:51 +11:00
Andy Piper
6eda43f9f4 AP_AHRS: configure primary gyro/accel in IMU when it changes 2025-01-29 18:47:51 +11:00