From 8fe95dca816f52ddadf4fe78f5b7f52b6c4ffe76 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Thu, 23 Nov 2023 19:56:36 -0600 Subject: [PATCH] AP_HAL_Linux: introduce get_HAL_mutable() to complement get_HAL() Returns a mutable reference to the same HAL for certain purposes where the HAL needs to be mutated to avoid UB problems with casting away const and to make the fact that mutation is happening obvious. --- libraries/AP_HAL_Linux/HAL_Linux_Class.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp b/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp index ba68930e89..0fc691598b 100644 --- a/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp +++ b/libraries/AP_HAL_Linux/HAL_Linux_Class.cpp @@ -491,3 +491,8 @@ const AP_HAL::HAL &AP_HAL::get_HAL() { return hal_linux; } + +AP_HAL::HAL &AP_HAL::get_HAL_mutable() +{ + return hal_linux; +}