From ceafc84ca061d0a373714d1ebe0b3439e1e9d987 Mon Sep 17 00:00:00 2001 From: Michael Jerris Date: Tue, 13 Feb 2007 21:03:06 +0000 Subject: [PATCH] constify some arguments to switch_console_printf and switch_cut_path and remove improper casts for the consumers of those functions. git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4241 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/include/switch_console.h | 2 +- src/include/switch_utils.h | 2 +- src/switch_channel.c | 14 +++++++------- src/switch_console.c | 6 +++--- src/switch_core.c | 10 +++++----- src/switch_log.c | 2 +- src/switch_utils.c | 8 ++++---- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/include/switch_console.h b/src/include/switch_console.h index f49a5677f7..e7a2d271e7 100644 --- a/src/include/switch_console.h +++ b/src/include/switch_console.h @@ -62,7 +62,7 @@ SWITCH_DECLARE(void) switch_console_loop(void); /*! \brief A method akin to printf that allows you to redirect output to a specific console "channel" */ -SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, char *fmt, ...) PRINTF_FUNCTION(5,6); +SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line, const char *fmt, ...) PRINTF_FUNCTION(5,6); /*! \brief A method akin to printf for dealing with api streams diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index 0a4fa62277..f45c75e895 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -274,7 +274,7 @@ SWITCH_DECLARE(int) switch_socket_waitfor(switch_pollfd_t *poll, int ms); \brief Create a pointer to the file name in a given file path eliminating the directory name \return the pointer to the next character after the final / or \\ characters */ -SWITCH_DECLARE(char *) switch_cut_path(char *in); +SWITCH_DECLARE(const char *) switch_cut_path(const char *in); #define switch_clean_re(re) if (re) {\ pcre_free(re);\ diff --git a/src/switch_channel.c b/src/switch_channel.c index 414580a125..0ea00fa30f 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -612,7 +612,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c if (state > CS_RING) { switch_channel_presence(channel, "unknown", (char*)state_names[state]); } - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]); @@ -645,7 +645,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_c } } else { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_WARNING, "%s Invalid State Change %s -> %s\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_WARNING, "%s Invalid State Change %s -> %s\n", channel->name, state_names[last_state], state_names[state]); @@ -958,7 +958,7 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_hangup(switch_chan switch_channel_state_t last_state = channel->state; channel->state = CS_HANGUP; channel->hangup_cause = hangup_cause; - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Hangup %s [%s] [%s]\n", channel->name, state_names[last_state], switch_channel_cause2str(channel->hangup_cause)); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_HANGUP) == SWITCH_STATUS_SUCCESS) { @@ -985,7 +985,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_ring_ready(switch_ch int line) { if (!switch_channel_test_flag(channel, CF_RING_READY)) { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name); switch_channel_set_flag(channel, CF_RING_READY); return SWITCH_STATUS_SUCCESS; } @@ -1008,7 +1008,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_pre_answered(switch_ char *uuid; switch_core_session_t *other_session; - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Pre-Answer %s!\n", channel->name); switch_channel_set_flag(channel, CF_EARLY_MEDIA); switch_channel_set_variable(channel, "endpoint_disposition", "EARLY MEDIA"); if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_PROGRESS) == SWITCH_STATUS_SUCCESS) { @@ -1091,7 +1091,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_ring_ready(switch_channel status = switch_core_session_message_send(uuid, &msg); if (status == SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name); } return status; @@ -1138,7 +1138,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_mark_answered(switch_chan } switch_channel_set_variable(channel, "endpoint_disposition", "ANSWER"); - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n", channel->name); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n", channel->name); return SWITCH_STATUS_SUCCESS; } diff --git a/src/switch_console.c b/src/switch_console.c index 1752b24a86..f1d30ea218 100644 --- a/src/switch_console.c +++ b/src/switch_console.c @@ -132,14 +132,14 @@ static int switch_console_process(char *cmd) return 1; } -SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, char *file, const char *func, int line, - char *fmt, ...) +SWITCH_DECLARE(void) switch_console_printf(switch_text_channel_t channel, const char *file, const char *func, int line, + const char *fmt, ...) { char *data = NULL; int ret = 0; va_list ap; FILE *handle; - char *filep = switch_cut_path(file); + const char *filep = switch_cut_path(file); va_start(ap, fmt); diff --git a/src/switch_core.c b/src/switch_core.c index a43d52fe91..4d73b4acce 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -589,13 +589,13 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(switch_core_sessio if (switch_test_flag(session, SSF_DESTROYED)) { status = SWITCH_STATUS_FALSE; #ifdef SWITCH_DEBUG_RWLOCKS - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s Read lock FAIL\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s Read lock FAIL\n", switch_channel_get_name(session->channel)); #endif } else { status = (switch_status_t) switch_thread_rwlock_tryrdlock(session->rwlock); #ifdef SWITCH_DEBUG_RWLOCKS - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s Read lock AQUIRED\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s Read lock AQUIRED\n", switch_channel_get_name(session->channel)); #endif } @@ -611,7 +611,7 @@ SWITCH_DECLARE(void) switch_core_session_perform_write_lock(switch_core_session_ int line) { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s Write lock AQUIRED\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s Write lock AQUIRED\n", switch_channel_get_name(session->channel)); #else SWITCH_DECLARE(void) switch_core_session_write_lock(switch_core_session_t *session) @@ -626,7 +626,7 @@ SWITCH_DECLARE(void) switch_core_session_perform_rwunlock(switch_core_session_t const char *func, int line) { - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_DEBUG, "%s Read/Write lock CLEARED\n", + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_DEBUG, "%s Read/Write lock CLEARED\n", switch_channel_get_name(session->channel)); #else SWITCH_DECLARE(void) switch_core_session_rwunlock(switch_core_session_t *session) @@ -2495,7 +2495,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_perform_kill_channel(switch_ switch_io_event_hook_kill_channel_t *ptr; switch_status_t status = SWITCH_STATUS_FALSE; - switch_log_printf(SWITCH_CHANNEL_ID_LOG, (char *) file, func, line, SWITCH_LOG_INFO, "Kill %s [%d]\n", switch_channel_get_name(session->channel), sig); + switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, SWITCH_LOG_INFO, "Kill %s [%d]\n", switch_channel_get_name(session->channel), sig); if (session->endpoint_interface->io_routines->kill_channel) { if ((status = session->endpoint_interface->io_routines->kill_channel(session, sig)) == SWITCH_STATUS_SUCCESS) { diff --git a/src/switch_log.c b/src/switch_log.c index 0cbdb293f5..1928bea15b 100644 --- a/src/switch_log.c +++ b/src/switch_log.c @@ -169,7 +169,7 @@ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, const char int ret = 0; va_list ap; FILE *handle; - const char *filep = (file ? (const char *)switch_cut_path((char *)file): ""); + const char *filep = (file ? switch_cut_path(file): ""); const char *funcp = (func ? func : ""); char *content = NULL; switch_time_t now = switch_time_now(); diff --git a/src/switch_utils.c b/src/switch_utils.c index 3f02c135bd..b59db7e216 100644 --- a/src/switch_utils.c +++ b/src/switch_utils.c @@ -496,11 +496,11 @@ SWITCH_DECLARE(unsigned int) switch_separate_string(char *buf, char delim, char return argc; } -SWITCH_DECLARE(char *) switch_cut_path(char *in) +SWITCH_DECLARE(const char *) switch_cut_path(const char *in) { - char *p, *ret = in; - char delims[] = "/\\"; - char *i; + const char *p, *ret = in; + const char delims[] = "/\\"; + const char *i; if (in) { for (i = delims; *i; i++) {