Skip to content

Commit

Permalink
profiles: annotate immutable data as const
Browse files Browse the repository at this point in the history
  • Loading branch information
evelikov-work authored and Vudentz committed Jan 19, 2024
1 parent f8e0270 commit a078d13
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion profiles/audio/avctp.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ struct avctp_browsing_pdu_handler {
GDestroyNotify destroy;
};

static struct {
static const struct {
const char *name;
uint8_t avc;
uint16_t uinput;
Expand Down
8 changes: 4 additions & 4 deletions profiles/audio/avrcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ struct control_pdu_handler {
uint8_t transaction);
};

static struct {
static const struct {
uint8_t feature_bit;
uint8_t avc;
} passthrough_map[] = {
Expand Down Expand Up @@ -361,7 +361,7 @@ static unsigned int avctp_id = 0;
static uint8_t default_features[16];

/* Company IDs supported by this device */
static uint32_t company_ids[] = {
static const uint32_t company_ids[] = {
IEEEID_BTSIG,
};

Expand Down Expand Up @@ -2118,7 +2118,7 @@ static void avrcp_handle_get_total_number_of_items(struct avrcp *session,
pdu->param_len = cpu_to_be16(1);
}

static struct browsing_pdu_handler {
static const struct browsing_pdu_handler {
uint8_t pdu_id;
void (*func) (struct avrcp *session, struct avrcp_browsing_header *pdu,
uint8_t transaction);
Expand Down Expand Up @@ -2147,7 +2147,7 @@ static size_t handle_browsing_pdu(struct avctp *conn,
size_t operand_count, void *user_data)
{
struct avrcp *session = user_data;
struct browsing_pdu_handler *handler;
const struct browsing_pdu_handler *handler;
struct avrcp_browsing_header *pdu = (void *) operands;

DBG("AVRCP Browsing PDU 0x%02X, len 0x%04X", pdu->pdu_id,
Expand Down
6 changes: 3 additions & 3 deletions profiles/audio/media.c
Original file line number Diff line number Diff line change
Expand Up @@ -1420,7 +1420,7 @@ static bool experimental_bcast_sink_ep_supported(struct btd_adapter *adapter)
return g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL;
}

static struct media_endpoint_init {
static const struct media_endpoint_init {
const char *uuid;
bool (*func)(struct media_endpoint *endpoint, int *err);
bool (*supported)(struct btd_adapter *adapter);
Expand Down Expand Up @@ -1456,7 +1456,7 @@ media_endpoint_create(struct media_adapter *adapter,
int *err)
{
struct media_endpoint *endpoint;
struct media_endpoint_init *init;
const struct media_endpoint_init *init;
size_t i;
bool succeeded = false;

Expand Down Expand Up @@ -3244,7 +3244,7 @@ static gboolean supported_uuids(const GDBusPropertyTable *property,
DBUS_TYPE_STRING_AS_STRING, &entry);

for (i = 0; i < ARRAY_SIZE(init_table); i++) {
struct media_endpoint_init *init = &init_table[i];
const struct media_endpoint_init *init = &init_table[i];

if (init->supported(adapter->btd_adapter))
dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING,
Expand Down
2 changes: 1 addition & 1 deletion profiles/audio/sink.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct sink_state_callback {

static GSList *sink_callbacks = NULL;

static char *str_state[] = {
static const char *str_state[] = {
"SINK_STATE_DISCONNECTED",
"SINK_STATE_CONNECTING",
"SINK_STATE_CONNECTED",
Expand Down
2 changes: 1 addition & 1 deletion profiles/audio/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct source_state_callback {

static GSList *source_callbacks = NULL;

static char *str_state[] = {
static const char *str_state[] = {
"SOURCE_STATE_DISCONNECTED",
"SOURCE_STATE_CONNECTING",
"SOURCE_STATE_CONNECTED",
Expand Down
13 changes: 7 additions & 6 deletions profiles/audio/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ typedef enum {
TRANSPORT_STATE_SUSPENDING, /* Release in progress */
} transport_state_t;

static char *str_state[] = {
static const char *str_state[] = {
"TRANSPORT_STATE_IDLE",
"TRANSPORT_STATE_PENDING",
"TRANSPORT_STATE_REQUESTING",
Expand Down Expand Up @@ -124,7 +124,7 @@ struct media_transport {
uint16_t imtu; /* Transport input mtu */
uint16_t omtu; /* Transport output mtu */
transport_state_t state;
struct media_transport_ops *ops;
const struct media_transport_ops *ops;
void *data;
};

Expand Down Expand Up @@ -1753,7 +1753,7 @@ static void *transport_bap_init(struct media_transport *transport, void *stream)
#define BAP_BC_OPS(_uuid) \
BAP_OPS(_uuid, transport_bap_bc_properties, NULL, NULL)

static struct media_transport_ops transport_ops[] = {
static const struct media_transport_ops transport_ops[] = {
A2DP_OPS(A2DP_SOURCE_UUID, transport_a2dp_src_init,
transport_a2dp_src_set_volume,
transport_a2dp_src_destroy),
Expand All @@ -1766,12 +1766,13 @@ static struct media_transport_ops transport_ops[] = {
BAP_BC_OPS(BAA_SERVICE_UUID),
};

static struct media_transport_ops *media_transport_find_ops(const char *uuid)
static const struct media_transport_ops *
media_transport_find_ops(const char *uuid)
{
size_t i;

for (i = 0; i < ARRAY_SIZE(transport_ops); i++) {
struct media_transport_ops *ops = &transport_ops[i];
const struct media_transport_ops *ops = &transport_ops[i];

if (!strcasecmp(uuid, ops->uuid))
return ops;
Expand All @@ -1788,7 +1789,7 @@ struct media_transport *media_transport_create(struct btd_device *device,
{
struct media_endpoint *endpoint = data;
struct media_transport *transport;
struct media_transport_ops *ops;
const struct media_transport_ops *ops;
static int fd = 0;

transport = g_new0(struct media_transport, 1);
Expand Down
15 changes: 7 additions & 8 deletions profiles/health/hdp_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef gboolean (*parse_item_f)(DBusMessageIter *iter, gpointer user_data,
GError **err);

struct dict_entry_func {
char *key;
const char *key;
parse_item_f func;
};

Expand All @@ -67,15 +67,14 @@ struct get_dcpsm_data {
GDestroyNotify destroy;
};

static gboolean parse_dict_entry(struct dict_entry_func dict_context[],
static gboolean parse_dict_entry(const struct dict_entry_func dict_context[],
DBusMessageIter *iter,
GError **err,
gpointer user_data)
{
DBusMessageIter entry;
char *key;
int ctype, i;
struct dict_entry_func df;

dbus_message_iter_recurse(iter, &entry);
ctype = dbus_message_iter_get_arg_type(&entry);
Expand All @@ -88,17 +87,17 @@ static gboolean parse_dict_entry(struct dict_entry_func dict_context[],
dbus_message_iter_get_basic(&entry, &key);
dbus_message_iter_next(&entry);
/* Find function and call it */
for (i = 0, df = dict_context[0]; df.key; i++, df = dict_context[i]) {
if (g_ascii_strcasecmp(df.key, key) == 0)
return df.func(&entry, user_data, err);
for (i = 0; dict_context[i].key; i++) {
if (g_ascii_strcasecmp(dict_context[i].key, key) == 0)
return dict_context[i].func(&entry, user_data, err);
}

g_set_error(err, HDP_ERROR, HDP_DIC_ENTRY_PARSE_ERROR,
"No function found for parsing value for key %s", key);
return FALSE;
}

static gboolean parse_dict(struct dict_entry_func dict_context[],
static gboolean parse_dict(const struct dict_entry_func dict_context[],
DBusMessageIter *iter,
GError **err,
gpointer user_data)
Expand Down Expand Up @@ -273,7 +272,7 @@ static gboolean parse_chan_type(DBusMessageIter *iter, gpointer data,
return TRUE;
}

static struct dict_entry_func dict_parser[] = {
static const struct dict_entry_func dict_parser[] = {
{"DataType", parse_data_type},
{"Role", parse_role},
{"Description", parse_desc},
Expand Down
2 changes: 1 addition & 1 deletion profiles/iap/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ static guint setup_signalfd(void)

static gboolean option_version = FALSE;

static GOptionEntry options[] = {
static const GOptionEntry options[] = {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
"Show version information and exit" },
{ NULL },
Expand Down

0 comments on commit a078d13

Please sign in to comment.