From 5d1a444812f46b3f841ea2f09b1dd6be9725ec15 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 27 Jul 2021 21:11:56 +0800 Subject: [PATCH] Replace __attribute__ ((unused)) with unused_code Signed-off-by: Xiang Xiao --- arch/arm/src/cxd56xx/cxd56_clock.c | 10 +++------- arch/arm/src/cxd56xx/cxd56_farapi.c | 2 +- arch/arm/src/cxd56xx/cxd56_scufifo.c | 2 -- arch/arm/src/cxd56xx/cxd56_spi.c | 22 +++++++--------------- arch/arm/src/rp2040/rp2040_spi.c | 18 +++++++----------- arch/risc-v/src/bl602/bl602_start.c | 3 +-- arch/x86_64/src/intel64/up_irq.c | 4 ++-- include/nuttx/compiler.h | 14 ++++++++++++++ include/nuttx/tree.h | 6 +++--- 9 files changed, 38 insertions(+), 43 deletions(-) diff --git a/arch/arm/src/cxd56xx/cxd56_clock.c b/arch/arm/src/cxd56xx/cxd56_clock.c index 7a05641f63..98472cb85c 100644 --- a/arch/arm/src/cxd56xx/cxd56_clock.c +++ b/arch/arm/src/cxd56xx/cxd56_clock.c @@ -77,10 +77,6 @@ #define APDID_HPADC 12 #define APDID_LPADC 13 -/* Compiler hint shortcut */ - -#define __unused __attribute__((unused)) - #define ALIGNUP(v, a) (((v) + ((a) - 1)) & ~((a) - 1)) #define TILESIZESHIT 17 #define TILESIZE (1 << TILESIZESHIT) @@ -133,11 +129,11 @@ static void cxd56_img_clock_enable(void); static void cxd56_img_clock_disable(void); static void cxd56_scu_clock_ctrl(uint32_t block, uint32_t intr, int on); static void cxd56_scu_peri_clock_enable(FAR const struct scu_peripheral *p) - __unused; + unused_code; static void cxd56_scu_peri_clock_disable(FAR const struct scu_peripheral *p) - __unused; + unused_code; static void cxd56_scu_peri_clock_gating(FAR const struct scu_peripheral *p, - int enable) __unused; + int enable) unused_code; /**************************************************************************** * Public Data diff --git a/arch/arm/src/cxd56xx/cxd56_farapi.c b/arch/arm/src/cxd56xx/cxd56_farapi.c index bf7cf986c0..aaddaa83c1 100644 --- a/arch/arm/src/cxd56xx/cxd56_farapi.c +++ b/arch/arm/src/cxd56xx/cxd56_farapi.c @@ -182,7 +182,7 @@ static int cxd56_farapidonehandler(int cpuid, int protoid, * Public Functions ****************************************************************************/ -__attribute__((used)) +unused_code void farapi_main(int id, void *arg, struct modulelist_s *mlist) { struct farmsg_s msg; diff --git a/arch/arm/src/cxd56xx/cxd56_scufifo.c b/arch/arm/src/cxd56xx/cxd56_scufifo.c index 90e86919cf..e792abfc82 100644 --- a/arch/arm/src/cxd56xx/cxd56_scufifo.c +++ b/arch/arm/src/cxd56xx/cxd56_scufifo.c @@ -43,8 +43,6 @@ #define FIFOMEMSIZE 40960 -#define __unused __attribute__((unused)) - /**************************************************************************** * Private Types ****************************************************************************/ diff --git a/arch/arm/src/cxd56xx/cxd56_spi.c b/arch/arm/src/cxd56xx/cxd56_spi.c index f8fbd12abe..110a92e1f2 100644 --- a/arch/arm/src/cxd56xx/cxd56_spi.c +++ b/arch/arm/src/cxd56xx/cxd56_spi.c @@ -57,14 +57,6 @@ #ifdef CONFIG_CXD56_SPI -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifndef __unused -#define __unused __attribute__((unused)) -#endif - /**************************************************************************** * Private Types ****************************************************************************/ @@ -110,9 +102,9 @@ static inline void spi_putreg(FAR struct cxd56_spidev_s *priv, /* DMA support */ #ifdef CONFIG_CXD56_DMAC -static void __unused spi_dmaexchange(FAR struct spi_dev_s *dev, - FAR const void *txbuffer, - FAR void *rxbuffer, size_t nwords); +static void unused_code spi_dmaexchange(FAR struct spi_dev_s *dev, + FAR const void *txbuffer, + FAR void *rxbuffer, size_t nwords); static void spi_dmatrxwait(FAR struct cxd56_spidev_s *priv); static void spi_dmatxcallback(DMA_HANDLE handle, uint8_t status, void *data); static void spi_dmarxcallback(DMA_HANDLE handle, uint8_t status, void *data); @@ -134,10 +126,10 @@ static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode); static void spi_setbits(FAR struct spi_dev_s *dev, int nbits); static uint32_t spi_send(FAR struct spi_dev_s *dev, uint32_t wd); -static void __unused spi_exchange(FAR struct spi_dev_s *dev, - FAR const void *txbuffer, - FAR void *rxbuffer, - size_t nwords); +static void unused_code spi_exchange(FAR struct spi_dev_s *dev, + FAR const void *txbuffer, + FAR void *rxbuffer, + size_t nwords); #ifndef CONFIG_SPI_EXCHANGE static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size_t nwords); diff --git a/arch/arm/src/rp2040/rp2040_spi.c b/arch/arm/src/rp2040/rp2040_spi.c index 273bb87a4e..29012c08c5 100644 --- a/arch/arm/src/rp2040/rp2040_spi.c +++ b/arch/arm/src/rp2040/rp2040_spi.c @@ -57,10 +57,6 @@ * Pre-processor Definitions ****************************************************************************/ -#ifndef __unused -#define __unused __attribute__((unused)) -#endif - /* 8 frame FIFOs for both transmit and receive */ #define RP2040_SPI_FIFOSZ 8 @@ -110,9 +106,9 @@ static inline void spi_putreg(FAR struct rp2040_spidev_s *priv, /* DMA support */ #ifdef CONFIG_RP2040_SPI_DMA -static void __unused spi_dmaexchange(FAR struct spi_dev_s *dev, - FAR const void *txbuffer, - FAR void *rxbuffer, size_t nwords); +static void unused_code spi_dmaexchange(FAR struct spi_dev_s *dev, + FAR const void *txbuffer, + FAR void *rxbuffer, size_t nwords); static void spi_dmatxcallback(DMA_HANDLE handle, uint8_t status, void *data); static void spi_dmarxcallback(DMA_HANDLE handle, uint8_t status, void *data); static void spi_dmatxsetup(FAR struct rp2040_spidev_s *priv, @@ -136,10 +132,10 @@ static uint32_t spi_setfrequency(FAR struct spi_dev_s *dev, static void spi_setmode(FAR struct spi_dev_s *dev, enum spi_mode_e mode); static void spi_setbits(FAR struct spi_dev_s *dev, int nbits); static uint32_t spi_send(FAR struct spi_dev_s *dev, uint32_t wd); -static void __unused spi_exchange(FAR struct spi_dev_s *dev, - FAR const void *txbuffer, - FAR void *rxbuffer, - size_t nwords); +static void unused_code spi_exchange(FAR struct spi_dev_s *dev, + FAR const void *txbuffer, + FAR void *rxbuffer, + size_t nwords); #ifndef CONFIG_SPI_EXCHANGE static void spi_sndblock(FAR struct spi_dev_s *dev, FAR const void *buffer, size_t nwords); diff --git a/arch/risc-v/src/bl602/bl602_start.c b/arch/risc-v/src/bl602/bl602_start.c index d6a32c4e87..ebf7ba3152 100644 --- a/arch/risc-v/src/bl602/bl602_start.c +++ b/arch/risc-v/src/bl602/bl602_start.c @@ -76,8 +76,7 @@ uint8_t g_idle_stack[BL602_IDLESTACK_SIZE] * g_boot2_partition_table in linker script */ -static struct boot2_partition_table_s g_boot2_partition_table - __attribute__((used)); +static struct boot2_partition_table_s g_boot2_partition_table unused_data; /**************************************************************************** * Public Data diff --git a/arch/x86_64/src/intel64/up_irq.c b/arch/x86_64/src/intel64/up_irq.c index 102eb1b03f..8e238e63e9 100644 --- a/arch/x86_64/src/intel64/up_irq.c +++ b/arch/x86_64/src/intel64/up_irq.c @@ -329,8 +329,8 @@ static void up_apic_init(void) * ****************************************************************************/ -static int __attribute__((unused)) - legacy_pic_irq_handler(int irq, uint32_t *regs, void *arg) +static int unused_code +legacy_pic_irq_handler(int irq, uint32_t *regs, void *arg) { return 0; } diff --git a/include/nuttx/compiler.h b/include/nuttx/compiler.h index 79e5eed024..0a1c5d2c4c 100644 --- a/include/nuttx/compiler.h +++ b/include/nuttx/compiler.h @@ -147,6 +147,11 @@ # define noinstrument_function __attribute__ ((no_instrument_function)) +/* The unsued code or data */ + +# define unused_code __attribute__((unused)) +# define unused_data __attribute__((unused)) + /* Some versions of GCC have a separate __syslog__ format. * http://mail-index.netbsd.org/source-changes/2015/10/14/msg069435.html * Use it if available. Otherwise, assume __printf__ accepts %m. @@ -404,6 +409,9 @@ # define noinline_function # define noinstrument_function +# define unused_code +# define unused_data + # define printflike(a, b) # define sysloglike(a, b) # define scanflike(a, b) @@ -536,6 +544,8 @@ # define inline_function # define noinline_function # define noinstrument_function +# define unused_code +# define unused_data # define printflike(a, b) # define sysloglike(a, b) # define scanflike(a, b) @@ -641,6 +651,8 @@ # define inline_function # define noinline_function # define noinstrument_function +# define unused_code +# define unused_data # define printflike(a, b) # define sysloglike(a, b) # define scanflike(a, b) @@ -701,6 +713,8 @@ # define inline_function # define noinline_function # define noinstrument_function +# define unused_code +# define unused_data # define printflike(a, b) # define sysloglike(a, b) # define scanflike(a, b) diff --git a/include/nuttx/tree.h b/include/nuttx/tree.h index 5941092809..44bb2e0a16 100644 --- a/include/nuttx/tree.h +++ b/include/nuttx/tree.h @@ -81,7 +81,7 @@ #define SPLAY_ENTRY(type) \ struct \ { \ - struct type *spe_left; /* left element */ \ + struct type *spe_left; /* left element */ \ struct type *spe_right; /* right element */ \ } @@ -516,7 +516,7 @@ while (0) #define RB_PROTOTYPE(name, type, field, cmp) \ RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) #define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp, __attribute__((__unused__)) static) + RB_PROTOTYPE_INTERNAL(name, type, field, cmp, unused_code static) #define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *); \ @@ -536,7 +536,7 @@ while (0) RB_GENERATE_INTERNAL(name, type, field, cmp,) #define RB_GENERATE_STATIC(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp, __attribute__((__unused__)) static) + RB_GENERATE_INTERNAL(name, type, field, cmp, unused_code static) #define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ attr void name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \