From 07744ba6f15fc88632200128a366bf36c86e2fcf Mon Sep 17 00:00:00 2001 From: yinshengkai Date: Thu, 22 Feb 2024 13:05:27 +0800 Subject: [PATCH] fix variable set but not used These variables will trigger variable 'ret' set but not used warnings due to different configurations. For using variables only in assert, added UNUSED to declare Warnings in external repositories are ignored in the makefile Signed-off-by: yinshengkai --- boot/mcuboot/Makefile | 2 +- lte/alt1250/alt1250_main.c | 1 + modbus/nuttx/porttimer.c | 1 + system/adb/Makefile | 6 ++++++ system/adb/logcat_service.c | 2 ++ testing/getprime/getprime_main.c | 1 + 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/boot/mcuboot/Makefile b/boot/mcuboot/Makefile index 3fbd6c62a13..6a49401aa58 100644 --- a/boot/mcuboot/Makefile +++ b/boot/mcuboot/Makefile @@ -38,7 +38,7 @@ PRIORITY += SCHED_PRIORITY_DEFAULT STACKSIZE += $(CONFIG_DEFAULT_TASK_STACKSIZE) endif -CFLAGS += -Wno-undef +CFLAGS += -Wno-undef -Wno-unused-but-set-variable CSRCS := $(MCUBOOT_UNPACK)/boot/bootutil/src/boot_record.c \ $(MCUBOOT_UNPACK)/boot/bootutil/src/bootutil_misc.c \ diff --git a/lte/alt1250/alt1250_main.c b/lte/alt1250/alt1250_main.c index d78adacc402..6dab6b93438 100644 --- a/lte/alt1250/alt1250_main.c +++ b/lte/alt1250/alt1250_main.c @@ -96,6 +96,7 @@ static void notify_to_lapi_caller(sem_t *syncsem) static int initialize_daemon(FAR struct alt1250_s *dev) { int ret; + UNSED(ret); /* Initialize sub-system */ diff --git a/modbus/nuttx/porttimer.c b/modbus/nuttx/porttimer.c index 2a68654cf15..16f93ccae37 100644 --- a/modbus/nuttx/porttimer.c +++ b/modbus/nuttx/porttimer.c @@ -105,6 +105,7 @@ void vMBPortTimersEnable(void) { int res = gettimeofday(&xTimeLast, NULL); + UNUSED(res); DEBUGASSERT(res == 0); bTimeoutEnable = true; } diff --git a/system/adb/Makefile b/system/adb/Makefile index e299250fcf7..8313a287135 100644 --- a/system/adb/Makefile +++ b/system/adb/Makefile @@ -34,6 +34,12 @@ $(ADB_UNPACKDIR): $(call DELFILE, $(ADB_VERSION).zip) $(call MOVEFILE, $(ADB_UNPACKNAME)-$(ADB_VERSION), $(ADB_UNPACKDIR)) +# Fix warnings in microADB +# Error: microADB/hal/hal_uv_client_usb.c:90:13: error: unused variable 'ret' [-Werror=unused-variable] +# 90 | int ret = uv_read_start((uv_stream_t*)&client->pipe, + +CFLAGS += -Wno-error=unused-variable + # adb server app PROGNAME := $(CONFIG_ADBD_PROGNAME) diff --git a/system/adb/logcat_service.c b/system/adb/logcat_service.c index 2b7e73eec8a..7da3da93faf 100644 --- a/system/adb/logcat_service.c +++ b/system/adb/logcat_service.c @@ -67,6 +67,7 @@ static void logcat_on_kick(struct adb_service_s *service) if (!svc->wait_ack) { int ret; + UNUSED(ret); ret = uv_poll_start(&svc->poll, UV_READABLE, logcat_on_data_available); assert(ret == 0); } @@ -93,6 +94,7 @@ static void logcat_on_close(struct adb_service_s *service) int ret; logcat_service_t *svc = container_of(service, logcat_service_t, service); + UNUSED(ret); ret = uv_fileno((uv_handle_t *)&svc->poll, &fd); assert(ret == 0); diff --git a/testing/getprime/getprime_main.c b/testing/getprime/getprime_main.c index dd0b179e990..eeb8deee956 100644 --- a/testing/getprime/getprime_main.c +++ b/testing/getprime/getprime_main.c @@ -119,6 +119,7 @@ static void get_prime_in_parallel(int n) int status; int i; + UNUSED(status); status = pthread_attr_init(&attr); ASSERT(status == OK);