From 2487dbfc9254c7411e0c1e5fc449aaacbbf61e78 Mon Sep 17 00:00:00 2001
From: Daniel Agar <daniel@agar.ca>
Date: Thu, 19 May 2016 00:19:09 -0400
Subject: [PATCH] remove Wpacked and cleanup unused warning flags

---
 cmake/common/px4_base.cmake                            | 1 -
 src/drivers/px4flow/CMakeLists.txt                     | 1 -
 src/drivers/snapdragon_rc_pwm/CMakeLists.txt           | 2 --
 src/drivers/uart_esc/CMakeLists.txt                    | 1 -
 src/firmware/posix/CMakeLists.txt                      | 2 +-
 src/modules/commander/CMakeLists.txt                   | 2 --
 src/modules/mavlink/CMakeLists.txt                     | 4 ----
 src/modules/mavlink/mavlink_tests/CMakeLists.txt       | 3 ---
 src/modules/navigator/CMakeLists.txt                   | 1 -
 src/modules/navigator/geofence.h                       | 2 +-
 src/modules/navigator/mission.cpp                      | 2 +-
 src/modules/sensors/CMakeLists.txt                     | 3 +--
 src/modules/sensors/sensors.cpp                        | 2 +-
 src/modules/simulator/CMakeLists.txt                   | 3 ---
 src/modules/systemlib/CMakeLists.txt                   | 2 --
 src/modules/systemlib/param/param.c                    | 2 +-
 src/modules/uavcan/CMakeLists.txt                      | 3 ---
 src/platforms/posix/drivers/accelsim/CMakeLists.txt    | 1 -
 src/platforms/posix/drivers/airspeedsim/CMakeLists.txt | 1 -
 src/platforms/posix/drivers/barosim/CMakeLists.txt     | 1 -
 src/platforms/posix/drivers/gpssim/CMakeLists.txt      | 1 -
 src/platforms/posix/drivers/gyrosim/CMakeLists.txt     | 1 -
 src/platforms/posix/px4_layer/CMakeLists.txt           | 2 --
 src/platforms/qurt/px4_layer/CMakeLists.txt            | 1 -
 src/systemcmds/mtd/CMakeLists.txt                      | 1 -
 src/systemcmds/tests/CMakeLists.txt                    | 4 ++--
 26 files changed, 8 insertions(+), 41 deletions(-)

diff --git a/cmake/common/px4_base.cmake b/cmake/common/px4_base.cmake
index 2098996188..886522763a 100644
--- a/cmake/common/px4_base.cmake
+++ b/cmake/common/px4_base.cmake
@@ -597,7 +597,6 @@ function(px4_add_common_flags)
 		-Wall
 		-Werror
 		-Wextra
-		-Wpacked
 		-Wno-sign-compare
 		-Wshadow
 		-Wfloat-equal
diff --git a/src/drivers/px4flow/CMakeLists.txt b/src/drivers/px4flow/CMakeLists.txt
index 1859ab3534..d8953b1ae1 100644
--- a/src/drivers/px4flow/CMakeLists.txt
+++ b/src/drivers/px4flow/CMakeLists.txt
@@ -35,7 +35,6 @@ px4_add_module(
 	MAIN px4flow
 	STACK_MAIN 1200
 	COMPILE_FLAGS
-		-Wno-attributes
 		-Os
 	SRCS
 		px4flow.cpp
diff --git a/src/drivers/snapdragon_rc_pwm/CMakeLists.txt b/src/drivers/snapdragon_rc_pwm/CMakeLists.txt
index 405b903306..6fae0f3157 100644
--- a/src/drivers/snapdragon_rc_pwm/CMakeLists.txt
+++ b/src/drivers/snapdragon_rc_pwm/CMakeLists.txt
@@ -35,8 +35,6 @@ px4_add_module(
 	MAIN snapdragon_rc_pwm
 	COMPILE_FLAGS
 		-Os
-		-Wno-attributes
-		-Wno-packed
 	SRCS
 		snapdragon_rc_pwm.cpp
 	DEPENDS
diff --git a/src/drivers/uart_esc/CMakeLists.txt b/src/drivers/uart_esc/CMakeLists.txt
index 43c201b26d..cb060c82da 100644
--- a/src/drivers/uart_esc/CMakeLists.txt
+++ b/src/drivers/uart_esc/CMakeLists.txt
@@ -35,7 +35,6 @@ px4_add_module(
 	MAIN uart_esc
 	COMPILE_FLAGS
 		-Os
-		-Wno-packed
 	SRCS
 		uart_esc.cpp
 	DEPENDS
diff --git a/src/firmware/posix/CMakeLists.txt b/src/firmware/posix/CMakeLists.txt
index ce2b469961..8d0232a017 100644
--- a/src/firmware/posix/CMakeLists.txt
+++ b/src/firmware/posix/CMakeLists.txt
@@ -11,7 +11,7 @@ if ("${BOARD}" STREQUAL "eagle" OR ("${BOARD}" STREQUAL "excelsior"))
 
 	FASTRPC_STUB_GEN(../qurt/px4muorb.idl)
 
-	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-missing-prototypes -Wno-missing-declarations")
+	set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
 	LINUX_APP(
 		APP_NAME mainapp
 		IDL_NAME px4muorb
diff --git a/src/modules/commander/CMakeLists.txt b/src/modules/commander/CMakeLists.txt
index be0d32dec7..8972791a41 100644
--- a/src/modules/commander/CMakeLists.txt
+++ b/src/modules/commander/CMakeLists.txt
@@ -36,8 +36,6 @@ px4_add_module(
 	STACK_MAIN 4096
 	STACK_MAX 2450
 	COMPILE_FLAGS
-		-Wno-attributes
-		-Wno-packed
 		-Os
 	SRCS
 		commander.cpp
diff --git a/src/modules/mavlink/CMakeLists.txt b/src/modules/mavlink/CMakeLists.txt
index 01a8b5fa5c..8487dad685 100644
--- a/src/modules/mavlink/CMakeLists.txt
+++ b/src/modules/mavlink/CMakeLists.txt
@@ -36,11 +36,7 @@ px4_add_module(
 	STACK_MAIN 1200
 	STACK_MAX 1500
 	COMPILE_FLAGS
-		-Wno-attributes
-		-Wno-packed
 		-DMAVLINK_COMM_NUM_BUFFERS=4
-		-Wno-packed
-		-Wno-tautological-constant-out-of-range-compare
 		-Os
 	SRCS
 		mavlink.c
diff --git a/src/modules/mavlink/mavlink_tests/CMakeLists.txt b/src/modules/mavlink/mavlink_tests/CMakeLists.txt
index 8096965c3d..26b7d0d4ba 100644
--- a/src/modules/mavlink/mavlink_tests/CMakeLists.txt
+++ b/src/modules/mavlink/mavlink_tests/CMakeLists.txt
@@ -36,9 +36,6 @@ px4_add_module(
 	STACK_MAIN 5000
 	COMPILE_FLAGS
 		-DMAVLINK_FTP_UNIT_TEST
-		-Wno-attributes
-		-Wno-packed
-		-Wno-packed
 		-Os
 	SRCS
 		mavlink_tests.cpp
diff --git a/src/modules/navigator/CMakeLists.txt b/src/modules/navigator/CMakeLists.txt
index 4fb4a5bed4..89530ca119 100644
--- a/src/modules/navigator/CMakeLists.txt
+++ b/src/modules/navigator/CMakeLists.txt
@@ -35,7 +35,6 @@ px4_add_module(
 	MAIN navigator
 	STACK_MAIN 1200
 	COMPILE_FLAGS
-		-Wno-sign-compare
 		-Os
 	SRCS
 		navigator_main.cpp
diff --git a/src/modules/navigator/geofence.h b/src/modules/navigator/geofence.h
index f46f849b18..ee8f61e484 100644
--- a/src/modules/navigator/geofence.h
+++ b/src/modules/navigator/geofence.h
@@ -131,7 +131,7 @@ private:
 	control::BlockParamInt _param_max_hor_distance;
 	control::BlockParamInt _param_max_ver_distance;
 
-	unsigned _outside_counter;
+	int _outside_counter;
 
 	bool inside(double lat, double lon, float altitude);
 	bool inside(const struct vehicle_global_position_s &global_position);
diff --git a/src/modules/navigator/mission.cpp b/src/modules/navigator/mission.cpp
index 56fa817845..401fe0899d 100644
--- a/src/modules/navigator/mission.cpp
+++ b/src/modules/navigator/mission.cpp
@@ -1149,7 +1149,7 @@ Mission::reset_offboard_mission(struct mission_s &mission)
 			if (mission.count > 0) {
 				dm_item_t dm_current = DM_KEY_WAYPOINTS_OFFBOARD(mission.dataman_id);
 
-				for (int index = 0; index < mission.count; index++) {
+				for (unsigned index = 0; index < mission.count; index++) {
 					struct mission_item_s item;
 					const ssize_t len = sizeof(struct mission_item_s);
 
diff --git a/src/modules/sensors/CMakeLists.txt b/src/modules/sensors/CMakeLists.txt
index 93f2f59d2f..e26df79246 100644
--- a/src/modules/sensors/CMakeLists.txt
+++ b/src/modules/sensors/CMakeLists.txt
@@ -35,9 +35,8 @@ px4_add_module(
 	MODULE modules__sensors
 	MAIN sensors
 	PRIORITY "SCHED_PRIORITY_MAX-5"
-	STACK_MAIN 1200
+	STACK_MAIN 1300
 	COMPILE_FLAGS
-		-Wno-type-limits
 		-O3
 	SRCS
 		sensors.cpp
diff --git a/src/modules/sensors/sensors.cpp b/src/modules/sensors/sensors.cpp
index 35db3614af..cbc3e062ac 100644
--- a/src/modules/sensors/sensors.cpp
+++ b/src/modules/sensors/sensors.cpp
@@ -1945,7 +1945,7 @@ Sensors::rc_poll()
 			if (_parameters.rc_map_flightmode > 0) {
 
 				/* the number of valid slots equals the index of the max marker minus one */
-				const unsigned num_slots = manual_control_setpoint_s::MODE_SLOT_MAX;
+				const int num_slots = manual_control_setpoint_s::MODE_SLOT_MAX;
 
 				/* the half width of the range of a slot is the total range
 				 * divided by the number of slots, again divided by two
diff --git a/src/modules/simulator/CMakeLists.txt b/src/modules/simulator/CMakeLists.txt
index 0a7e221086..98db9d8731 100644
--- a/src/modules/simulator/CMakeLists.txt
+++ b/src/modules/simulator/CMakeLists.txt
@@ -40,9 +40,6 @@ px4_add_module(
 	MODULE modules__simulator
 	MAIN simulator
 	COMPILE_FLAGS
-		-Wno-attributes
-		-Wno-packed
-		-Wno-packed
 	SRCS
 		${SIMULATOR_SRCS}
 	DEPENDS
diff --git a/src/modules/systemlib/CMakeLists.txt b/src/modules/systemlib/CMakeLists.txt
index 3fadc26da3..4507974e85 100644
--- a/src/modules/systemlib/CMakeLists.txt
+++ b/src/modules/systemlib/CMakeLists.txt
@@ -80,8 +80,6 @@ px4_add_module(
 	MODULE modules__systemlib
 	COMPILE_FLAGS
 		-Wno-sign-compare
-		-Wno-attributes
-		-Wno-packed
 		-Os
 	SRCS ${SRCS}
 	DEPENDS
diff --git a/src/modules/systemlib/param/param.c b/src/modules/systemlib/param/param.c
index 1973704738..02e384e0e5 100644
--- a/src/modules/systemlib/param/param.c
+++ b/src/modules/systemlib/param/param.c
@@ -173,7 +173,7 @@ param_assert_locked(void)
 static bool
 handle_in_range(param_t param)
 {
-	int count = get_param_info_count();
+	unsigned count = get_param_info_count();
 	return (count && param < count);
 }
 
diff --git a/src/modules/uavcan/CMakeLists.txt b/src/modules/uavcan/CMakeLists.txt
index c485fc8da6..8aea69743b 100644
--- a/src/modules/uavcan/CMakeLists.txt
+++ b/src/modules/uavcan/CMakeLists.txt
@@ -59,9 +59,6 @@ px4_add_module(
 	STACK_MAIN 3200
 	STACK_MAX 1500
 	COMPILE_FLAGS
-		-Wno-attributes
-		-Wno-packed
-		-Wno-deprecated-declarations
 		-Os
 	SRCS
 		# Main
diff --git a/src/platforms/posix/drivers/accelsim/CMakeLists.txt b/src/platforms/posix/drivers/accelsim/CMakeLists.txt
index d4146b8129..253fd3c62d 100644
--- a/src/platforms/posix/drivers/accelsim/CMakeLists.txt
+++ b/src/platforms/posix/drivers/accelsim/CMakeLists.txt
@@ -34,7 +34,6 @@ px4_add_module(
 	MODULE platforms__posix__drivers__accelsim
 	MAIN accelsim
 	COMPILE_FLAGS
-		-Wno-packed
 	SRCS
 		accelsim.cpp
 	DEPENDS
diff --git a/src/platforms/posix/drivers/airspeedsim/CMakeLists.txt b/src/platforms/posix/drivers/airspeedsim/CMakeLists.txt
index cecefb204e..8c2a410862 100644
--- a/src/platforms/posix/drivers/airspeedsim/CMakeLists.txt
+++ b/src/platforms/posix/drivers/airspeedsim/CMakeLists.txt
@@ -34,7 +34,6 @@ px4_add_module(
 	MODULE platforms__posix__drivers__airspeedsim
 	MAIN measairspeedsim
 	COMPILE_FLAGS
-		-Wno-packed
 		-Os
 	SRCS
 		airspeedsim.cpp
diff --git a/src/platforms/posix/drivers/barosim/CMakeLists.txt b/src/platforms/posix/drivers/barosim/CMakeLists.txt
index 6103737bfb..6e3a105204 100644
--- a/src/platforms/posix/drivers/barosim/CMakeLists.txt
+++ b/src/platforms/posix/drivers/barosim/CMakeLists.txt
@@ -34,7 +34,6 @@ px4_add_module(
 	MODULE platforms__posix__drivers__barosim
 	MAIN barosim
 	COMPILE_FLAGS
-		-Wno-packed
 		-Os
 	SRCS
 		baro.cpp
diff --git a/src/platforms/posix/drivers/gpssim/CMakeLists.txt b/src/platforms/posix/drivers/gpssim/CMakeLists.txt
index 60cd2de7a8..2c580d7757 100644
--- a/src/platforms/posix/drivers/gpssim/CMakeLists.txt
+++ b/src/platforms/posix/drivers/gpssim/CMakeLists.txt
@@ -34,7 +34,6 @@ px4_add_module(
 	MODULE platforms__posix__drivers__gpssim
 	MAIN gpssim
 	COMPILE_FLAGS
-		-Wno-packed
 		-Os
 	SRCS
 		gpssim.cpp
diff --git a/src/platforms/posix/drivers/gyrosim/CMakeLists.txt b/src/platforms/posix/drivers/gyrosim/CMakeLists.txt
index 88571e41b6..bac977afbb 100644
--- a/src/platforms/posix/drivers/gyrosim/CMakeLists.txt
+++ b/src/platforms/posix/drivers/gyrosim/CMakeLists.txt
@@ -35,7 +35,6 @@ px4_add_module(
 	MAIN gyrosim
 	STACK_MAIN 1200
 	COMPILE_FLAGS
-		-Wno-packed
 		-Os
 	SRCS
 		gyrosim.cpp
diff --git a/src/platforms/posix/px4_layer/CMakeLists.txt b/src/platforms/posix/px4_layer/CMakeLists.txt
index abccca4c59..d80b6083ad 100644
--- a/src/platforms/posix/px4_layer/CMakeLists.txt
+++ b/src/platforms/posix/px4_layer/CMakeLists.txt
@@ -43,8 +43,6 @@ px4_add_module(
 	MODULE platforms__posix__px4_layer
 	COMPILE_FLAGS
 		-Os
-		-Wno-attributes
-		-Wno-packed
 	SRCS
 		px4_posix_impl.cpp
 		px4_posix_tasks.cpp
diff --git a/src/platforms/qurt/px4_layer/CMakeLists.txt b/src/platforms/qurt/px4_layer/CMakeLists.txt
index 25ada03442..6196d1d43f 100644
--- a/src/platforms/qurt/px4_layer/CMakeLists.txt
+++ b/src/platforms/qurt/px4_layer/CMakeLists.txt
@@ -55,7 +55,6 @@ px4_add_module(
 	MODULE platforms__qurt__px4_layer
 	COMPILE_FLAGS
 		-Os
-		-Wno-packed
 	SRCS
 		${QURT_LAYER_SRCS}
 		${CONFIG_SRC}
diff --git a/src/systemcmds/mtd/CMakeLists.txt b/src/systemcmds/mtd/CMakeLists.txt
index 7c67196736..2a1f73e401 100644
--- a/src/systemcmds/mtd/CMakeLists.txt
+++ b/src/systemcmds/mtd/CMakeLists.txt
@@ -34,7 +34,6 @@ px4_add_module(
 	MODULE systemcmds__mtd
 	MAIN mtd
 	COMPILE_FLAGS
-		-Wno-error
 		-Os
 	SRCS
 		mtd.c
diff --git a/src/systemcmds/tests/CMakeLists.txt b/src/systemcmds/tests/CMakeLists.txt
index 60f9cc885d..50365c62b3 100644
--- a/src/systemcmds/tests/CMakeLists.txt
+++ b/src/systemcmds/tests/CMakeLists.txt
@@ -70,10 +70,10 @@ px4_add_module(
 	MODULE systemcmds__tests
 	MAIN tests
 	STACK_MAIN 9000
+	STACK_MAX 9000
 	COMPILE_FLAGS
-		-Wframe-larger-than=8000
 		-Wno-float-equal
-		-O0
+		-Os
 	SRCS ${srcs}
 	DEPENDS
 		platforms__common
-- 
GitLab