mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 08:13:33 +08:00
fix all sign-compare warnings
This commit is contained in:
committed by
Lorenz Meier
parent
cf74166801
commit
9ce83f2208
@@ -39,7 +39,6 @@ px4_add_module(
|
||||
STACK_MAIN 1200
|
||||
STACK_MAX 1500
|
||||
COMPILE_FLAGS
|
||||
-Wno-sign-compare # TODO: fix all sign-compare
|
||||
INCLUDES
|
||||
${PX4_SOURCE_DIR}/mavlink/include/mavlink
|
||||
SRCS
|
||||
|
||||
@@ -477,7 +477,7 @@ LogListHelper::_init()
|
||||
time_t tt = 0;
|
||||
char log_path[128];
|
||||
int ret = snprintf(log_path, sizeof(log_path), "%s/%s", kLogRoot, result->d_name);
|
||||
bool path_is_ok = (ret > 0) && (ret < sizeof(log_path));
|
||||
bool path_is_ok = (ret > 0) && (ret < (int)sizeof(log_path));
|
||||
|
||||
if (path_is_ok) {
|
||||
if (_get_session_date(log_path, result->d_name, tt)) {
|
||||
@@ -539,7 +539,7 @@ LogListHelper::_scan_logs(FILE *f, const char *dir, time_t &date)
|
||||
uint32_t size = 0;
|
||||
char log_file_path[128];
|
||||
int ret = snprintf(log_file_path, sizeof(log_file_path), "%s/%s", dir, result->d_name);
|
||||
bool path_is_ok = (ret > 0) && (ret < sizeof(log_file_path));
|
||||
bool path_is_ok = (ret > 0) && (ret < (int)sizeof(log_file_path));
|
||||
|
||||
if (path_is_ok) {
|
||||
if (_get_log_time_size(log_file_path, result->d_name, ldate, size)) {
|
||||
@@ -609,7 +609,7 @@ LogListHelper::delete_all(const char *dir)
|
||||
if (result->d_type == PX4LOG_DIRECTORY && result->d_name[0] != '.') {
|
||||
char log_path[128];
|
||||
int ret = snprintf(log_path, sizeof(log_path), "%s/%s", dir, result->d_name);
|
||||
bool path_is_ok = (ret > 0) && (ret < sizeof(log_path));
|
||||
bool path_is_ok = (ret > 0) && (ret < (int)sizeof(log_path));
|
||||
|
||||
if (path_is_ok) {
|
||||
LogListHelper::delete_all(log_path);
|
||||
@@ -623,7 +623,7 @@ LogListHelper::delete_all(const char *dir)
|
||||
if (result->d_type == PX4LOG_REGULAR_FILE) {
|
||||
char log_path[128];
|
||||
int ret = snprintf(log_path, sizeof(log_path), "%s/%s", dir, result->d_name);
|
||||
bool path_is_ok = (ret > 0) && (ret < sizeof(log_path));
|
||||
bool path_is_ok = (ret > 0) && (ret < (int)sizeof(log_path));
|
||||
|
||||
if (path_is_ok) {
|
||||
if (unlink(log_path)) {
|
||||
|
||||
@@ -115,7 +115,7 @@ extern mavlink_system_t mavlink_system;
|
||||
|
||||
void mavlink_send_uart_bytes(mavlink_channel_t chan, const uint8_t *ch, int length)
|
||||
{
|
||||
Mavlink *m = Mavlink::get_instance((unsigned)chan);
|
||||
Mavlink *m = Mavlink::get_instance(chan);
|
||||
|
||||
if (m != nullptr) {
|
||||
m->send_bytes(ch, length);
|
||||
@@ -131,7 +131,7 @@ void mavlink_send_uart_bytes(mavlink_channel_t chan, const uint8_t *ch, int leng
|
||||
|
||||
void mavlink_start_uart_send(mavlink_channel_t chan, int length)
|
||||
{
|
||||
Mavlink *m = Mavlink::get_instance((unsigned)chan);
|
||||
Mavlink *m = Mavlink::get_instance(chan);
|
||||
|
||||
if (m != nullptr) {
|
||||
(void)m->begin_send();
|
||||
@@ -143,7 +143,7 @@ void mavlink_start_uart_send(mavlink_channel_t chan, int length)
|
||||
|
||||
void mavlink_end_uart_send(mavlink_channel_t chan, int length)
|
||||
{
|
||||
Mavlink *m = Mavlink::get_instance((unsigned)chan);
|
||||
Mavlink *m = Mavlink::get_instance(chan);
|
||||
|
||||
if (m != nullptr) {
|
||||
(void)m->send_packet();
|
||||
@@ -158,7 +158,7 @@ void mavlink_end_uart_send(mavlink_channel_t chan, int length)
|
||||
*/
|
||||
mavlink_status_t *mavlink_get_channel_status(uint8_t channel)
|
||||
{
|
||||
Mavlink *m = Mavlink::get_instance((unsigned)channel);
|
||||
Mavlink *m = Mavlink::get_instance(channel);
|
||||
|
||||
if (m != nullptr) {
|
||||
return m->get_status();
|
||||
@@ -173,7 +173,7 @@ mavlink_status_t *mavlink_get_channel_status(uint8_t channel)
|
||||
*/
|
||||
mavlink_message_t *mavlink_get_channel_buffer(uint8_t channel)
|
||||
{
|
||||
Mavlink *m = Mavlink::get_instance((unsigned)channel);
|
||||
Mavlink *m = Mavlink::get_instance(channel);
|
||||
|
||||
if (m != nullptr) {
|
||||
return m->get_buffer();
|
||||
@@ -386,7 +386,7 @@ Mavlink::instance_count()
|
||||
}
|
||||
|
||||
Mavlink *
|
||||
Mavlink::get_instance(unsigned instance)
|
||||
Mavlink::get_instance(int instance)
|
||||
{
|
||||
Mavlink *inst;
|
||||
LL_FOREACH(::_mavlink_instances, inst) {
|
||||
@@ -524,8 +524,8 @@ Mavlink::forward_message(const mavlink_message_t *msg, Mavlink *self)
|
||||
const mavlink_msg_entry_t *meta = mavlink_get_msg_entry(msg->msgid);
|
||||
|
||||
// Extract target system and target component if set
|
||||
unsigned target_system_id = (meta->target_system_ofs != 0) ? ((uint8_t *)msg)[meta->target_system_ofs] : 0;
|
||||
unsigned target_component_id = (meta->target_component_ofs != 0) ? ((uint8_t *)msg)[meta->target_component_ofs] : 233;
|
||||
int target_system_id = (meta->target_system_ofs != 0) ? ((uint8_t *)msg)[meta->target_system_ofs] : 0;
|
||||
int target_component_id = (meta->target_component_ofs != 0) ? ((uint8_t *)msg)[meta->target_component_ofs] : 233;
|
||||
|
||||
// Broadcast or addressing this system and not trying to talk
|
||||
// to the autopilot component -> pass on to other components
|
||||
@@ -1088,7 +1088,7 @@ Mavlink::find_broadcast_address()
|
||||
return;
|
||||
}
|
||||
|
||||
size_t offset = 0;
|
||||
int offset = 0;
|
||||
// Later used to point to next network interface in buffer.
|
||||
struct ifreq *cur_ifreq = (struct ifreq *) & (((uint8_t *)ifconf.ifc_req)[offset]);
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public:
|
||||
|
||||
static Mavlink *new_instance();
|
||||
|
||||
static Mavlink *get_instance(unsigned instance);
|
||||
static Mavlink *get_instance(int instance);
|
||||
|
||||
static Mavlink *get_instance_for_device(const char *device_name);
|
||||
|
||||
@@ -510,9 +510,9 @@ private:
|
||||
orb_advert_t _mavlink_log_pub;
|
||||
bool _task_running;
|
||||
static bool _boot_complete;
|
||||
static constexpr unsigned MAVLINK_MAX_INSTANCES = 4;
|
||||
static constexpr unsigned MAVLINK_MIN_INTERVAL = 1500;
|
||||
static constexpr unsigned MAVLINK_MAX_INTERVAL = 10000;
|
||||
static constexpr int MAVLINK_MAX_INSTANCES = 4;
|
||||
static constexpr int MAVLINK_MIN_INTERVAL = 1500;
|
||||
static constexpr int MAVLINK_MAX_INTERVAL = 10000;
|
||||
static constexpr float MAVLINK_MIN_MULTIPLIER = 0.0005f;
|
||||
mavlink_message_t _mavlink_buffer;
|
||||
mavlink_status_t _mavlink_status;
|
||||
|
||||
@@ -38,7 +38,6 @@ px4_add_module(
|
||||
MAIN mavlink_tests
|
||||
STACK_MAIN 5000
|
||||
COMPILE_FLAGS
|
||||
-Wno-sign-compare # TODO: fix all sign-compare
|
||||
-DMAVLINK_FTP_UNIT_TEST
|
||||
#-DMAVLINK_FTP_DEBUG
|
||||
-DMavlinkStream=MavlinkStreamTest
|
||||
|
||||
Reference in New Issue
Block a user