When building on FreeBSD, errors are reported in the base code by the lock checker (-Wthread-safety). For example:
../drivers/net/intel/ixgbe/base/ixgbe_osdep.c:42:1: error: mutex 'lock->mutex' is still held at the end of function [-Werror,-Wthread-safety-analysis] 42 | } | ^ These errors are due to the checker not recognising the lock wrapper functions. We can avoid these errors by converting these functions into macros. While converting the lock macros, we can also convert the memory allocation functions too, which allows us to remove the osdep.c file entirely from the build. Fixes: 30b19d1b5c43 ("net/ixgbe/base: add definitions for E610") Cc: sta...@dpdk.org Signed-off-by: Bruce Richardson <bruce.richard...@intel.com> --- drivers/net/intel/ixgbe/base/ixgbe_osdep.c | 47 ---------------------- drivers/net/intel/ixgbe/base/ixgbe_osdep.h | 18 +++++---- drivers/net/intel/ixgbe/base/meson.build | 1 - 3 files changed, 10 insertions(+), 56 deletions(-) delete mode 100644 drivers/net/intel/ixgbe/base/ixgbe_osdep.c diff --git a/drivers/net/intel/ixgbe/base/ixgbe_osdep.c b/drivers/net/intel/ixgbe/base/ixgbe_osdep.c deleted file mode 100644 index d3d7e8e116..0000000000 --- a/drivers/net/intel/ixgbe/base/ixgbe_osdep.c +++ /dev/null @@ -1,47 +0,0 @@ -/* SPDX-License-Identifier: BSD-3-Clause - * Copyright(c) 2024 Intel Corporation - */ - -#include <stdlib.h> - -#include <rte_common.h> - -#include "ixgbe_osdep.h" - -void * -ixgbe_calloc(struct ixgbe_hw __rte_unused *hw, size_t count, size_t size) -{ - return malloc(count * size); -} - -void * -ixgbe_malloc(struct ixgbe_hw __rte_unused *hw, size_t size) -{ - return malloc(size); -} - -void -ixgbe_free(struct ixgbe_hw __rte_unused *hw, void *addr) -{ - free(addr); -} - -void ixgbe_init_lock(struct ixgbe_lock *lock) -{ - pthread_mutex_init(&lock->mutex, NULL); -} - -void ixgbe_destroy_lock(struct ixgbe_lock *lock) -{ - pthread_mutex_destroy(&lock->mutex); -} - -void ixgbe_acquire_lock(struct ixgbe_lock *lock) -{ - pthread_mutex_lock(&lock->mutex); -} - -void ixgbe_release_lock(struct ixgbe_lock *lock) -{ - pthread_mutex_unlock(&lock->mutex); -} diff --git a/drivers/net/intel/ixgbe/base/ixgbe_osdep.h b/drivers/net/intel/ixgbe/base/ixgbe_osdep.h index 398c38bffd..53d0422193 100644 --- a/drivers/net/intel/ixgbe/base/ixgbe_osdep.h +++ b/drivers/net/intel/ixgbe/base/ixgbe_osdep.h @@ -11,6 +11,8 @@ #include <stdio.h> #include <stdarg.h> #include <stdbool.h> +#include <malloc.h> + #include <rte_common.h> #include <rte_debug.h> #include <rte_cycles.h> @@ -50,7 +52,7 @@ #define false 0 #define true 1 #ifndef RTE_EXEC_ENV_WINDOWS -#define min(a,b) RTE_MIN(a,b) +#define min(a,b) RTE_MIN(a,b) #endif #define EWARN(hw, S, ...) DEBUGOUT1(S, ##__VA_ARGS__) @@ -163,13 +165,13 @@ struct ixgbe_lock { pthread_mutex_t mutex; }; -void *ixgbe_calloc(struct ixgbe_hw *hw, size_t count, size_t size); -void *ixgbe_malloc(struct ixgbe_hw *hw, size_t size); -void ixgbe_free(struct ixgbe_hw *hw, void *addr); +#define ixgbe_calloc(hw, c, s) ((void)hw, calloc(c, s)) +#define ixgbe_malloc(hw, s) ((void)hw, malloc(s)) +#define ixgbe_free(hw, a) ((void)hw, free(a)) -void ixgbe_init_lock(struct ixgbe_lock *lock); -void ixgbe_destroy_lock(struct ixgbe_lock *lock); -void ixgbe_acquire_lock(struct ixgbe_lock *lock); -void ixgbe_release_lock(struct ixgbe_lock *lock); +#define ixgbe_init_lock(lock) pthread_mutex_init(&(lock)->mutex, NULL) +#define ixgbe_destroy_lock(lock) pthread_mutex_destroy(&(lock)->mutex) +#define ixgbe_acquire_lock(lock) pthread_mutex_lock(&(lock)->mutex) +#define ixgbe_release_lock(lock) pthread_mutex_unlock(&(lock)->mutex) #endif /* _IXGBE_OS_H_ */ diff --git a/drivers/net/intel/ixgbe/base/meson.build b/drivers/net/intel/ixgbe/base/meson.build index 64e0bfd7be..2af8a55e92 100644 --- a/drivers/net/intel/ixgbe/base/meson.build +++ b/drivers/net/intel/ixgbe/base/meson.build @@ -12,7 +12,6 @@ sources = [ 'ixgbe_e610.c', 'ixgbe_hv_vf.c', 'ixgbe_mbx.c', - 'ixgbe_osdep.c', 'ixgbe_phy.c', 'ixgbe_vf.c', 'ixgbe_x540.c', -- 2.45.2