New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global: resolve gcs::send_text compiler warnings in 7 libraries #11891
Global: resolve gcs::send_text compiler warnings in 7 libraries #11891
Conversation
c8c61b8
to
3be22b0
Compare
3be22b0
to
7efa69a
Compare
I think that using static_cast can prevent missing values rather than "forced cast". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've noted one case that should be %u not %d. Same for some of the others
The official iaoc value in it's proper application of adsb is an unsigned 24bit hex. However, uavionix and other systems have sneakily used the upper 8bits for other data so it is used as a 32 bit. Sign is basically ignored. It's only stored as signed because we can't save to epprom as unsigned. I don't know of any system that uses it as signed. |
Merged, thanks! |
This PR resolves some slightly distracting compiler warnings. The warnings that appeared for each are written below. I've tested that post these changes the warnings do not appear.
AP_ADSB
../../libraries/AP_ADSB/AP_ADSB.cpp: In member function 'void AP_ADSB::update()':
../../libraries/AP_ADSB/AP_ADSB.cpp:279:131: warning: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t {aka long int}' [-Wformat=]
gcs().send_text(MAV_SEVERITY_INFO, "ADSB: Using ICAO_id %d and Callsign %s", out_state.cfg.ICAO_id, out_state.cfg.callsign);
^
../../libraries/AP_ADSB/AP_ADSB.cpp: In member function 'void AP_ADSB::handle_out_cfg(const mavlink_message_t&)':
../../libraries/AP_ADSB/AP_ADSB.cpp:717:127: warning: format '%d' expects argument of type 'int', but argument 4 has type 'int32_t {aka long int}' [-Wformat=]
gcs().send_text(MAV_SEVERITY_INFO, "ADSB: Using ICAO_id %d and Callsign %s", out_state.cfg.ICAO_id, out_state.cfg.callsign);
GCS_MAVLink
../../libraries/GCS_MAVLink/GCS_Common.cpp: In member function 'bool GCS_MAVLINK::set_mavlink_message_id_interval(uint32_t, uint16_t)':
../../libraries/GCS_MAVLink/GCS_Common.cpp:815:91: warning: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t {aka long unsigned int}' [-Wformat=]
gcs().send_text(MAV_SEVERITY_INFO, "No ap_message for mavlink id (%u)", mavlink_id);
AP_GPS_SBP2
[132/605] Compiling libraries/AP_GPS/AP_GPS_SBP2.cpp
../../libraries/AP_GPS/AP_GPS_SBF.cpp: In member function 'bool AP_GPS_SBF::process_message()':
../../libraries/AP_GPS/AP_GPS_SBF.cpp:344:82: warning: format '%x' expects argument of type 'unsigned int', but argument 5 has type 'long unsigned int' [-Wformat=]
RxError & RX_ERROR_MASK, temp.RxError & RX_ERROR_MASK);
^
../../libraries/AP_GPS/AP_GPS_SBF.cpp:344:82: warning: format '%x' expects argument of type 'unsigned int', but argument 6 has type 'long unsigned int' [-Wformat=]
AP_GPS_UBLOX
../../libraries/AP_GPS/AP_GPS_UBLOX.cpp: In member function 'virtual void AP_GPS_UBLOX::broadcast_configuration_failure_reason() const':
../../libraries/AP_GPS/AP_GPS_UBLOX.cpp:1384:70: warning: format '%x' expects argument of type 'unsigned int', but argument 6 has type 'uint32_t {aka long unsigned int}' [-Wformat=]
state.instance +1, reasons[i], _unconfigured_messages);
^
AP_RSSI
../../libraries/AP_RSSI/AP_RSSI.cpp: In member function 'void AP_RSSI::check_pwm_pin_rssi()':
../../libraries/AP_RSSI/AP_RSSI.cpp:222:40: warning: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'AP_Int8 {aka AP_ParamT<signed char, (ap_var_type)1u>}' [-Wformat=]
rssi_analog_pin);
^
AP_InertialSensor
../../libraries/AP_InertialSensor/BatchSampler.cpp: In member function 'void AP_InertialSensor::BatchSampler::init()':
../../libraries/AP_InertialSensor/BatchSampler.cpp:59:128: warning: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t {aka long unsigned int}' [-Wformat=]
gcs().send_text(MAV_SEVERITY_DEBUG, "INS: alloc %u bytes for ISB (free=%u)", total_allocation, hal.util->available_memory());
^
../../libraries/AP_InertialSensor/BatchSampler.cpp:59:128: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'uint32_t {aka long unsigned int}' [-Wformat=]
../../libraries/AP_InertialSensor/BatchSampler.cpp:71:117: warning: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'uint32_t {aka long unsigned int}' [-Wformat=]
gcs().send_text(MAV_SEVERITY_WARNING, "Failed to allocate %u bytes for IMU batch sampling", total_allocation);
^
AP_RangeFinder
libraries/AP_RangeFinder/AP_RangeFinder_analog.cpp
../../libraries/AP_RangeFinder/AP_RangeFinder_PWM.cpp: In member function 'void AP_RangeFinder_PWM::check_pin()':
../../libraries/AP_RangeFinder/AP_RangeFinder_PWM.cpp:112:35: warning: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'AP_Int8 {aka AP_ParamT<signed char, (ap_var_type)1u>}' [-Wformat=]
params.pin);
^
RC_Channel
../../libraries/RC_Channel/RC_Channel.cpp: In member function 'virtual void RC_Channel::do_aux_function(RC_Channel::aux_func_t, RC_Channel::aux_switch_pos_t)':
../../libraries/RC_Channel/RC_Channel.cpp:794:84: warning: format '%u' expects argument of type 'unsigned int', but argument 4 has type 'RC_Channel::aux_func_t {aka RC_Channel::AUX_FUNC}' [-Wformat=]
gcs().send_text(MAV_SEVERITY_INFO, "Invalid channel option (%u)", ch_option);