From 592a5b0b91f3b3941c906e1b9d84bfb0bb0d46dd Mon Sep 17 00:00:00 2001 From: Damjan Marion Date: Mon, 10 Feb 2025 20:34:47 +0100 Subject: [PATCH] build: replace __FUNCTION__ with C11 __func__ Type: improvement Change-Id: I6cf7aaf42e8c0738d5b677fa66c99f071c1526bb Signed-off-by: Damjan Marion --- src/plugins/quic/quic_crypto.c | 9 +++------ src/plugins/tlspicotls/pico_vpp_crypto.c | 6 ++---- src/vlib/main.c | 2 +- src/vlib/threads.c | 8 ++++---- src/vlib/threads.h | 7 +++++-- src/vppinfra/clib_error.h | 2 +- src/vppinfra/elog.h | 12 ++++++------ src/vppinfra/error_bootstrap.h | 2 +- src/vppinfra/mem.h | 2 +- src/vppinfra/string.c | 2 +- 10 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/plugins/quic/quic_crypto.c b/src/plugins/quic/quic_crypto.c index 9e2c915daaa..4e11eff2431 100644 --- a/src/plugins/quic/quic_crypto.c +++ b/src/plugins/quic/quic_crypto.c @@ -248,8 +248,7 @@ quic_crypto_decrypt_packet (quic_ctx_t *qctx, quic_rx_packet_ctx_t *pctx) pctx->packet.octets.len - aead_off, pn, pctx->packet.octets.base, aead_off)) == SIZE_MAX) { - fprintf (stderr, "%s: aead decryption failure (pn: %d)\n", __FUNCTION__, - pn); + fprintf (stderr, "%s: aead decryption failure (pn: %d)\n", __func__, pn); return; } @@ -349,8 +348,7 @@ quic_crypto_cipher_setup_crypto (ptls_cipher_context_t *_ctx, int is_enc, } else { - QUIC_DBG (1, "%s, Invalid crypto cipher : ", __FUNCTION__, - _ctx->algo->name); + QUIC_DBG (1, "%s, Invalid crypto cipher : ", __func__, _ctx->algo->name); assert (0); } @@ -405,8 +403,7 @@ quic_crypto_aead_setup_crypto (ptls_aead_context_t *_ctx, int is_enc, } else { - QUIC_DBG (1, "%s, invalied aead cipher %s", __FUNCTION__, - _ctx->algo->name); + QUIC_DBG (1, "%s, invalied aead cipher %s", __func__, _ctx->algo->name); assert (0); } diff --git a/src/plugins/tlspicotls/pico_vpp_crypto.c b/src/plugins/tlspicotls/pico_vpp_crypto.c index 3d28d50b352..e8e4a875e33 100644 --- a/src/plugins/tlspicotls/pico_vpp_crypto.c +++ b/src/plugins/tlspicotls/pico_vpp_crypto.c @@ -107,8 +107,7 @@ ptls_vpp_crypto_cipher_setup_crypto (ptls_cipher_context_t * _ctx, int is_enc, } else { - TLS_DBG (1, "%s, Invalid crypto cipher : ", __FUNCTION__, - _ctx->algo->name); + TLS_DBG (1, "%s, Invalid crypto cipher : ", __func__, _ctx->algo->name); assert (0); } @@ -226,8 +225,7 @@ ptls_vpp_crypto_aead_setup_crypto (ptls_aead_context_t *_ctx, int is_enc, } else { - TLS_DBG (1, "%s, invalied aead cipher %s", __FUNCTION__, - _ctx->algo->name); + TLS_DBG (1, "%s, invalied aead cipher %s", __func__, _ctx->algo->name); return -1; } diff --git a/src/vlib/main.c b/src/vlib/main.c index a2f833711ab..731e788d30d 100644 --- a/src/vlib/main.c +++ b/src/vlib/main.c @@ -972,7 +972,7 @@ dispatch_node (vlib_main_t * vm, { ELOG_TYPE_DECLARE (e) = { - .function = (char *) __FUNCTION__, + .function = (char *) __func__, .format = "%s vector length %d, switching to %s", .format_args = "T4i4t4", .n_enum_strings = 2, diff --git a/src/vlib/threads.c b/src/vlib/threads.c index fa8d949d549..9dce1b8c8bd 100644 --- a/src/vlib/threads.c +++ b/src/vlib/threads.c @@ -1304,7 +1304,7 @@ vlib_worker_thread_initial_barrier_sync_and_release (vlib_main_t * vm) { if ((now = vlib_time_now (vm)) > deadline) { - fformat (stderr, "%s: worker thread deadlock\n", __FUNCTION__); + fformat (stderr, "%s: worker thread deadlock\n", __func__); os_panic (); } CLIB_PAUSE (); @@ -1409,7 +1409,7 @@ vlib_worker_thread_barrier_sync_int (vlib_main_t * vm, const char *func_name) { if ((now = vlib_time_now (vm)) > deadline) { - fformat (stderr, "%s: worker thread deadlock\n", __FUNCTION__); + fformat (stderr, "%s: worker thread deadlock\n", __func__); os_panic (); } } @@ -1485,7 +1485,7 @@ vlib_worker_thread_barrier_release (vlib_main_t * vm) { if ((now = vlib_time_now (vm)) > deadline) { - fformat (stderr, "%s: worker thread deadlock\n", __FUNCTION__); + fformat (stderr, "%s: worker thread deadlock\n", __func__); os_panic (); } } @@ -1502,7 +1502,7 @@ vlib_worker_thread_barrier_release (vlib_main_t * vm) if ((now = vlib_time_now (vm)) > deadline) { fformat (stderr, "%s: worker thread refork deadlock\n", - __FUNCTION__); + __func__); os_panic (); } } diff --git a/src/vlib/threads.h b/src/vlib/threads.h index c671aa78c39..da2c41fec73 100644 --- a/src/vlib/threads.h +++ b/src/vlib/threads.h @@ -166,7 +166,10 @@ u32 vlib_frame_queue_main_init (u32 node_index, u32 frame_queue_nelts); #define BARRIER_SYNC_TIMEOUT (1.0) #endif -#define vlib_worker_thread_barrier_sync(X) {vlib_worker_thread_barrier_sync_int(X, __FUNCTION__);} +#define vlib_worker_thread_barrier_sync(X) \ + { \ + vlib_worker_thread_barrier_sync_int (X, __func__); \ + } void vlib_worker_thread_barrier_sync_int (vlib_main_t * vm, const char *func_name); @@ -195,7 +198,7 @@ vlib_smp_unsafe_warning (void) if (CLIB_DEBUG > 0) { if (vlib_get_thread_index ()) - fformat (stderr, "%s: SMP unsafe warning...\n", __FUNCTION__); + fformat (stderr, "%s: SMP unsafe warning...\n", __func__); } } diff --git a/src/vppinfra/clib_error.h b/src/vppinfra/clib_error.h index 45f18eb1fe4..5db1a5e3440 100644 --- a/src/vppinfra/clib_error.h +++ b/src/vppinfra/clib_error.h @@ -23,7 +23,7 @@ typedef struct /* Error message. */ u8 *what; - /* Where error occurred (e.g. __FUNCTION__ __LINE__) */ + /* Where error occurred (e.g. __func__ __LINE__) */ const u8 *where; uword flags; diff --git a/src/vppinfra/elog.h b/src/vppinfra/elog.h index d0825bdd5b2..6a66319148d 100644 --- a/src/vppinfra/elog.h +++ b/src/vppinfra/elog.h @@ -444,21 +444,21 @@ elog_data_inline (elog_main_t * em, elog_event_type_t * type, #define ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt,func) \ { .format = fmt, .function = func, } -#define ELOG_TYPE_INIT(fmt) \ - ELOG_TYPE_INIT_FORMAT_AND_FUNCTION(fmt,(char *) __FUNCTION__) +#define ELOG_TYPE_INIT(fmt) \ + ELOG_TYPE_INIT_FORMAT_AND_FUNCTION (fmt, (char *) __func__) #define ELOG_TYPE_DECLARE_HELPER(f,fmt,func) \ static elog_event_type_t __ELOG_TYPE_VAR(f) = \ ELOG_TYPE_INIT_FORMAT_AND_FUNCTION (fmt, func) -#define ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f,fmt) \ - ELOG_TYPE_DECLARE_HELPER (f, fmt, (char *) __FUNCTION__) +#define ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f, fmt) \ + ELOG_TYPE_DECLARE_HELPER (f, fmt, (char *) __func__) #define ELOG_TYPE_DECLARE_FORMAT(f,fmt) \ ELOG_TYPE_DECLARE_HELPER (f, fmt, 0) -/* Shorthands with and without __FUNCTION__. - D for decimal; X for hex. F for __FUNCTION__. */ +/* Shorthands with and without __func__. + D for decimal; X for hex. F for __func__. */ #define ELOG_TYPE(f,fmt) ELOG_TYPE_DECLARE_FORMAT_AND_FUNCTION(f,fmt) #define ELOG_TYPE_D(f) ELOG_TYPE_DECLARE_FORMAT (f, #f " %d") #define ELOG_TYPE_X(f) ELOG_TYPE_DECLARE_FORMAT (f, #f " 0x%x") diff --git a/src/vppinfra/error_bootstrap.h b/src/vppinfra/error_bootstrap.h index ae23d1bcca8..d3eed1b83ae 100644 --- a/src/vppinfra/error_bootstrap.h +++ b/src/vppinfra/error_bootstrap.h @@ -53,7 +53,7 @@ enum }; /* Current function name. Need (char *) cast to silence gcc4 pointer signedness warning. */ -#define clib_error_function ((char *) __FUNCTION__) +#define clib_error_function ((char *) __func__) #ifndef CLIB_ASSERT_ENABLE #define CLIB_ASSERT_ENABLE (CLIB_DEBUG > 0) diff --git a/src/vppinfra/mem.h b/src/vppinfra/mem.h index 6211bb51f0a..893978081d0 100644 --- a/src/vppinfra/mem.h +++ b/src/vppinfra/mem.h @@ -259,7 +259,7 @@ uword clib_mem_size (void *p); void clib_mem_free_s (void *p); /* Memory allocator which panics when it fails. - Use macro so that clib_panic macro can expand __FUNCTION__ and __LINE__. */ + Use macro so that clib_panic macro can expand __func__ and __LINE__. */ #define clib_mem_alloc_aligned_no_fail(size,align) \ ({ \ uword _clib_mem_alloc_size = (size); \ diff --git a/src/vppinfra/string.c b/src/vppinfra/string.c index ea9480875a5..aedaf428a31 100644 --- a/src/vppinfra/string.c +++ b/src/vppinfra/string.c @@ -94,7 +94,7 @@ clib_memswap (void *_a, void *_b, uword bytes) __clib_export void clib_c11_violation (const char *s) { - _clib_error (CLIB_ERROR_WARNING, (char *) __FUNCTION__, 0, (char *) s); + _clib_error (CLIB_ERROR_WARNING, (char *) __func__, 0, (char *) s); } /** -- 2.16.6