From 83408dc13b120b5e9d00e0b735ce789dc5967ca1 Mon Sep 17 00:00:00 2001 From: Edmunt Pienkowsky Date: Sat, 1 Jun 2024 09:19:02 +0200 Subject: [PATCH] Do not use attribute_const --- src/at_command.c | 4 ++-- src/at_command.h | 2 +- src/at_parse.c | 4 ++-- src/at_parse.h | 2 +- src/at_read.c | 4 ++-- src/at_read.h | 4 ++-- src/at_response.c | 4 ++-- src/chan_quectel.c | 8 ++++---- src/chan_quectel.h | 6 +++--- src/channel.c | 4 ++-- src/cli.c | 2 +- src/cpvt.c | 2 +- src/cpvt.h | 2 +- src/dc_config.c | 18 +++++++++--------- src/dc_config.h | 16 ++++++++-------- src/error.c | 2 +- src/error.h | 2 +- src/helpers.c | 8 ++++---- src/helpers.h | 8 ++++---- src/mutils.h | 6 +++--- src/pcm.c | 4 ++-- 21 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/at_command.c b/src/at_command.c index 1595bb40..1ac8487d 100644 --- a/src/at_command.c +++ b/src/at_command.c @@ -40,7 +40,7 @@ DECLARE_AT_CMD(chld2, "+CHLD=2"); * \return a string describing the given command */ -const char* attribute_const at_cmd2str(at_cmd_t cmd) +const char* at_cmd2str(at_cmd_t cmd) { static const char* const cmds[] = {AT_COMMANDS_TABLE(AT_CMD_AS_STRING)}; @@ -1218,7 +1218,7 @@ static int at_enqueue_msg_ack_n(struct cpvt *cpvt, int n, int uid) } #endif -static int attribute_const map_hangup_cause(int hangup_cause) +static int map_hangup_cause(int hangup_cause) { switch (hangup_cause) { // list of supported cause codes diff --git a/src/at_command.h b/src/at_command.h index d60f2b83..b60d1531 100644 --- a/src/at_command.h +++ b/src/at_command.h @@ -131,7 +131,7 @@ enum msg_status_t { MSG_STAT_REC_UNREAD, MSG_STAT_REC_READ, MSG_STAT_STO_UNSENT, struct pvt; struct cpvt; -const char* attribute_const at_cmd2str(at_cmd_t cmd); +const char* at_cmd2str(at_cmd_t cmd); int at_enqueue_at(struct cpvt* cpvt); int at_enqueue_initialization(struct cpvt* cpvt); int at_enqueue_initialization_quectel(struct cpvt*, unsigned int); diff --git a/src/at_parse.c b/src/at_parse.c index 58dcb738..0a11d5c6 100644 --- a/src/at_parse.c +++ b/src/at_parse.c @@ -59,7 +59,7 @@ static char* trim_blanks(char* str) return str; } -const char* attribute_const at_qind2str(qind_t qind) +const char* at_qind2str(qind_t qind) { static const char* qind_names[] = {"NONE", "CSQ", "ACT", "CCINFO"}; return enum2str_def(qind, qind_names, ARRAY_LEN(qind_names), "UNK"); @@ -199,7 +199,7 @@ int at_parse_cspn(char* str, char** spn) return -1; } -static int attribute_const act2int(const char* act) +static int act2int(const char* act) { static const struct { const char* act; diff --git a/src/at_parse.h b/src/at_parse.h index 9db48b71..e6679b08 100644 --- a/src/at_parse.h +++ b/src/at_parse.h @@ -16,7 +16,7 @@ typedef enum { QIND_NONE = 0, QIND_CSQ, QIND_ACT, QIND_CCINFO } qind_t; typedef enum { CCWA_VARIANT_PRESENTATION_FLAG, CCWA_VARIANT_STATUS_AND_CLASS, CCWA_VARIANT_URC } ccwa_variant_t; -const char* attribute_const at_qind2str(qind_t); +const char* at_qind2str(qind_t); char* at_parse_cnum(char* str); char* at_parse_cops(char* str); diff --git a/src/at_read.c b/src/at_read.c index a803772e..21a14828 100644 --- a/src/at_read.c +++ b/src/at_read.c @@ -107,9 +107,9 @@ void at_clean_data(const char* dev, int fd, struct ringbuffer* const rb) } } -size_t attribute_const at_get_iov_size(const struct iovec* iov) { return iov[0].iov_len + iov[1].iov_len; } +size_t at_get_iov_size(const struct iovec* iov) { return iov[0].iov_len + iov[1].iov_len; } -size_t attribute_const at_get_iov_size_n(const struct iovec* iov, int iovcnt) +size_t at_get_iov_size_n(const struct iovec* iov, int iovcnt) { size_t res = 0u; for (int i = 0; i < iovcnt; ++i) { diff --git a/src/at_read.h b/src/at_read.h index 87bb2aac..e2fd3565 100644 --- a/src/at_read.h +++ b/src/at_read.h @@ -12,8 +12,8 @@ int at_wait(int fd, int* ms); ssize_t at_read(const char* dev, int fd, struct ringbuffer* rb); void at_clean_data(const char* dev, int fd, struct ringbuffer* const rb); -size_t attribute_const at_get_iov_size(const struct iovec* iov); -size_t attribute_const at_get_iov_size_n(const struct iovec* iov, int iovcnt); +size_t at_get_iov_size(const struct iovec* iov); +size_t at_get_iov_size_n(const struct iovec* iov, int iovcnt); size_t at_combine_iov(struct ast_str* const, const struct iovec* const, int); diff --git a/src/at_response.c b/src/at_response.c index 65b4e30d..7dfb795d 100644 --- a/src/at_response.c +++ b/src/at_response.c @@ -1173,7 +1173,7 @@ static int at_response_clcc(struct pvt* const pvt, const struct ast_str* const r return 0; } -static attribute_const unsigned int map_dsci(const unsigned int dsci) +static unsigned int map_dsci(const unsigned int dsci) { switch (dsci) { case 3u: // connect @@ -2388,7 +2388,7 @@ static void at_response_dtmf(struct pvt* const pvt, const struct ast_str* const send_dtmf_frame(pvt, c); } -static const char* attribute_const qpcmv2str(int qpcmv) +static const char* qpcmv2str(int qpcmv) { const char* const names[3] = {"USB NMEA port", "Debug UART", "USB sound card"}; return enum2str_def((unsigned)qpcmv, names, ARRAY_LEN(names), "Unknown"); diff --git a/src/chan_quectel.c b/src/chan_quectel.c index 7dd68318..c409fb64 100644 --- a/src/chan_quectel.c +++ b/src/chan_quectel.c @@ -70,9 +70,9 @@ static const char* const dev_state_strs[4] = {"stop", "restart", "remove", "star public_state_t* gpublic; -const char* attribute_const dev_state2str(dev_state_t state) { return enum2str(state, dev_state_strs, ARRAY_LEN(dev_state_strs)); } +const char* dev_state2str(dev_state_t state) { return enum2str(state, dev_state_strs, ARRAY_LEN(dev_state_strs)); } -dev_state_t attribute_const str2dev_state(const char* str) +dev_state_t str2dev_state(const char* str) { if (!str) { return DEV_STATE_STOPPED; @@ -86,7 +86,7 @@ dev_state_t attribute_const str2dev_state(const char* str) } } -const char* attribute_const dev_state2str_msg(dev_state_t state) +const char* dev_state2str_msg(dev_state_t state) { static const char* const states[] = {"Stop scheduled", "Restart scheduled", "Removal scheduled", "Start scheduled"}; return enum2str(state, states, ARRAY_LEN(states)); @@ -1377,7 +1377,7 @@ const struct ast_format* pvt_get_audio_format(const struct pvt* const pvt) } } -static attribute_const size_t pvt_get_audio_frame_size_r(unsigned int ptime, const unsigned int sr) +static size_t pvt_get_audio_frame_size_r(unsigned int ptime, const unsigned int sr) { size_t res = ptime; res *= sr / 1000; diff --git a/src/chan_quectel.h b/src/chan_quectel.h index 075d510a..52295eb7 100644 --- a/src/chan_quectel.h +++ b/src/chan_quectel.h @@ -32,9 +32,9 @@ #define MODULE_DESCRIPTION "Channel Driver for Mobile Telephony" #define MAXQUECTELDEVICES 128 -const char* attribute_const dev_state2str(dev_state_t state); -dev_state_t attribute_const str2dev_state(const char*); -const char* attribute_const dev_state2str_msg(dev_state_t state); +const char* dev_state2str(dev_state_t state); +dev_state_t str2dev_state(const char*); +const char* dev_state2str_msg(dev_state_t state); typedef enum { RESTATE_TIME_NOW = 0, diff --git a/src/channel.c b/src/channel.c index d93a15e0..75ce3971 100644 --- a/src/channel.c +++ b/src/channel.c @@ -183,7 +183,7 @@ static struct ast_channel* channel_request(attribute_unused const char* type, st return channel; } -static int attribute_const get_at_clir_value(const int clir) +static int get_at_clir_value(const int clir) { int res = 0; @@ -369,7 +369,7 @@ static int channel_digit_begin(struct ast_channel* channel, char digit) static int channel_digit_end(attribute_unused struct ast_channel* channel, attribute_unused char digit, attribute_unused unsigned int duration) { return 0; } -static ssize_t attribute_const get_iov_total_len(const struct iovec* const iov, int iovcnt) +static ssize_t get_iov_total_len(const struct iovec* const iov, int iovcnt) { ssize_t len = 0; diff --git a/src/cli.c b/src/cli.c index cc5d8231..1457137d 100644 --- a/src/cli.c +++ b/src/cli.c @@ -737,7 +737,7 @@ CLI_ALIASES(cli_reset, "reset", "reset ", "Reset ") static const char* const a_choices[] = {"now", "gracefully", "when", NULL}; static const char* const a_choices2[] = {"convenient", NULL}; -static const char* attribute_const restate2str_msg(restate_time_t when) +static const char* restate2str_msg(restate_time_t when) { static const char* const choices[] = {"now", "gracefully", "when convenient"}; return enum2str(when, choices, ARRAY_LEN(choices)); diff --git a/src/cpvt.c b/src/cpvt.c index 1484c8ed..5eda0e78 100644 --- a/src/cpvt.c +++ b/src/cpvt.c @@ -16,7 +16,7 @@ #include "channel.h" #include "mutils.h" /* ARRAY_LEN() */ -const char* attribute_const call_state2str(call_state_t state) +const char* call_state2str(call_state_t state) { static const char* const states[] = {/* real device states */ "active", "held", "dialing", "alerting", "incoming", "waiting", diff --git a/src/cpvt.h b/src/cpvt.h index e45c88b4..0a01460f 100644 --- a/src/cpvt.h +++ b/src/cpvt.h @@ -32,7 +32,7 @@ typedef enum { #define CALL_STATES_NUMBER (CALL_STATE_MAX - CALL_STATE_MIN + 1) -const char* attribute_const call_state2str(call_state_t state); +const char* call_state2str(call_state_t state); typedef enum { CALL_FLAG_NONE = 0, diff --git a/src/dc_config.c b/src/dc_config.c index ae5116a5..2f267d61 100644 --- a/src/dc_config.c +++ b/src/dc_config.c @@ -16,13 +16,13 @@ static const int DEFAULT_CSMS_TTL = 600; const static long DEF_DTMF_DURATION = 120; -const char* attribute_const dc_cw_setting2str(call_waiting_t cw) +const char* dc_cw_setting2str(call_waiting_t cw) { static const char* const options[] = {"disabled", "allowed", "auto"}; return enum2str(cw, options, ARRAY_LEN(options)); } -tristate_bool_t attribute_const dc_str23stbool(const char* str) +tristate_bool_t dc_str23stbool(const char* str) { if (!str) { return TRIBOOL_NONE; @@ -37,7 +37,7 @@ tristate_bool_t attribute_const dc_str23stbool(const char* str) } } -int attribute_const dc_str23stbool_ex(const char* str, tristate_bool_t* res, const char* none_val) +int dc_str23stbool_ex(const char* str, tristate_bool_t* res, const char* none_val) { if (!str) { return -1; @@ -63,7 +63,7 @@ int attribute_const dc_str23stbool_ex(const char* str, tristate_bool_t* res, con } } -static unsigned int attribute_const int23statebool(int v) +static unsigned int int23statebool(int v) { if (!v) { return 1; @@ -72,7 +72,7 @@ static unsigned int attribute_const int23statebool(int v) } } -const char* attribute_const dc_3stbool2str(int v) +const char* dc_3stbool2str(int v) { static const char* const strs[] = {"off", "none", "on"}; @@ -80,7 +80,7 @@ const char* attribute_const dc_3stbool2str(int v) return enum2str_def(b, strs, ARRAY_LEN(strs), "none"); } -const char* attribute_const dc_3stbool2str_ex(int v, const char* none_val) +const char* dc_3stbool2str_ex(int v, const char* none_val) { const char* const strs[] = {"off", S_OR(none_val, "none"), "on"}; @@ -88,7 +88,7 @@ const char* attribute_const dc_3stbool2str_ex(int v, const char* none_val) return enum2str_def(b, strs, ARRAY_LEN(strs), S_OR(none_val, "none")); } -const char* attribute_const dc_3stbool2str_capitalized(int v) +const char* dc_3stbool2str_capitalized(int v) { static const char* const strs[] = {"Off", "None", "On"}; @@ -114,7 +114,7 @@ static unsigned int parse_on_off(const char* const name, const char* const value static const char* const msgstor_strs[] = {"AUTO", "SM", "ME", "MT", "SR"}; -message_storage_t attribute_const dc_str2msgstor(const char* stor) +message_storage_t dc_str2msgstor(const char* stor) { const int res = str2enum(stor, msgstor_strs, ARRAY_LEN(msgstor_strs)); if (res < 0) { @@ -123,7 +123,7 @@ message_storage_t attribute_const dc_str2msgstor(const char* stor) return (message_storage_t)res; } -const char* attribute_const dc_msgstor2str(message_storage_t stor) { return enum2str_def(stor, msgstor_strs, ARRAY_LEN(msgstor_strs), "AUTO"); } +const char* dc_msgstor2str(message_storage_t stor) { return enum2str_def(stor, msgstor_strs, ARRAY_LEN(msgstor_strs), "AUTO"); } #/* assume config is zerofill */ diff --git a/src/dc_config.h b/src/dc_config.h index c406c2f0..57417aec 100644 --- a/src/dc_config.h +++ b/src/dc_config.h @@ -36,17 +36,17 @@ typedef enum { MESSAGE_STORAGE_SR, } message_storage_t; -const char* attribute_const dc_cw_setting2str(call_waiting_t); +const char* dc_cw_setting2str(call_waiting_t); -tristate_bool_t attribute_const dc_str23stbool(const char*); -int attribute_const dc_str23stbool_ex(const char*, tristate_bool_t*, const char*); +tristate_bool_t dc_str23stbool(const char*); +int dc_str23stbool_ex(const char*, tristate_bool_t*, const char*); -const char* attribute_const dc_3stbool2str(int); -const char* attribute_const dc_3stbool2str_ex(int, const char*); -const char* attribute_const dc_3stbool2str_capitalized(int); +const char* dc_3stbool2str(int); +const char* dc_3stbool2str_ex(int, const char*); +const char* dc_3stbool2str_capitalized(int); -message_storage_t attribute_const dc_str2msgstor(const char*); -const char* attribute_const dc_msgstor2str(message_storage_t); +message_storage_t dc_str2msgstor(const char*); +const char* dc_msgstor2str(message_storage_t); /* Config API diff --git a/src/error.c b/src/error.c index 66b022ab..1bf7170d 100644 --- a/src/error.c +++ b/src/error.c @@ -5,7 +5,7 @@ #include "mutils.h" -const char* attribute_const error2str(int err) +const char* error2str(int err) { static const char* const errors[] = { "Unknown error", diff --git a/src/error.h b/src/error.h index 838ebc26..a2c79962 100644 --- a/src/error.h +++ b/src/error.h @@ -38,7 +38,7 @@ enum error { E_MALLOC }; -const char* attribute_const error2str(int err); +const char* error2str(int err); extern __thread int chan_quectel_err; diff --git a/src/helpers.c b/src/helpers.c index 46e76e3f..5840da9d 100644 --- a/src/helpers.c +++ b/src/helpers.c @@ -525,7 +525,7 @@ static char* escape_c(char* dest, const char* s, size_t size) return dest; } -size_t attribute_const get_esc_str_buffer_size(size_t len) { return (len * 2u) + 1u; } +size_t get_esc_str_buffer_size(size_t len) { return (len * 2u) + 1u; } struct ast_str* escape_nstr(const char* buf, size_t cnt) { @@ -596,7 +596,7 @@ const char* escape_str_ex(struct ast_str* ebuf, const struct ast_str* const str) #/* */ -const char* attribute_const gsm_regstate2str(int gsm_reg_status) +const char* gsm_regstate2str(int gsm_reg_status) { static const char* const gsm_states[] = { "Not registered, not searching", "Registered, home network", "Not registered, but searching", "Registration denied", "Unknown", "Registered, roaming", @@ -604,7 +604,7 @@ const char* attribute_const gsm_regstate2str(int gsm_reg_status) return enum2str_def(gsm_reg_status, gsm_states, ARRAY_LEN(gsm_states), "Unknown"); } -const char* attribute_const gsm_regstate2str_json(int gsm_reg_status) +const char* gsm_regstate2str_json(int gsm_reg_status) { static const char* const gsm_states[] = { "not_registered_not_searching", "registered", "not_registered_searching", "registration_denied", "unknown", "registered_roaming", @@ -614,7 +614,7 @@ const char* attribute_const gsm_regstate2str_json(int gsm_reg_status) #/* */ -const char* attribute_const sys_act2str(int act) +const char* sys_act2str(int act) { static const char* const sys_acts[] = { "No service", diff --git a/src/helpers.h b/src/helpers.h index e51ce48d..ba3d86fb 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -37,7 +37,7 @@ struct ast_str* const gain2str(int); int str2gain_simcom(const char*, int*); struct ast_str* const gain2str_simcom(int); -size_t attribute_const get_esc_str_buffer_size(size_t); +size_t get_esc_str_buffer_size(size_t); struct ast_str* escape_nstr(const char*, size_t); struct ast_str* escape_str(const struct ast_str* const); @@ -62,9 +62,9 @@ const char* escape_str_ex(struct ast_str*, const struct ast_str* const); if (s && ast_str_strlen(s)) ast_json_object_set(j, #s, ast_json_string_create(ast_str_buffer(s))); -const char* attribute_const gsm_regstate2str(int gsm_reg_status); -const char* attribute_const gsm_regstate2str_json(int gsm_reg_status); -const char* attribute_const sys_act2str(int sys_submode); +const char* gsm_regstate2str(int gsm_reg_status); +const char* gsm_regstate2str_json(int gsm_reg_status); +const char* sys_act2str(int sys_submode); struct ast_str* rssi2dBm(int rssi); size_t fd_write_all(int fd, const char* buf, size_t count); diff --git a/src/mutils.h b/src/mutils.h index 329d5766..46345272 100644 --- a/src/mutils.h +++ b/src/mutils.h @@ -17,17 +17,17 @@ #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif -static inline const char* attribute_const enum2str_def(const unsigned value, const char* const names[], const unsigned items, const char* const def) +static inline const char* enum2str_def(const unsigned value, const char* const names[], const unsigned items, const char* const def) { return S_COR(value < items, names[value], def); } -static inline const char* attribute_const enum2str(const unsigned value, const char* const names[], const unsigned items) +static inline const char* enum2str(const unsigned value, const char* const names[], const unsigned items) { return enum2str_def(value, names, items, "unknown"); } -static inline int attribute_const str2enum(const char* const value, const char* const options[], const unsigned items) +static inline int str2enum(const char* const value, const char* const options[], const unsigned items) { for (unsigned i = 0; i < items; ++i) { if (!strcasecmp(value, options[i])) { diff --git a/src/pcm.c b/src/pcm.c index da18158d..3cfe6d27 100644 --- a/src/pcm.c +++ b/src/pcm.c @@ -50,7 +50,7 @@ void _pcm_show_state(int attribute_unused lvl, const char* file, int line, const snd_pcm_state_name(pcm_state), delay_period_buffers, delay, avail_period_buffers, avail); } -static attribute_const snd_pcm_uframes_t adjust_uframes(snd_pcm_uframes_t ptime, unsigned int rate) +static snd_pcm_uframes_t adjust_uframes(snd_pcm_uframes_t ptime, unsigned int rate) { snd_pcm_uframes_t res = ptime; res *= rate / 1000; @@ -58,7 +58,7 @@ static attribute_const snd_pcm_uframes_t adjust_uframes(snd_pcm_uframes_t ptime, return res; } -static attribute_const snd_pcm_uframes_t adjust_start_threshold(snd_pcm_uframes_t ptime) +static snd_pcm_uframes_t adjust_start_threshold(snd_pcm_uframes_t ptime) { static const size_t PTIME_MIN_START_THRESHOLD = 100u; static const size_t PTIME_MAX_START_THRESHOLD = 250u;