Skip to content
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

Compilation fixes for GCC 8.0.1 #9430

Merged
merged 11 commits into from
May 9, 2018
Merged

Compilation fixes for GCC 8.0.1 #9430

merged 11 commits into from
May 9, 2018

Conversation

bkueng
Copy link
Member

@bkueng bkueng commented May 7, 2018

GCC 8.0.1 brings some new warnings. None of these is an important fix though.

@julianoes I'm surprised that you haven't hit these yet.

bkueng added 11 commits May 7, 2018 13:35
px4_main_t is defined as:
typedef int (*px4_main_t)(int argc, char *argv[]);
which matches with the definition in NuttX, given to task_create
-Wno-extra-semi is not valid for C code
compiler warning:
../../src/systemcmds/tests/test_mixer.cpp: In member function ‘bool MixerTest::loadAllTest()’:
../../src/systemcmds/tests/test_mixer.cpp:202:18: error: ‘char* strncpy(char*, const char*, size_t)’ output truncated before terminating nul copying 1 byte from a string of the same length [-Werror=stringop-truncation]
     (void)strncpy(&buf[strlen(MIXER_ONBOARD_PATH)], "/", 1);
@bkueng bkueng force-pushed the compiler_fixes branch from b7cf8fe to 98e24a8 Compare May 7, 2018 11:35
@jlecoeur
Copy link
Contributor

jlecoeur commented May 7, 2018

With GCC 8.1.0, I have another error:

In file included from ../../mavlink/include/mavlink/v2.0/standard/standard.h:30,
                 from ../../mavlink/include/mavlink/v2.0/standard/mavlink.h:32,
                 from ../../src/modules/mavlink/mavlink_bridge_header.h:87,
                 from ../../src/modules/mavlink/mavlink_ftp.h:46,
                 from ../../src/modules/mavlink/mavlink_ftp.cpp:45:
../../mavlink/include/mavlink/v2.0/standard/../common/./mavlink_msg_heartbeat.h: In function ‘uint8_t mavlink_msg_heartbeat_get_type(const mavlink_message_t*)’:
../../mavlink/include/mavlink/v2.0/standard/../protocol.h:247:91: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
 #define _MAV_RETURN_uint8_t(msg, wire_offset) (const uint8_t)_MAV_PAYLOAD(msg)[wire_offset]
                                                                                           ^
../../mavlink/include/mavlink/v2.0/standard/../common/./mavlink_msg_heartbeat.h:262:12: note: in expansion of macro ‘_MAV_RETURN_uint8_t’
     return _MAV_RETURN_uint8_t(msg,  4);
            ^~~~~~~~~~~~~~~~~~~
compilation terminated due to -Wfatal-errors.
cc1plus: all warnings being treated as errors

which I fixed with -Wno-ignored-qualifiers in px4_base.cmake.

@bkueng
Copy link
Member Author

bkueng commented May 7, 2018

@jlecoeur I got this one as well, but have not come around to create a PR for that.

My mavlink diff:

diff --git a/mavlink_helpers.h b/mavlink_helpers.h
index 77c848d5..6dbfe833 100644
--- a/mavlink_helpers.h
+++ b/mavlink_helpers.h
@@ -107,6 +107,10 @@ MAVLINK_HELPER uint8_t _mav_trim_payload(const char *payload, uint8_t length)
 /**
  * @brief check a signature block for a packet
  */
+	union tstamp_u {
+	    uint64_t t64;
+	    uint8_t t8[8];
+	};
 MAVLINK_HELPER bool mavlink_signature_check(mavlink_signing_t *signing,
 					    mavlink_signing_streams_t *signing_streams,
 					    const mavlink_message_t *msg)
@@ -133,10 +137,10 @@ MAVLINK_HELPER bool mavlink_signature_check(mavlink_signing_t *signing,
 
 	// now check timestamp
 	bool timestamp_checks = !(signing->flags & MAVLINK_SIGNING_FLAG_NO_TIMESTAMPS);
-	union tstamp {
-	    uint64_t t64;
-	    uint8_t t8[8];
-	} tstamp;
+	//../../mavlink/include/mavlink/v2.0/common/../mavlink_helpers.h: In function ‘bool mavlink_signature_check(mavlink_signing_t*, mavlink_signing_streams_t*, const mavlink_message_t*)’:
+	//../../mavlink/include/mavlink/v2.0/common/../mavlink_helpers.h:139:4: error: conflicting C language linkage declaration ‘mavlink_signature_check(mavlink_signing_t*, mavlink_signing_streams_t*, const mavlink_message_t*)::tstamp_u tstamp’ [-Werror]
+	//  } tstamp;
+	union tstamp_u tstamp;
 	uint8_t link_id = psig[0];
 	tstamp.t64 = 0;
 	memcpy(tstamp.t8, psig+1, 6);
@@ -168,7 +172,7 @@ MAVLINK_HELPER bool mavlink_signature_check(mavlink_signing_t *signing,
 		signing_streams->stream[i].link_id = link_id;
 		signing_streams->num_signing_streams++;
 	} else {
-		union tstamp last_tstamp;
+		union tstamp_u last_tstamp;
 		last_tstamp.t64 = 0;
 		memcpy(last_tstamp.t8, signing_streams->stream[i].timestamp_bytes, 6);
 		if (timestamp_checks && tstamp.t64 <= last_tstamp.t64) {
diff --git a/protocol.h b/protocol.h
index 8f539709..5c09761a 100644
--- a/protocol.h
+++ b/protocol.h
@@ -242,9 +242,14 @@ _MAV_PUT_ARRAY(int64_t,  i64)
 _MAV_PUT_ARRAY(float,    f)
 _MAV_PUT_ARRAY(double,   d)
 
-#define _MAV_RETURN_char(msg, wire_offset)             (const char)_MAV_PAYLOAD(msg)[wire_offset]
-#define _MAV_RETURN_int8_t(msg, wire_offset)   (const int8_t)_MAV_PAYLOAD(msg)[wire_offset]
-#define _MAV_RETURN_uint8_t(msg, wire_offset) (const uint8_t)_MAV_PAYLOAD(msg)[wire_offset]
+/*
+../../mavlink/include/mavlink/v2.0/common/./mavlink_msg_heartbeat.h: In function ‘uint8_t mavlink_msg_heartbeat_get_type(const mavlink_message_t*)’:
+../../mavlink/include/mavlink/v2.0/common/../protocol.h:247:91: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]
+ #define _MAV_RETURN_uint8_t(msg, wire_offset) (const uint8_t)_MAV_PAYLOAD(msg)[wire_offset]
+ */
+#define _MAV_RETURN_char(msg, wire_offset)             (char)_MAV_PAYLOAD(msg)[wire_offset]
+#define _MAV_RETURN_int8_t(msg, wire_offset)   (int8_t)_MAV_PAYLOAD(msg)[wire_offset]
+#define _MAV_RETURN_uint8_t(msg, wire_offset) (uint8_t)_MAV_PAYLOAD(msg)[wire_offset]
 
 #if MAVLINK_NEED_BYTE_SWAP
 #define _MAV_MSG_RETURN_TYPE(TYPE, SIZE) \

The first one is a strange error:

../../mavlink/include/mavlink/v2.0/common/./mavlink_msg_heartbeat.h: In function ‘uint8_t mavlink_msg_heartbeat_get_type(const mavlink_message_t*)’:
+../../mavlink/include/mavlink/v2.0/common/../protocol.h:247:91: error: type qualifiers ignored on cast result type [-Werror=ignored-qualifiers]

for union tstamp_u tstamp;. Did you get that as well?

@jlecoeur
Copy link
Contributor

jlecoeur commented May 8, 2018

@bkueng no I had no error on tstamp_u

@bkueng
Copy link
Member Author

bkueng commented May 8, 2018

Ok then I guess it's some GCC weirdness.
Mavlink PR: https://github.com/mavlink/pymavlink/pull/11

@julianoes
Copy link
Contributor

Thanks @bkueng. I might not have updated recently. And I'm not currently using my Arch box.

@bkueng bkueng merged commit c6b0d5c into master May 9, 2018
@bkueng bkueng deleted the compiler_fixes branch May 9, 2018 05:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants