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 #if AP_BATTERY_ANALOG_ENABLED
case Type::ANALOG_VOLTAGE_ONLY: case Type::ANALOG_VOLTAGE_ONLY:
case Type::ANALOG_VOLTAGE_AND_CURRENT: 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; break;
#endif #endif
#if AP_BATTERY_SMBUS_SOLO_ENABLED #if AP_BATTERY_SMBUS_SOLO_ENABLED
case Type::SOLO: 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; break;
#endif #endif
#if AP_BATTERY_SMBUS_GENERIC_ENABLED #if AP_BATTERY_SMBUS_GENERIC_ENABLED
case Type::SMBus_Generic: 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; break;
#endif #endif
#if AP_BATTERY_SMBUS_SUI_ENABLED #if AP_BATTERY_SMBUS_SUI_ENABLED
case Type::SUI3: 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; break;
case Type::SUI6: 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; break;
#endif #endif
#if AP_BATTERY_SMBUS_MAXELL_ENABLED #if AP_BATTERY_SMBUS_MAXELL_ENABLED
case Type::MAXELL: 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; break;
#endif #endif
#if AP_BATTERY_SMBUS_ROTOYE_ENABLED #if AP_BATTERY_SMBUS_ROTOYE_ENABLED
case Type::Rotoye: 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; break;
#endif #endif
#if AP_BATTERY_SMBUS_NEODESIGN_ENABLED #if AP_BATTERY_SMBUS_NEODESIGN_ENABLED
case Type::NeoDesign: 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; break;
#endif #endif
#if AP_BATTERY_BEBOP_ENABLED #if AP_BATTERY_BEBOP_ENABLED
case Type::BEBOP: 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; break;
#endif #endif
#if AP_BATTERY_UAVCAN_BATTERYINFO_ENABLED #if AP_BATTERY_UAVCAN_BATTERYINFO_ENABLED
case Type::UAVCAN_BatteryInfo: 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; break;
#endif #endif
#if AP_BATTERY_ESC_ENABLED #if AP_BATTERY_ESC_ENABLED
case Type::BLHeliESC: 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; break;
#endif #endif
#if AP_BATTERY_SUM_ENABLED #if AP_BATTERY_SUM_ENABLED
case Type::Sum: 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; break;
#endif #endif
#if AP_BATTERY_FUELFLOW_ENABLED #if AP_BATTERY_FUELFLOW_ENABLED
case Type::FuelFlow: 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; break;
#endif // AP_BATTERY_FUELFLOW_ENABLED #endif // AP_BATTERY_FUELFLOW_ENABLED
#if AP_BATTERY_FUELLEVEL_PWM_ENABLED #if AP_BATTERY_FUELLEVEL_PWM_ENABLED
case Type::FuelLevel_PWM: 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; break;
#endif // AP_BATTERY_FUELLEVEL_PWM_ENABLED #endif // AP_BATTERY_FUELLEVEL_PWM_ENABLED
#if AP_BATTERY_FUELLEVEL_ANALOG_ENABLED #if AP_BATTERY_FUELLEVEL_ANALOG_ENABLED
case Type::FuelLevel_Analog: 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; break;
#endif // AP_BATTERY_FUELLEVEL_ANALOG_ENABLED #endif // AP_BATTERY_FUELLEVEL_ANALOG_ENABLED
#if HAL_GENERATOR_ENABLED #if HAL_GENERATOR_ENABLED
case Type::GENERATOR_ELEC: 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; break;
case Type::GENERATOR_FUEL: 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; break;
#endif // HAL_GENERATOR_ENABLED #endif // HAL_GENERATOR_ENABLED
#if AP_BATTERY_INA2XX_ENABLED #if AP_BATTERY_INA2XX_ENABLED
case Type::INA2XX: 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; break;
#endif #endif
#if AP_BATTERY_LTC2946_ENABLED #if AP_BATTERY_LTC2946_ENABLED
case Type::LTC2946: 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; break;
#endif #endif
#if HAL_TORQEEDO_ENABLED #if HAL_TORQEEDO_ENABLED
case Type::Torqeedo: 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; break;
#endif #endif
#if AP_BATTERY_SYNTHETIC_CURRENT_ENABLED #if AP_BATTERY_SYNTHETIC_CURRENT_ENABLED
case Type::Analog_Volt_Synthetic_Current: 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; break;
#endif #endif
#if AP_BATTERY_INA239_ENABLED #if AP_BATTERY_INA239_ENABLED
case Type::INA239_SPI: 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; break;
#endif #endif
#if AP_BATTERY_EFI_ENABLED #if AP_BATTERY_EFI_ENABLED
case Type::EFI: 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; break;
#endif // AP_BATTERY_EFI_ENABLED #endif // AP_BATTERY_EFI_ENABLED
#if AP_BATTERY_AD7091R5_ENABLED #if AP_BATTERY_AD7091R5_ENABLED
case Type::AD7091R5: 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; break;
#endif// AP_BATTERY_AD7091R5_ENABLED #endif// AP_BATTERY_AD7091R5_ENABLED
#if AP_BATTERY_SCRIPTING_ENABLED #if AP_BATTERY_SCRIPTING_ENABLED
case Type::Scripting: 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; break;
#endif // AP_BATTERY_SCRIPTING_ENABLED #endif // AP_BATTERY_SCRIPTING_ENABLED
case Type::NONE: case Type::NONE:

View File

@ -405,7 +405,7 @@ void AP_BattMonitor_DroneCAN::mppt_set_powered_state(bool power_on)
request.disable = !request.enable; request.disable = !request.enable;
if (mppt_outputenable_client == nullptr) { 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) { if (mppt_outputenable_client == nullptr) {
return; return;
} }