Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Commit

Permalink
Do not use attribute_const
Browse files Browse the repository at this point in the history
  • Loading branch information
RoEdAl committed Jun 1, 2024
1 parent 9589320 commit 83408dc
Show file tree
Hide file tree
Showing 21 changed files with 56 additions and 56 deletions.
4 changes: 2 additions & 2 deletions src/at_command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)};

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/at_command.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/at_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/at_parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions src/at_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions src/at_read.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions src/at_response.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions src/chan_quectel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/chan_quectel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ CLI_ALIASES(cli_reset, "reset", "reset <device>", "Reset <device>")
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));
Expand Down
2 changes: 1 addition & 1 deletion src/cpvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/cpvt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions src/dc_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -72,23 +72,23 @@ 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"};

const unsigned b = int23statebool(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"};

const unsigned b = int23statebool(v);
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"};

Expand All @@ -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) {
Expand All @@ -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 */

Expand Down
16 changes: 8 additions & 8 deletions src/dc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions src/helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -596,15 +596,15 @@ 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",
};
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",
Expand All @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions src/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/mutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
Loading

0 comments on commit 83408dc

Please sign in to comment.