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

Re-enable -Wunused-function for clang #83830

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
1 change: 0 additions & 1 deletion cmake/compiler/clang/compiler_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ check_set_compiler_property(PROPERTY warning_extended
-Wno-sometimes-uninitialized
-Wno-self-assign
-Wno-address-of-packed-member
-Wno-unused-function
-Wno-initializer-overrides
-Wno-section
-Wno-unused-variable
Expand Down
5 changes: 0 additions & 5 deletions drivers/dma/dma_emul.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,6 @@ static void dma_emul_work_handler(struct k_work *work);

LOG_MODULE_REGISTER(dma_emul, CONFIG_DMA_LOG_LEVEL);

static inline bool dma_emul_xfer_is_error_status(int status)
{
return status < 0;
}

static inline const char *const dma_emul_channel_state_to_string(enum dma_emul_channel_state state)
{
switch (state) {
Expand Down
42 changes: 0 additions & 42 deletions drivers/gpio/gpio_pca95xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,38 +117,6 @@ struct gpio_pca95xx_drv_data {
#endif
};

static int read_port_reg(const struct device *dev, uint8_t reg, uint8_t pin,
uint16_t *cache, uint16_t *buf)
{
const struct gpio_pca95xx_config * const config = dev->config;
uint8_t b_buf;
int ret;

if (pin >= 8) {
reg++;
}

ret = i2c_reg_read_byte_dt(&config->bus, reg, &b_buf);
if (ret != 0) {
LOG_ERR("PCA95XX[0x%X]: error reading register 0x%X (%d)",
config->bus.addr, reg, ret);
return ret;
}

if (pin < 8) {
((uint8_t *)cache)[LOW_BYTE_LE16_IDX] = b_buf;
} else {
((uint8_t *)cache)[HIGH_BYTE_LE16_IDX] = b_buf;
}

*buf = *cache;

LOG_DBG("PCA95XX[0x%X]: Read: REG[0x%X] = 0x%X",
config->bus.addr, reg, b_buf);

return 0;
}

/**
* @brief Read both port 0 and port 1 registers of certain register function.
*
Expand Down Expand Up @@ -253,16 +221,6 @@ static int write_port_regs(const struct device *dev, uint8_t reg,
return ret;
}

static inline int update_input_reg(const struct device *dev, uint8_t pin,
uint16_t *buf)
{
struct gpio_pca95xx_drv_data * const drv_data =
(struct gpio_pca95xx_drv_data * const)dev->data;

return read_port_reg(dev, REG_INPUT_PORT0, pin,
&drv_data->reg_cache.input, buf);
}

static inline int update_input_regs(const struct device *dev, uint16_t *buf)
{
struct gpio_pca95xx_drv_data * const drv_data =
Expand Down
14 changes: 0 additions & 14 deletions drivers/sensor/st/ism330dhcx/ism330dhcx.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,6 @@ static int ism330dhcx_gyro_range_to_fs_val(int32_t range)
return -EINVAL;
}

static inline int ism330dhcx_reboot(const struct device *dev)
{
struct ism330dhcx_data *data = dev->data;

if (ism330dhcx_boot_set(data->ctx, 1) < 0) {
return -EIO;
}

/* Wait sensor turn-on time as per datasheet */
k_busy_wait(35 * USEC_PER_MSEC);

return 0;
}

static int ism330dhcx_accel_set_fs_raw(const struct device *dev, uint8_t fs)
{
struct ism330dhcx_data *data = dev->data;
Expand Down
296 changes: 296 additions & 0 deletions include/zephyr/toolchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,302 @@
#define TOOLCHAIN_IGNORE_WSHADOW_END
#endif

/**
* @def TOOLCHAIN_PRAGMA
* @brief Helper for using pragma in macros.
*/
#ifdef TOOLCHAIN_HAS_PRAGMA_DIAG
#define TOOLCHAIN_PRAGMA(x) _Pragma(#x)
#else
#define TOOLCHAIN_PRAGMA(x)
#endif

/**
* @def TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER
* @brief Toolchain-specific warning for taking the address of a packed member.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER
#define TOOLCHAIN_WARNING_ADDRESS_OF_PACKED_MEMBER
#endif

/**
* @def TOOLCHAIN_WARNING_ALLOC_SIZE_LARGER_THAN
* @brief Toolchain-specific warning for allocations larger than a given size.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_ALLOC_SIZE_LARGER_THAN
#define TOOLCHAIN_WARNING_ALLOC_SIZE_LARGER_THAN
#endif

/**
* @def TOOLCHAIN_WARNING_ARRAY_BOUNDS
* @brief Toolchain-specific warning for array bounds violations.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_ARRAY_BOUNDS
#define TOOLCHAIN_WARNING_ARRAY_BOUNDS
#endif

/**
* @def TOOLCHAIN_WARNING_ATTRIBUTES
* @brief Toolchain-specific warning for unknown attributes.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_ATTRIBUTES
#define TOOLCHAIN_WARNING_ATTRIBUTES
#endif

/**
* @def TOOLCHAIN_WARNING_DANGLING_POINTER
* @brief Toolchain-specific warning for dangling pointers.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_DANGLING_POINTER
#define TOOLCHAIN_WARNING_DANGLING_POINTER
#endif

/**
* @def TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR
* @brief Toolchain-specific warning for deleting a pointer to an object
* with a non-virtual destructor.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR
#define TOOLCHAIN_WARNING_DELETE_NON_VIRTUAL_DTOR
#endif

/**
* @def TOOLCHAIN_WARNING_EXTRA
* @brief Toolchain-specific warning for extra warnings.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_EXTRA
#define TOOLCHAIN_WARNING_EXTRA
#endif

/**
* @def TOOLCHAIN_WARNING_FORMAT_TRUNCATION
* @brief Toolchain-specific warning for format truncation.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_FORMAT_TRUNCATION
#define TOOLCHAIN_WARNING_FORMAT_TRUNCATION
#endif

/**
* @def TOOLCHAIN_WARNING_INFINITE_RECURSION
* @brief Toolchain-specific warning for infinite recursion.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_INFINITE_RECURSION
#define TOOLCHAIN_WARNING_INFINITE_RECURSION
#endif

/**
* @def TOOLCHAIN_WARNING_INTEGER_OVERFLOW
* @brief Toolchain-specific warning for integer overflow.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_INTEGER_OVERFLOW
#define TOOLCHAIN_WARNING_INTEGER_OVERFLOW
#endif

/**
* @def TOOLCHAIN_WARNING_NONNULL
* @brief Toolchain-specific warning for null pointer arguments to functions marked with "nonnull".
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_NONNULL
#define TOOLCHAIN_WARNING_NONNULL
#endif

/**
* @def TOOLCHAIN_WARNING_OVERFLOW
* @brief Toolchain-specific warning for integer overflow.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_OVERFLOW
#define TOOLCHAIN_WARNING_OVERFLOW
#endif

/**
* @def TOOLCHAIN_WARNING_POINTER_ARITH
* @brief Toolchain-specific warning for pointer arithmetic.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_POINTER_ARITH
#define TOOLCHAIN_WARNING_POINTER_ARITH
#endif

/**
* @def TOOLCHAIN_WARNING_PRAGMAS
* @brief Toolchain-specific warning for unknown pragmas.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_PRAGMAS
#define TOOLCHAIN_WARNING_PRAGMAS
#endif

/**
* @def TOOLCHAIN_WARNING_SHADOW
* @brief Toolchain-specific warning for shadow variables.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_SHADOW
#define TOOLCHAIN_WARNING_SHADOW
#endif

/**
* @def TOOLCHAIN_WARNING_SIZEOF_ARRAY_DECAY
* @brief Toolchain-specific warning for sizeof array decay.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_SIZEOF_ARRAY_DECAY
#define TOOLCHAIN_WARNING_SIZEOF_ARRAY_DECAY
#endif

/**
* @def TOOLCHAIN_WARNING_STRINGOP_OVERFLOW
* @brief Toolchain-specific warning for stringop overflow.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_STRINGOP_OVERFLOW
#define TOOLCHAIN_WARNING_STRINGOP_OVERFLOW
#endif

/**
* @def TOOLCHAIN_WARNING_STRINGOP_TRUNCATION
* @brief Toolchain-specific warning for stringop truncation.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_STRINGOP_TRUNCATION
#define TOOLCHAIN_WARNING_STRINGOP_TRUNCATION
#endif

/**
* @def TOOLCHAIN_WARNING_UNUSED_FUNCTION
* @brief Toolchain-specific warning for unused function.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_UNUSED_FUNCTION
#define TOOLCHAIN_WARNING_UNUSED_FUNCTION
#endif

/**
* @def TOOLCHAIN_WARNING_UNUSED_LABEL
* @brief Toolchain-specific warning for unused labels.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_UNUSED_LABEL
#define TOOLCHAIN_WARNING_UNUSED_LABEL
#endif

/**
* @def TOOLCHAIN_WARNING_UNUSED_VARIABLE
* @brief Toolchain-specific warning for unused variables.
*
* Use this as an argument to the @ref TOOLCHAIN_DISABLE_WARNING and
* @ref TOOLCHAIN_ENABLE_WARNING family of macros.
*/
#ifndef TOOLCHAIN_WARNING_UNUSED_VARIABLE
#define TOOLCHAIN_WARNING_UNUSED_VARIABLE
#endif

/**
* @def TOOLCHAIN_DISABLE_WARNING
* @brief Disable the specified compiler warning for all compilers.
*/
#ifndef TOOLCHAIN_DISABLE_WARNING
#define TOOLCHAIN_DISABLE_WARNING(warning)
#endif

/**
* @def TOOLCHAIN_ENABLE_WARNING
* @brief Re-enable the specified compiler warning for all compilers.
*
* Can only be used after a call to @ref TOOLCHAIN_DISABLE_WARNING.
*/
#ifndef TOOLCHAIN_ENABLE_WARNING
#define TOOLCHAIN_ENABLE_WARNING(warning)
#endif

/**
* @def TOOLCHAIN_DISABLE_CLANG_WARNING
* @brief Disable the specified compiler warning for clang.
*/
#ifndef TOOLCHAIN_DISABLE_CLANG_WARNING
#define TOOLCHAIN_DISABLE_CLANG_WARNING(warning)
#endif

/**
* @def TOOLCHAIN_ENABLE_CLANG_WARNING
* @brief Re-enable the specified compiler warning for clang.
*
* Can only be used after a call to @ref TOOLCHAIN_DISABLE_CLANG_WARNING.
*/
#ifndef TOOLCHAIN_ENABLE_CLANG_WARNING
#define TOOLCHAIN_ENABLE_CLANG_WARNING(warning)
#endif

/**
* @def TOOLCHAIN_DISABLE_GCC_WARNING
* @brief Disable the specified compiler warning for gcc.
*/
#ifndef TOOLCHAIN_DISABLE_GCC_WARNING
#define TOOLCHAIN_DISABLE_GCC_WARNING(warning)
#endif

/**
* @def TOOLCHAIN_ENABLE_GCC_WARNING
* @brief Re-enable the specified compiler warning for gcc.
*
* Can only be used after a call to @ref TOOLCHAIN_DISABLE_GCC_WARNING.
*/
#ifndef TOOLCHAIN_ENABLE_GCC_WARNING
#define TOOLCHAIN_ENABLE_GCC_WARNING(warning)
#endif

/*
* Ensure that __BYTE_ORDER__ and related preprocessor definitions are defined,
* and that they match the Kconfig option that is used in the code itself to
Expand Down
Loading
Loading