AP_BattMonitor: use NEW_NOTHROW for new(std::nothrow)

This commit is contained in:
Andrew Tridgell 2024-05-27 11:24:09 +10:00
parent 72dc87e5c1
commit 4879cc24e6
2 changed files with 26 additions and 26 deletions

View File

@ -484,123 +484,123 @@ AP_BattMonitor::init()
#if AP_BATTERY_ANALOG_ENABLED
case Type::ANALOG_VOLTAGE_ONLY:
case Type::ANALOG_VOLTAGE_AND_CURRENT:
drivers[instance] = new AP_BattMonitor_Analog(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_Analog(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_SMBUS_SOLO_ENABLED
case Type::SOLO:
drivers[instance] = new AP_BattMonitor_SMBus_Solo(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_SMBus_Solo(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_SMBUS_GENERIC_ENABLED
case Type::SMBus_Generic:
drivers[instance] = new AP_BattMonitor_SMBus_Generic(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_SMBus_Generic(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_SMBUS_SUI_ENABLED
case Type::SUI3:
drivers[instance] = new AP_BattMonitor_SMBus_SUI(*this, state[instance], _params[instance], 3);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_SMBus_SUI(*this, state[instance], _params[instance], 3);
break;
case Type::SUI6:
drivers[instance] = new AP_BattMonitor_SMBus_SUI(*this, state[instance], _params[instance], 6);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_SMBus_SUI(*this, state[instance], _params[instance], 6);
break;
#endif
#if AP_BATTERY_SMBUS_MAXELL_ENABLED
case Type::MAXELL:
drivers[instance] = new AP_BattMonitor_SMBus_Maxell(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_SMBus_Maxell(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_SMBUS_ROTOYE_ENABLED
case Type::Rotoye:
drivers[instance] = new AP_BattMonitor_SMBus_Rotoye(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_SMBus_Rotoye(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_SMBUS_NEODESIGN_ENABLED
case Type::NeoDesign:
drivers[instance] = new AP_BattMonitor_SMBus_NeoDesign(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_SMBus_NeoDesign(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_BEBOP_ENABLED
case Type::BEBOP:
drivers[instance] = new AP_BattMonitor_Bebop(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_Bebop(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_UAVCAN_BATTERYINFO_ENABLED
case Type::UAVCAN_BatteryInfo:
drivers[instance] = new AP_BattMonitor_DroneCAN(*this, state[instance], AP_BattMonitor_DroneCAN::UAVCAN_BATTERY_INFO, _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_DroneCAN(*this, state[instance], AP_BattMonitor_DroneCAN::UAVCAN_BATTERY_INFO, _params[instance]);
break;
#endif
#if AP_BATTERY_ESC_ENABLED
case Type::BLHeliESC:
drivers[instance] = new AP_BattMonitor_ESC(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_ESC(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_SUM_ENABLED
case Type::Sum:
drivers[instance] = new AP_BattMonitor_Sum(*this, state[instance], _params[instance], instance);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_Sum(*this, state[instance], _params[instance], instance);
break;
#endif
#if AP_BATTERY_FUELFLOW_ENABLED
case Type::FuelFlow:
drivers[instance] = new AP_BattMonitor_FuelFlow(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_FuelFlow(*this, state[instance], _params[instance]);
break;
#endif // AP_BATTERY_FUELFLOW_ENABLED
#if AP_BATTERY_FUELLEVEL_PWM_ENABLED
case Type::FuelLevel_PWM:
drivers[instance] = new AP_BattMonitor_FuelLevel_PWM(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_FuelLevel_PWM(*this, state[instance], _params[instance]);
break;
#endif // AP_BATTERY_FUELLEVEL_PWM_ENABLED
#if AP_BATTERY_FUELLEVEL_ANALOG_ENABLED
case Type::FuelLevel_Analog:
drivers[instance] = new AP_BattMonitor_FuelLevel_Analog(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_FuelLevel_Analog(*this, state[instance], _params[instance]);
break;
#endif // AP_BATTERY_FUELLEVEL_ANALOG_ENABLED
#if HAL_GENERATOR_ENABLED
case Type::GENERATOR_ELEC:
drivers[instance] = new AP_BattMonitor_Generator_Elec(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_Generator_Elec(*this, state[instance], _params[instance]);
break;
case Type::GENERATOR_FUEL:
drivers[instance] = new AP_BattMonitor_Generator_FuelLevel(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_Generator_FuelLevel(*this, state[instance], _params[instance]);
break;
#endif // HAL_GENERATOR_ENABLED
#if AP_BATTERY_INA2XX_ENABLED
case Type::INA2XX:
drivers[instance] = new AP_BattMonitor_INA2XX(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_INA2XX(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_LTC2946_ENABLED
case Type::LTC2946:
drivers[instance] = new AP_BattMonitor_LTC2946(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_LTC2946(*this, state[instance], _params[instance]);
break;
#endif
#if HAL_TORQEEDO_ENABLED
case Type::Torqeedo:
drivers[instance] = new AP_BattMonitor_Torqeedo(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_Torqeedo(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_SYNTHETIC_CURRENT_ENABLED
case Type::Analog_Volt_Synthetic_Current:
drivers[instance] = new AP_BattMonitor_Synthetic_Current(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_Synthetic_Current(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_INA239_ENABLED
case Type::INA239_SPI:
drivers[instance] = new AP_BattMonitor_INA239(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_INA239(*this, state[instance], _params[instance]);
break;
#endif
#if AP_BATTERY_EFI_ENABLED
case Type::EFI:
drivers[instance] = new AP_BattMonitor_EFI(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_EFI(*this, state[instance], _params[instance]);
break;
#endif // AP_BATTERY_EFI_ENABLED
#if AP_BATTERY_AD7091R5_ENABLED
case Type::AD7091R5:
drivers[instance] = new AP_BattMonitor_AD7091R5(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_AD7091R5(*this, state[instance], _params[instance]);
break;
#endif// AP_BATTERY_AD7091R5_ENABLED
#if AP_BATTERY_SCRIPTING_ENABLED
case Type::Scripting:
drivers[instance] = new AP_BattMonitor_Scripting(*this, state[instance], _params[instance]);
drivers[instance] = NEW_NOTHROW AP_BattMonitor_Scripting(*this, state[instance], _params[instance]);
break;
#endif // AP_BATTERY_SCRIPTING_ENABLED
case Type::NONE:

View File

@ -405,7 +405,7 @@ void AP_BattMonitor_DroneCAN::mppt_set_powered_state(bool power_on)
request.disable = !request.enable;
if (mppt_outputenable_client == nullptr) {
mppt_outputenable_client = new Canard::Client<mppt_OutputEnableResponse>{_ap_dronecan->get_canard_iface(), mppt_outputenable_res_cb};
mppt_outputenable_client = NEW_NOTHROW Canard::Client<mppt_OutputEnableResponse>{_ap_dronecan->get_canard_iface(), mppt_outputenable_res_cb};
if (mppt_outputenable_client == nullptr) {
return;
}