From f31c73a11d3500966b724110b0aaa8a2ef5c3cdb Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Thu, 21 Oct 2021 16:09:34 +0000 Subject: [PATCH] [core] Add type checking for SWITCH_CHANNEL_SESSION_LOG and SWITCH_CHANNEL_UUID_LOG macros. --- src/include/switch_types.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/include/switch_types.h b/src/include/switch_types.h index a4e4059176..bb06cfa0ea 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1329,13 +1329,17 @@ typedef enum { } switch_core_session_message_flag_enum_t; typedef uint32_t switch_core_session_message_flag_t; +typedef struct switch_core_session switch_core_session_t; +static inline switch_core_session_t *switch_core_session_type_check(switch_core_session_t *session) { return session; } +static inline const char *switch_const_char_type_check(const char *str) { return str; } + #define SWITCH_CHANNEL_LOG SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, NULL #define SWITCH_CHANNEL_LOG_CLEAN SWITCH_CHANNEL_ID_LOG_CLEAN, __FILE__, __SWITCH_FUNC__, __LINE__, NULL #define SWITCH_CHANNEL_SESSION_LOG_CLEAN(x) SWITCH_CHANNEL_ID_LOG_CLEAN, __FILE__, __SWITCH_FUNC__, __LINE__, switch_core_session_get_uuid((x)) #define SWITCH_CHANNEL_EVENT SWITCH_CHANNEL_ID_EVENT, __FILE__, __SWITCH_FUNC__, __LINE__, NULL -#define SWITCH_CHANNEL_SESSION_LOG(x) SWITCH_CHANNEL_ID_SESSION, __FILE__, __SWITCH_FUNC__, __LINE__, (const char*)(x) +#define SWITCH_CHANNEL_SESSION_LOG(x) SWITCH_CHANNEL_ID_SESSION, __FILE__, __SWITCH_FUNC__, __LINE__, (const char*)switch_core_session_type_check(x) #define SWITCH_CHANNEL_CHANNEL_LOG(x) SWITCH_CHANNEL_ID_SESSION, __FILE__, __SWITCH_FUNC__, __LINE__, (const char*)switch_channel_get_session(x) -#define SWITCH_CHANNEL_UUID_LOG(x) SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, (x) +#define SWITCH_CHANNEL_UUID_LOG(x) SWITCH_CHANNEL_ID_LOG, __FILE__, __SWITCH_FUNC__, __LINE__, switch_const_char_type_check(x) typedef enum { CCS_DOWN, @@ -2336,7 +2340,6 @@ typedef struct switch_rtcp_frame switch_rtcp_frame_t; typedef struct switch_channel switch_channel_t; typedef struct switch_sql_queue_manager switch_sql_queue_manager_t; typedef struct switch_file_handle switch_file_handle_t; -typedef struct switch_core_session switch_core_session_t; typedef struct switch_caller_profile switch_caller_profile_t; typedef struct switch_caller_extension switch_caller_extension_t; typedef struct switch_caller_application switch_caller_application_t;