misc: Clean up a large pile of -Wexpansion-to-defined warnings

And re-enable the warning (applies with GCC 7+)

Change-Id: I406ce796ebd06bad53cab911e17a28265a79b420
This commit is contained in:
Solomon Peachy 2025-04-21 20:52:56 -04:00
parent 6fc87143df
commit c7eda36341
7 changed files with 21 additions and 18 deletions

View file

@ -412,7 +412,7 @@ static const struct plugin_api rockbox_api = {
storage_sleep,
STORAGE_FUNCTION(spin),
STORAGE_FUNCTION(spindown),
#if USING_STORAGE_CALLBACK
#ifdef USING_STORAGE_CALLBACK
register_storage_idle_func,
unregister_storage_idle_func,
#endif /* USING_STORAGE_CALLBACK */

View file

@ -474,7 +474,7 @@ struct plugin_api {
void (*storage_sleep)(void);
void (*storage_spin)(void);
void (*storage_spindown)(int seconds);
#if USING_STORAGE_CALLBACK
#ifdef USING_STORAGE_CALLBACK
void (*register_storage_idle_func)(void (*function)(void));
void (*unregister_storage_idle_func)(void (*function)(void), bool run);
#endif /* USING_STORAGE_CALLBACK */

View file

@ -458,7 +458,7 @@ static void thread(void)
bat[buf_idx].flags = charge_state();
#endif
buf_idx++;
#if USING_STORAGE_CALLBACK
#ifdef USING_STORAGE_CALLBACK
rb->register_storage_idle_func(flush_buffer);
#endif
}
@ -497,7 +497,7 @@ static void thread(void)
}
}
#if USING_STORAGE_CALLBACK
#ifdef USING_STORAGE_CALLBACK
/* unregister flush callback and flush to disk */
rb->unregister_storage_idle_func(flush_buffer, true);
#else

View file

@ -25,7 +25,7 @@
#include "kernel.h"
#include "string.h"
#if USING_STORAGE_CALLBACK
#if defined(USING_STORAGE_CALLBACK)
static void wrapper(unsigned short id, void *ev_data, void *user_data)
{
(void)id;
@ -37,7 +37,7 @@ static void wrapper(unsigned short id, void *ev_data, void *user_data)
void register_storage_idle_func(void (*function)(void))
{
#if USING_STORAGE_CALLBACK
#if defined(USING_STORAGE_CALLBACK)
add_event_ex(DISK_EVENT_SPINUP, true, wrapper, function);
#else
function(); /* just call the function now */
@ -47,11 +47,11 @@ void register_storage_idle_func(void (*function)(void))
#endif
}
#if USING_STORAGE_CALLBACK
#if defined(USING_STORAGE_CALLBACK)
void unregister_storage_idle_func(void (*func)(void), bool run)
{
remove_event_ex(DISK_EVENT_SPINUP, wrapper, func);
if (run)
func();
}
@ -68,7 +68,7 @@ bool call_storage_idle_notifys(bool force)
lock_until = current_tick + 30*HZ;
send_event(DISK_EVENT_SPINUP, NULL);
return true;
}
#endif

View file

@ -27,7 +27,7 @@
/*
NOTE: storage_idle_notify usage notes..
1) The callbacks are called in the ata thread, not main/your thread.
2) Asynchronous callbacks (like the buffer refill) should be avoided.
If you must use an async callback, remember to check storage_is_active() before
@ -46,10 +46,12 @@ enum {
/* Enable storage callbacks everywhere except for bootloaders. Both
* hosted and native targets need this.
*/
#define USING_STORAGE_CALLBACK !defined(BOOTLOADER) && !defined(APPLICATION) && !defined(__PCTOOL__)
#if !defined(BOOTLOADER) && !defined(APPLICATION) && !defined(__PCTOOL__)
#define USING_STORAGE_CALLBACK
#endif
extern void register_storage_idle_func(void (*function)(void));
#if USING_STORAGE_CALLBACK
#ifdef USING_STORAGE_CALLBACK
extern void unregister_storage_idle_func(void (*function)(void), bool run);
extern bool call_storage_idle_notifys(bool force);
#else

View file

@ -131,9 +131,10 @@ static const char power_thread_name[] = "power";
/* Time estimation requires 64 bit math so don't use it in the bootloader.
* Also we need to be able to measure current, and not have a better time
* estimate source available. */
#define HAVE_TIME_ESTIMATION \
(!defined(BOOTLOADER) && !(CONFIG_BATTERY_MEASURE & TIME_MEASURE) && \
#if (!defined(BOOTLOADER) && !(CONFIG_BATTERY_MEASURE & TIME_MEASURE) && \
(defined(CURRENT_NORMAL) || (CONFIG_BATTERY_MEASURE & CURRENT_MEASURE)))
#define HAVE_TIME_ESTIMATION
#endif
#if !(CONFIG_BATTERY_MEASURE & PERCENTAGE_MEASURE)
int _battery_level(void) { return -1; }
@ -146,7 +147,7 @@ int _battery_time(void) { return -1; }
static int time_now; /* Cached to avoid polling too often */
#endif
#if HAVE_TIME_ESTIMATION
#ifdef HAVE_TIME_ESTIMATION
static int time_now; /* reported time in minutes */
static int64_t time_cnt; /* reported time in seconds */
static int64_t time_err; /* error... it's complicated */
@ -186,7 +187,7 @@ int battery_level(void)
* on the battery level and the actual current usage. */
int battery_time(void)
{
#if (CONFIG_BATTERY_MEASURE & TIME_MEASURE) || HAVE_TIME_ESTIMATION
#if (CONFIG_BATTERY_MEASURE & TIME_MEASURE) || defined(HAVE_TIME_ESTIMATION)
return time_now;
#else
return -1;
@ -401,7 +402,7 @@ static void battery_status_update(void)
#if CONFIG_BATTERY_MEASURE & TIME_MEASURE
time_now = _battery_time();
#elif HAVE_TIME_ESTIMATION
#elif defined(HAVE_TIME_ESTIMATION)
/* TODO: This is essentially a bad version of coloumb counting,
* so in theory using coloumb counters when they are available
* should provide a more accurate result. Also note that this

2
tools/configure vendored
View file

@ -4614,7 +4614,7 @@ else
if test "$gccnum" -ge "700"; then
# gcc 7 spews a bunch of warnings by default
GCCOPTS="$GCCOPTS -Wno-expansion-to-defined -Wimplicit-fallthrough=0"
GCCOPTS="$GCCOPTS -Wimplicit-fallthrough=0"
fi
case "$GCCOPTS" in