* [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section
@ 2014-12-02 17:28 Szymon Janc
2014-12-02 17:28 ` [PATCH 02/13] profiles: List all enum values in switch Szymon Janc
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
Since GCC has option (-Wswitch-enum) that ensure all enum values are
handled inside switch it is no longer necessary to forbit default in
such case.
---
doc/coding-style.txt | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/doc/coding-style.txt b/doc/coding-style.txt
index 59df64a..b3fbd2e 100644
--- a/doc/coding-style.txt
+++ b/doc/coding-style.txt
@@ -175,10 +175,11 @@ enum animal_type {
M10: Enum as switch variable
============================
-If the variable of a switch is an enum, you must not include a default in
-switch body. The reason for this is: If later on you modify the enum by adding
-a new type, and forget to change the switch accordingly, the compiler will
-complain the new added type hasn't been handled.
+If the variable of a switch is an enum, you must include all values in
+switch body even if providing default. This is enforced by compiler option
+enabling extra warning in such case. The reason for this is to ensure that if
+later on enum is modified and one forget to change the switch accordingly, the
+compiler will complain the new added type hasn't been handled.
Example:
@@ -190,7 +191,7 @@ enum animal_type {
enum animal_type t;
-switch (t) {
+switch (t) { // OK
case ANIMAL_TYPE_FOUR_LEGS:
...
break;
@@ -200,7 +201,18 @@ case ANIMAL_TYPE_EIGHT_LEGS:
case ANIMAL_TYPE_TWO_LEGS:
...
break;
-default: // wrong
+default:
+ break;
+}
+
+switch (t) { // Wrong
+case ANIMAL_TYPE_FOUR_LEGS:
+ ...
+ break;
+case ANIMAL_TYPE_TWO_LEGS:
+ ...
+ break;
+default:
break;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 02/13] profiles: List all enum values in switch
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-02 17:28 ` [PATCH 03/13] lib: " Szymon Janc
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
As described in coding style M10.
---
profiles/alert/server.c | 1 +
profiles/audio/a2dp.c | 12 ++++++++++++
profiles/audio/avrcp.c | 1 +
profiles/audio/control.c | 2 ++
profiles/health/mcap.c | 1 +
5 files changed, 17 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 8601bf1..aefcff8 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -406,6 +406,7 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
len = enc_notification(al_adapter->hnd_value[type],
nd->value, nd->len, pdu, len);
break;
+ case NOTIFY_SIZE:
default:
DBG("Unknown type, could not send notification");
goto end;
diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 6b72f99..75503f3 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -1619,6 +1619,9 @@ unsigned int a2dp_config(struct avdtp *session, struct a2dp_sep *sep,
}
}
break;
+ case AVDTP_STATE_CONFIGURED:
+ case AVDTP_STATE_CLOSING:
+ case AVDTP_STATE_ABORTING:
default:
error("SEP in bad state for requesting a new stream");
goto failed;
@@ -1675,6 +1678,8 @@ unsigned int a2dp_resume(struct avdtp *session, struct a2dp_sep *sep,
cb_data->source_id = g_idle_add(finalize_resume,
setup);
break;
+ case AVDTP_STATE_CLOSING:
+ case AVDTP_STATE_ABORTING:
default:
error("SEP in bad state for resume");
goto failed;
@@ -1719,6 +1724,9 @@ unsigned int a2dp_suspend(struct avdtp *session, struct a2dp_sep *sep,
}
sep->suspending = TRUE;
break;
+ case AVDTP_STATE_CONFIGURED:
+ case AVDTP_STATE_CLOSING:
+ case AVDTP_STATE_ABORTING:
default:
error("SEP in bad state for suspend");
goto failed;
@@ -1806,6 +1814,10 @@ gboolean a2dp_sep_unlock(struct a2dp_sep *sep, struct avdtp *session)
if (avdtp_suspend(session, sep->stream) == 0)
sep->suspending = TRUE;
break;
+ case AVDTP_STATE_IDLE:
+ case AVDTP_STATE_CONFIGURED:
+ case AVDTP_STATE_CLOSING:
+ case AVDTP_STATE_ABORTING:
default:
break;
}
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 5c3c4f9..11de6ee 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -3610,6 +3610,7 @@ static void state_changed(struct btd_device *device, avctp_state_t old_state,
session_init_browsing(session);
break;
+ case AVCTP_STATE_BROWSING_CONNECTING:
default:
return;
}
diff --git a/profiles/audio/control.c b/profiles/audio/control.c
index ab94a57..3985362 100644
--- a/profiles/audio/control.c
+++ b/profiles/audio/control.c
@@ -96,6 +96,8 @@ static void state_changed(struct btd_device *dev, avctp_state_t old_state,
g_dbus_emit_property_changed(conn, path,
AUDIO_CONTROL_INTERFACE, "Connected");
break;
+ case AVCTP_STATE_BROWSING_CONNECTING:
+ case AVCTP_STATE_BROWSING_CONNECTED:
default:
return;
}
diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c
index a20a7ad..cc47a1e 100644
--- a/profiles/health/mcap.c
+++ b/profiles/health/mcap.c
@@ -952,6 +952,7 @@ static gboolean parse_set_opts(struct mcap_mdl_cb *mdl_cb, GError **err,
c->mdl_reconn_req = va_arg(args,
mcap_remote_mdl_reconn_req_cb);
break;
+ case MCAP_MDL_CB_INVALID:
default:
g_set_error(err, MCAP_ERROR, MCAP_ERROR_INVALID_ARGS,
"Unknown option %d", cb);
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 03/13] lib: List all enum values in switch
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
2014-12-02 17:28 ` [PATCH 02/13] profiles: List all enum values in switch Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-02 17:28 ` [PATCH 04/13] btio: " Szymon Janc
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
As described in coding style M10.
---
lib/uuid.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/uuid.c b/lib/uuid.c
index 5c3f986..186a7e6 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -84,6 +84,7 @@ void bt_uuid_to_uuid128(const bt_uuid_t *src, bt_uuid_t *dst)
case BT_UUID16:
bt_uuid16_to_uuid128(src, dst);
break;
+ case BT_UUID_UNSPEC:
default:
break;
}
@@ -171,6 +172,7 @@ int bt_uuid_to_string(const bt_uuid_t *uuid, char *str, size_t n)
ntohl(data4), ntohs(data5));
}
break;
+ case BT_UUID_UNSPEC:
default:
snprintf(str, n, "Type of UUID (%x) unknown.", uuid->type);
return -EINVAL; /* Enum type of UUID not set */
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 04/13] btio: List all enum values in switch
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
2014-12-02 17:28 ` [PATCH 02/13] profiles: List all enum values in switch Szymon Janc
2014-12-02 17:28 ` [PATCH 03/13] lib: " Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-02 17:28 ` [PATCH 05/13] attrib: " Szymon Janc
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
As described in coding style M10.
---
btio/btio.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/btio/btio.c b/btio/btio.c
index 4ec286c..db731fa 100644
--- a/btio/btio.c
+++ b/btio/btio.c
@@ -875,6 +875,12 @@ static gboolean parse_set_opts(struct set_opts *opts, GError **err,
case BT_IO_OPT_VOICE:
opts->voice = va_arg(args, int);
break;
+ case BT_IO_OPT_INVALID:
+ case BT_IO_OPT_KEY_SIZE:
+ case BT_IO_OPT_SOURCE_CHANNEL:
+ case BT_IO_OPT_DEST_CHANNEL:
+ case BT_IO_OPT_HANDLE:
+ case BT_IO_OPT_CLASS:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
"Unknown option %d", opt);
@@ -1141,6 +1147,13 @@ parse_opts:
}
*(va_arg(args, uint32_t *)) = priority;
break;
+ case BT_IO_OPT_INVALID:
+ case BT_IO_OPT_SOURCE_TYPE:
+ case BT_IO_OPT_CHANNEL:
+ case BT_IO_OPT_SOURCE_CHANNEL:
+ case BT_IO_OPT_DEST_CHANNEL:
+ case BT_IO_OPT_MTU:
+ case BT_IO_OPT_VOICE:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
"Unknown option %d", opt);
@@ -1274,6 +1287,19 @@ static gboolean rfcomm_get(int sock, GError **err, BtIOOption opt1,
}
memcpy(va_arg(args, uint8_t *), dev_class, 3);
break;
+ case BT_IO_OPT_SOURCE_TYPE:
+ case BT_IO_OPT_DEST_TYPE:
+ case BT_IO_OPT_KEY_SIZE:
+ case BT_IO_OPT_PSM:
+ case BT_IO_OPT_CID:
+ case BT_IO_OPT_MTU:
+ case BT_IO_OPT_OMTU:
+ case BT_IO_OPT_IMTU:
+ case BT_IO_OPT_MODE:
+ case BT_IO_OPT_FLUSHABLE:
+ case BT_IO_OPT_PRIORITY:
+ case BT_IO_OPT_VOICE:
+ case BT_IO_OPT_INVALID:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
"Unknown option %d", opt);
@@ -1359,6 +1385,22 @@ static gboolean sco_get(int sock, GError **err, BtIOOption opt1, va_list args)
}
memcpy(va_arg(args, uint8_t *), dev_class, 3);
break;
+ case BT_IO_OPT_SOURCE_TYPE:
+ case BT_IO_OPT_DEST_TYPE:
+ case BT_IO_OPT_DEFER_TIMEOUT:
+ case BT_IO_OPT_SEC_LEVEL:
+ case BT_IO_OPT_KEY_SIZE:
+ case BT_IO_OPT_CHANNEL:
+ case BT_IO_OPT_SOURCE_CHANNEL:
+ case BT_IO_OPT_DEST_CHANNEL:
+ case BT_IO_OPT_PSM:
+ case BT_IO_OPT_CID:
+ case BT_IO_OPT_MASTER:
+ case BT_IO_OPT_MODE:
+ case BT_IO_OPT_FLUSHABLE:
+ case BT_IO_OPT_PRIORITY:
+ case BT_IO_OPT_VOICE:
+ case BT_IO_OPT_INVALID:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
"Unknown option %d", opt);
@@ -1385,6 +1427,7 @@ static gboolean get_valist(GIOChannel *io, BtIOType type, GError **err,
return rfcomm_get(sock, err, opt1, args);
case BT_IO_SCO:
return sco_get(sock, err, opt1, args);
+ case BT_IO_INVALID:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
"Unknown BtIO type %d", type);
@@ -1452,6 +1495,7 @@ gboolean bt_io_set(GIOChannel *io, GError **err, BtIOOption opt1, ...)
return rfcomm_set(sock, opts.sec_level, opts.master, err);
case BT_IO_SCO:
return sco_set(sock, opts.mtu, opts.voice, err);
+ case BT_IO_INVALID:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
"Unknown BtIO type %d", type);
@@ -1522,6 +1566,7 @@ static GIOChannel *create_io(gboolean server, struct set_opts *opts,
if (!sco_set(sock, opts->mtu, opts->voice, err))
goto failed;
break;
+ case BT_IO_INVALID:
default:
g_set_error(err, BT_IO_ERROR, EINVAL,
"Unknown BtIO type %d", opts->type);
@@ -1575,6 +1620,7 @@ GIOChannel *bt_io_connect(BtIOConnect connect, gpointer user_data,
case BT_IO_SCO:
err = sco_connect(sock, &opts.dst);
break;
+ case BT_IO_INVALID:
default:
g_set_error(gerr, BT_IO_ERROR, EINVAL,
"Unknown BtIO type %d", opts.type);
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 05/13] attrib: List all enum values in switch
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
` (2 preceding siblings ...)
2014-12-02 17:28 ` [PATCH 04/13] btio: " Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-02 17:28 ` [PATCH 06/13] core: " Szymon Janc
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
As described in coding style M10
---
attrib/gatt-service.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/attrib/gatt-service.c b/attrib/gatt-service.c
index 874552b..f592a70 100644
--- a/attrib/gatt-service.c
+++ b/attrib/gatt-service.c
@@ -118,6 +118,10 @@ static GSList *parse_opts(gatt_option opt1, va_list args)
case GATT_OPT_CHR_AUTHORIZATION:
info->authorization = va_arg(args, gatt_option);
break;
+ case GATT_CHR_VALUE_READ:
+ case GATT_CHR_VALUE_WRITE:
+ case GATT_CHR_VALUE_BOTH:
+ case GATT_OPT_INVALID:
default:
error("Invalid option: %d", opt);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 06/13] core: List all enum values in switch
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
` (3 preceding siblings ...)
2014-12-02 17:28 ` [PATCH 05/13] attrib: " Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-02 17:28 ` [PATCH 07/13] gobex: " Szymon Janc
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
As described in coding style M10
---
src/agent.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/agent.c b/src/agent.c
index 97daf71..73b2fdd 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -242,6 +242,10 @@ void agent_unref(struct agent *agent)
passkey_cb = agent->request->cb;
passkey_cb(agent, &err, 0, agent->request->user_data);
break;
+ case AGENT_REQUEST_CONFIRMATION:
+ case AGENT_REQUEST_AUTHORIZATION:
+ case AGENT_REQUEST_AUTHORIZE_SERVICE:
+ case AGENT_REQUEST_DISPLAY_PINCODE:
default:
cb = agent->request->cb;
cb(agent, &err, agent->request->user_data);
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 07/13] gobex: List all enum values in switch
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
` (4 preceding siblings ...)
2014-12-02 17:28 ` [PATCH 06/13] core: " Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-02 17:28 ` [PATCH 08/13] obexd: " Szymon Janc
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
As described in coding style M10.
---
| 1 +
1 file changed, 1 insertion(+)
--git a/gobex/gobex-header.c b/gobex/gobex-header.c
index ed7fd08..c594999 100644
--- a/gobex/gobex-header.c
+++ b/gobex/gobex-header.c
@@ -241,6 +241,7 @@ GObexHeader *g_obex_header_decode(const void *data, gsize len,
header->extdata = TRUE;
header->v.extdata = ptr;
break;
+ case G_OBEX_DATA_INHERIT:
default:
g_set_error(err, G_OBEX_ERROR,
G_OBEX_ERROR_INVALID_ARGS,
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 08/13] obexd: List all enum values in switch
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
` (5 preceding siblings ...)
2014-12-02 17:28 ` [PATCH 07/13] gobex: " Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-02 17:28 ` [PATCH 09/13] shared: " Szymon Janc
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
As described in coding style M10.
---
obexd/client/map.c | 2 ++
obexd/plugins/vcard.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/obexd/client/map.c b/obexd/client/map.c
index 76cf055..e6c1073 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -1929,6 +1929,8 @@ static void map_handle_notification(struct map_event *event, void *user_data)
case MAP_ET_MESSAGE_SHIFT:
map_handle_folder_changed(map, event, event->folder);
break;
+ case MAP_ET_MEMORY_FULL:
+ case MAP_ET_MEMORY_AVAILABLE:
default:
break;
}
diff --git a/obexd/plugins/vcard.c b/obexd/plugins/vcard.c
index b36e4bf..aaa126b 100644
--- a/obexd/plugins/vcard.c
+++ b/obexd/plugins/vcard.c
@@ -574,6 +574,7 @@ static void vcard_printf_email(GString *vcards, uint8_t format,
else if (format == FORMAT_VCARD30)
category_string = "TYPE=INTERNET;TYPE=WORK";
break;
+ case FIELD_TYPE_OTHER:
default:
if (format == FORMAT_VCARD21)
category_string = "INTERNET";
@@ -616,6 +617,7 @@ static void vcard_printf_url(GString *vcards, uint8_t format,
else if (format == FORMAT_VCARD30)
category_string = "TYPE=INTERNET;TYPE=WORK";
break;
+ case FIELD_TYPE_OTHER:
default:
if (format == FORMAT_VCARD21)
category_string = "INTERNET";
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 09/13] shared: List all enum values in switch
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
` (6 preceding siblings ...)
2014-12-02 17:28 ` [PATCH 08/13] obexd: " Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-02 17:28 ` [PATCH 10/13] android: " Szymon Janc
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
As described in coding style M10.
---
src/shared/att.c | 15 +++++++++++++++
src/shared/gatt-helpers.c | 1 +
src/shared/gatt-server.c | 1 +
src/shared/hfp.c | 9 +++++++++
src/shared/io-glib.c | 3 +++
5 files changed, 29 insertions(+)
diff --git a/src/shared/att.c b/src/shared/att.c
index bc01827..ee425d8 100644
--- a/src/shared/att.c
+++ b/src/shared/att.c
@@ -488,6 +488,12 @@ static bool can_write_data(struct io *io, void *user_data)
case ATT_OP_TYPE_RSP:
/* Set in_req to false to indicate that no request is pending */
att->in_req = false;
+
+ /* Fall through to the next case */
+ case ATT_OP_TYPE_CMD:
+ case ATT_OP_TYPE_NOT:
+ case ATT_OP_TYPE_CONF:
+ case ATT_OP_TYPE_UNKNOWN:
default:
destroy_att_send_op(op);
return true;
@@ -784,6 +790,10 @@ static bool can_read_data(struct io *io, void *user_data)
att->in_req = true;
/* Fall through to the next case */
+ case ATT_OP_TYPE_CMD:
+ case ATT_OP_TYPE_NOT:
+ case ATT_OP_TYPE_UNKNOWN:
+ case ATT_OP_TYPE_IND:
default:
/* For all other opcodes notify the upper layer of the PDU and
* let them act on it.
@@ -1067,6 +1077,11 @@ unsigned int bt_att_send(struct bt_att *att, uint8_t opcode,
case ATT_OP_TYPE_IND:
result = queue_push_tail(att->ind_queue, op);
break;
+ case ATT_OP_TYPE_CMD:
+ case ATT_OP_TYPE_NOT:
+ case ATT_OP_TYPE_UNKNOWN:
+ case ATT_OP_TYPE_RSP:
+ case ATT_OP_TYPE_CONF:
default:
result = queue_push_tail(att->write_queue, op);
break;
diff --git a/src/shared/gatt-helpers.c b/src/shared/gatt-helpers.c
index dc4a8e8..c6e179c 100644
--- a/src/shared/gatt-helpers.c
+++ b/src/shared/gatt-helpers.c
@@ -581,6 +581,7 @@ static void put_uuid_le(const bt_uuid_t *src, void *dst)
bt_uuid_to_uuid128(src, &uuid);
bswap_128(&uuid.value.u128, dst);
break;
+ case BT_UUID_UNSPEC:
default:
break;
}
diff --git a/src/shared/gatt-server.c b/src/shared/gatt-server.c
index ef91289..5eb2e4f 100644
--- a/src/shared/gatt-server.c
+++ b/src/shared/gatt-server.c
@@ -512,6 +512,7 @@ static void put_uuid_le(const bt_uuid_t *src, void *dst)
bt_uuid_to_uuid128(src, &uuid);
bswap_128(&uuid.value.u128, dst);
break;
+ case BT_UUID_UNSPEC:
default:
break;
}
diff --git a/src/shared/hfp.c b/src/shared/hfp.c
index 5a91d12..0a5a57e 100644
--- a/src/shared/hfp.c
+++ b/src/shared/hfp.c
@@ -738,6 +738,15 @@ bool hfp_gw_send_result(struct hfp_gw *hfp, enum hfp_result result)
case HFP_RESULT_ERROR:
str = "ERROR";
break;
+ case HFP_RESULT_RING:
+ case HFP_RESULT_NO_CARRIER:
+ case HFP_RESULT_BUSY:
+ case HFP_RESULT_NO_ANSWER:
+ case HFP_RESULT_DELAYED:
+ case HFP_RESULT_BLACKLISTED:
+ case HFP_RESULT_CME_ERROR:
+ case HFP_RESULT_NO_DIALTONE:
+ case HFP_RESULT_CONNECT:
default:
return false;
}
diff --git a/src/shared/io-glib.c b/src/shared/io-glib.c
index e9578e1..6687a6b 100644
--- a/src/shared/io-glib.c
+++ b/src/shared/io-glib.c
@@ -220,6 +220,9 @@ static bool io_set_handler(struct io *io, GIOCondition cond,
case G_IO_HUP:
watch = &io->disconnect_watch;
break;
+ case G_IO_PRI:
+ case G_IO_ERR:
+ case G_IO_NVAL:
default:
return false;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 10/13] android: List all enum values in switch
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
` (7 preceding siblings ...)
2014-12-02 17:28 ` [PATCH 09/13] shared: " Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-02 17:28 ` [PATCH 11/13] unit: " Szymon Janc
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
As described in coding style M10.
---
android/avdtp.c | 3 +++
android/avdtptest.c | 1 +
android/client/if-bt.c | 28 +++++++++++++++++++++++++++
android/gatt.c | 1 +
android/hal-bluetooth.c | 15 +++++++++++++++
android/hal-utils.c | 2 ++
android/handsfree-client.c | 3 +++
android/system/audio.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++
8 files changed, 101 insertions(+)
diff --git a/android/avdtp.c b/android/avdtp.c
index 9f2527f..853fdf3 100644
--- a/android/avdtp.c
+++ b/android/avdtp.c
@@ -1765,6 +1765,9 @@ static gboolean avdtp_delayreport_cmd(struct avdtp *session,
case AVDTP_STATE_CLOSING:
err = AVDTP_BAD_STATE;
goto failed;
+ case AVDTP_STATE_CONFIGURED:
+ case AVDTP_STATE_OPEN:
+ case AVDTP_STATE_STREAMING:
default:
break;
}
diff --git a/android/avdtptest.c b/android/avdtptest.c
index a56b9c0..ce39519 100644
--- a/android/avdtptest.c
+++ b/android/avdtptest.c
@@ -141,6 +141,7 @@ static void send_command(void)
case CMD_DELAY:
avdtp_delay_report(avdtp , avdtp_stream , 250);
break;
+ case CMD_NONE:
default:
break;
}
diff --git a/android/client/if-bt.c b/android/client/if-bt.c
index 4f1a9d9..776098e 100644
--- a/android/client/if-bt.c
+++ b/android/client/if-bt.c
@@ -289,6 +289,8 @@ static void ssp_request_cb(bt_bdaddr_t *remote_bd_addr, bt_bdname_t *bd_name,
terminal_prompt_for(prompt, ssp_request_yes_no_answer);
break;
+ case BT_SSP_VARIANT_PASSKEY_ENTRY:
+ case BT_SSP_VARIANT_PASSKEY_NOTIFICATION:
default:
haltest_info("Not automatically handled\n");
break;
@@ -554,6 +556,19 @@ static void set_adapter_property_p(int argc, const char **argv)
property.len = sizeof(timeout);
break;
+ case BT_PROPERTY_BDADDR:
+ case BT_PROPERTY_UUIDS:
+ case BT_PROPERTY_CLASS_OF_DEVICE:
+ case BT_PROPERTY_TYPE_OF_DEVICE:
+ case BT_PROPERTY_SERVICE_RECORD:
+ case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
+ case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
+ case BT_PROPERTY_REMOTE_RSSI:
+ case BT_PROPERTY_REMOTE_VERSION_INFO:
+ case BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP:
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ case BT_PROPERTY_LOCAL_LE_FEATURES:
+#endif
default:
haltest_error("Invalid property %s\n", argv[3]);
return;
@@ -630,6 +645,19 @@ static void set_remote_device_property_p(int argc, const char **argv)
property.len = strlen(argv[4]);
property.val = (char *) argv[4];
break;
+ case BT_PROPERTY_BDNAME:
+ case BT_PROPERTY_BDADDR:
+ case BT_PROPERTY_UUIDS:
+ case BT_PROPERTY_CLASS_OF_DEVICE:
+ case BT_PROPERTY_TYPE_OF_DEVICE:
+ case BT_PROPERTY_SERVICE_RECORD:
+ case BT_PROPERTY_ADAPTER_SCAN_MODE:
+ case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
+ case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
+ case BT_PROPERTY_REMOTE_RSSI:
+ case BT_PROPERTY_REMOTE_VERSION_INFO:
+ case BT_PROPERTY_LOCAL_LE_FEATURES:
+ case BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP:
default:
return;
}
diff --git a/android/gatt.c b/android/gatt.c
index b9b3c7b..3cf4f67 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -5146,6 +5146,7 @@ static uint32_t add_sdp_record(const bt_uuid_t *uuid, uint16_t start,
case BT_UUID128:
sdp_uuid128_create(&u, &uuid->value.u128);
break;
+ case BT_UUID_UNSPEC:
default:
return 0;
}
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index cceb196..b13cffe 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -116,6 +116,21 @@ static void adapter_prop_from_hal(const bt_property_t *property, uint8_t *type,
case HAL_PROP_ADAPTER_SCAN_MODE:
enum_prop_from_hal(property, len, val, bt_scan_mode_t);
break;
+ case BT_PROPERTY_BDNAME:
+ case BT_PROPERTY_BDADDR:
+ case BT_PROPERTY_UUIDS:
+ case BT_PROPERTY_CLASS_OF_DEVICE:
+ case BT_PROPERTY_TYPE_OF_DEVICE:
+ case BT_PROPERTY_SERVICE_RECORD:
+ case BT_PROPERTY_ADAPTER_BONDED_DEVICES:
+ case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT:
+ case BT_PROPERTY_REMOTE_FRIENDLY_NAME:
+ case BT_PROPERTY_REMOTE_RSSI:
+ case BT_PROPERTY_REMOTE_VERSION_INFO:
+ case BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP:
+#if ANDROID_VERSION >= PLATFORM_VER(5, 0, 0)
+ case BT_PROPERTY_LOCAL_LE_FEATURES:
+#endif
default:
*len = property->len;
memcpy(val, property->val, property->len);
diff --git a/android/hal-utils.c b/android/hal-utils.c
index f18a82c..004d89d 100644
--- a/android/hal-utils.c
+++ b/android/hal-utils.c
@@ -395,6 +395,8 @@ const char *btproperty2str(const bt_property_t *property)
}
break;
#endif
+ case BT_PROPERTY_REMOTE_VERSION_INFO:
+ case BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP:
default:
sprintf(p, "%p", property->val);
}
diff --git a/android/handsfree-client.c b/android/handsfree-client.c
index 9818a47..a81830c 100644
--- a/android/handsfree-client.c
+++ b/android/handsfree-client.c
@@ -428,6 +428,9 @@ static void cmd_complete_cb(enum hfp_result result, enum hfp_error cme_err,
ev.type = HAL_HF_CLIENT_CMD_COMP_ERR_CME;
ev.cme = cme_err;
break;
+ case HFP_RESULT_CONNECT:
+ case HFP_RESULT_RING:
+ case HFP_RESULT_NO_DIALTONE:
default:
error("hf-client: Unknown error code %d", result);
ev.type = HAL_HF_CLIENT_CMD_COMP_ERR;
diff --git a/android/system/audio.h b/android/system/audio.h
index 1d045b3..d2da76d 100644
--- a/android/system/audio.h
+++ b/android/system/audio.h
@@ -1295,6 +1295,30 @@ static inline bool audio_is_valid_format(audio_format_t format)
case AUDIO_FORMAT_PCM_FLOAT:
case AUDIO_FORMAT_PCM_24_BIT_PACKED:
return true;
+ case AUDIO_FORMAT_INVALID:
+ case AUDIO_FORMAT_DEFAULT:
+ case AUDIO_FORMAT_MP3:
+ case AUDIO_FORMAT_AMR_NB:
+ case AUDIO_FORMAT_AMR_WB:
+ case AUDIO_FORMAT_AAC:
+ case AUDIO_FORMAT_HE_AAC_V1:
+ case AUDIO_FORMAT_HE_AAC_V2:
+ case AUDIO_FORMAT_VORBIS:
+ case AUDIO_FORMAT_OPUS:
+ case AUDIO_FORMAT_AC3:
+ case AUDIO_FORMAT_E_AC3:
+ case AUDIO_FORMAT_MAIN_MASK:
+ case AUDIO_FORMAT_SUB_MASK:
+ case AUDIO_FORMAT_AAC_MAIN:
+ case AUDIO_FORMAT_AAC_LC:
+ case AUDIO_FORMAT_AAC_SSR:
+ case AUDIO_FORMAT_AAC_LTP:
+ case AUDIO_FORMAT_AAC_HE_V1:
+ case AUDIO_FORMAT_AAC_SCALABLE:
+ case AUDIO_FORMAT_AAC_ERLC:
+ case AUDIO_FORMAT_AAC_LD:
+ case AUDIO_FORMAT_AAC_HE_V2:
+ case AUDIO_FORMAT_AAC_ELD:
default:
return false;
}
@@ -1341,6 +1365,30 @@ static inline size_t audio_bytes_per_sample(audio_format_t format)
case AUDIO_FORMAT_PCM_FLOAT:
size = sizeof(float);
break;
+ case AUDIO_FORMAT_INVALID:
+ case AUDIO_FORMAT_DEFAULT:
+ case AUDIO_FORMAT_MP3:
+ case AUDIO_FORMAT_AMR_NB:
+ case AUDIO_FORMAT_AMR_WB:
+ case AUDIO_FORMAT_AAC:
+ case AUDIO_FORMAT_HE_AAC_V1:
+ case AUDIO_FORMAT_HE_AAC_V2:
+ case AUDIO_FORMAT_VORBIS:
+ case AUDIO_FORMAT_OPUS:
+ case AUDIO_FORMAT_AC3:
+ case AUDIO_FORMAT_E_AC3:
+ case AUDIO_FORMAT_MAIN_MASK:
+ case AUDIO_FORMAT_SUB_MASK:
+ case AUDIO_FORMAT_AAC_MAIN:
+ case AUDIO_FORMAT_AAC_LC:
+ case AUDIO_FORMAT_AAC_SSR:
+ case AUDIO_FORMAT_AAC_LTP:
+ case AUDIO_FORMAT_AAC_HE_V1:
+ case AUDIO_FORMAT_AAC_SCALABLE:
+ case AUDIO_FORMAT_AAC_ERLC:
+ case AUDIO_FORMAT_AAC_LD:
+ case AUDIO_FORMAT_AAC_HE_V2:
+ case AUDIO_FORMAT_AAC_ELD:
default:
break;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 11/13] unit: List all enum values in switch
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
` (8 preceding siblings ...)
2014-12-02 17:28 ` [PATCH 10/13] android: " Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-02 17:28 ` [PATCH 12/13] tools: " Szymon Janc
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
As described in coding style M10.
---
unit/test-uuid.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/unit/test-uuid.c b/unit/test-uuid.c
index 6c7e9d0..49ea031 100644
--- a/unit/test-uuid.c
+++ b/unit/test-uuid.c
@@ -115,6 +115,7 @@ static void test_uuid(gconstpointer data)
*/
g_assert(memcmp(&uuid.value.u128, test_data->binary, 16) == 0);
break;
+ case BT_UUID_UNSPEC:
default:
return;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 12/13] tools: List all enum values in switch
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
` (9 preceding siblings ...)
2014-12-02 17:28 ` [PATCH 11/13] unit: " Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-02 17:28 ` [PATCH 13/13] build: Enable -Wswitch-enum in maintainer mode Szymon Janc
2014-12-08 13:25 ` [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
As described in coding style M10.
---
tools/hid2hci.c | 1 +
tools/parser/lmp.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/tools/hid2hci.c b/tools/hid2hci.c
index 2dbfca7..a183bfa 100644
--- a/tools/hid2hci.c
+++ b/tools/hid2hci.c
@@ -382,6 +382,7 @@ int main(int argc, char *argv[])
err = hid_switch_logitech(device);
break;
}
+ case METHOD_UNDEF:
default:
break;
}
diff --git a/tools/parser/lmp.c b/tools/parser/lmp.c
index c303c1b..3f65ace 100644
--- a/tools/parser/lmp.c
+++ b/tools/parser/lmp.c
@@ -120,6 +120,11 @@ static inline void comb_key(struct frame *frm)
memcpy(pairing_data.comb_key_s, val, 16);
pairing_state = AU_RAND_M;
break;
+ case IN_RAND:
+ case AU_RAND_M:
+ case AU_RAND_S:
+ case SRES_M:
+ case SRES_S:
default:
pairing_state = IN_RAND;
break;
@@ -139,6 +144,11 @@ static inline void au_rand(struct frame *frm)
memcpy(pairing_data.au_rand_s, val, 16);
pairing_state = SRES_S;
break;
+ case COMB_KEY_M:
+ case COMB_KEY_S:
+ case IN_RAND:
+ case SRES_M:
+ case SRES_S:
default:
pairing_state = IN_RAND;
break;
@@ -159,6 +169,11 @@ static inline void sres(struct frame *frm)
pairing_state = IN_RAND;
pairing_data_dump();
break;
+ case COMB_KEY_M:
+ case COMB_KEY_S:
+ case IN_RAND:
+ case AU_RAND_M:
+ case AU_RAND_S:
default:
pairing_state = IN_RAND;
break;
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH 13/13] build: Enable -Wswitch-enum in maintainer mode
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
` (10 preceding siblings ...)
2014-12-02 17:28 ` [PATCH 12/13] tools: " Szymon Janc
@ 2014-12-02 17:28 ` Szymon Janc
2014-12-08 13:25 ` [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-02 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This makes GCC verify if all enum values are listed in switch.
---
acinclude.m4 | 1 +
1 file changed, 1 insertion(+)
diff --git a/acinclude.m4 b/acinclude.m4
index 2065852..4c241bf 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -20,6 +20,7 @@ AC_DEFUN([COMPILER_FLAGS], [
with_cflags="$with_cflags -Wmissing-declarations"
with_cflags="$with_cflags -Wredundant-decls"
with_cflags="$with_cflags -Wcast-align"
+ with_cflags="$with_cflags -Wswitch-enum"
with_cflags="$with_cflags -DG_DISABLE_DEPRECATED"
with_cflags="$with_cflags -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_28"
with_cflags="$with_cflags -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_28"
--
1.9.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
` (11 preceding siblings ...)
2014-12-02 17:28 ` [PATCH 13/13] build: Enable -Wswitch-enum in maintainer mode Szymon Janc
@ 2014-12-08 13:25 ` Szymon Janc
12 siblings, 0 replies; 14+ messages in thread
From: Szymon Janc @ 2014-12-08 13:25 UTC (permalink / raw)
To: linux-bluetooth
On Tuesday 02 of December 2014 18:28:26 Szymon Janc wrote:
> Since GCC has option (-Wswitch-enum) that ensure all enum values are
> handled inside switch it is no longer necessary to forbit default in
> such case.
> ---
> doc/coding-style.txt | 24 ++++++++++++++++++------
> 1 file changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/doc/coding-style.txt b/doc/coding-style.txt
> index 59df64a..b3fbd2e 100644
> --- a/doc/coding-style.txt
> +++ b/doc/coding-style.txt
> @@ -175,10 +175,11 @@ enum animal_type {
> M10: Enum as switch variable
> ============================
>
> -If the variable of a switch is an enum, you must not include a default in
> -switch body. The reason for this is: If later on you modify the enum by
> adding -a new type, and forget to change the switch accordingly, the
> compiler will -complain the new added type hasn't been handled.
> +If the variable of a switch is an enum, you must include all values in
> +switch body even if providing default. This is enforced by compiler option
> +enabling extra warning in such case. The reason for this is to ensure that
> if +later on enum is modified and one forget to change the switch
> accordingly, the +compiler will complain the new added type hasn't been
> handled.
>
> Example:
>
> @@ -190,7 +191,7 @@ enum animal_type {
>
> enum animal_type t;
>
> -switch (t) {
> +switch (t) { // OK
> case ANIMAL_TYPE_FOUR_LEGS:
> ...
> break;
> @@ -200,7 +201,18 @@ case ANIMAL_TYPE_EIGHT_LEGS:
> case ANIMAL_TYPE_TWO_LEGS:
> ...
> break;
> -default: // wrong
> +default:
> + break;
> +}
> +
> +switch (t) { // Wrong
> +case ANIMAL_TYPE_FOUR_LEGS:
> + ...
> + break;
> +case ANIMAL_TYPE_TWO_LEGS:
> + ...
> + break;
> +default:
> break;
> }
Pushed.
--
BR
Szymon Janc
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2014-12-08 13:25 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-02 17:28 [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
2014-12-02 17:28 ` [PATCH 02/13] profiles: List all enum values in switch Szymon Janc
2014-12-02 17:28 ` [PATCH 03/13] lib: " Szymon Janc
2014-12-02 17:28 ` [PATCH 04/13] btio: " Szymon Janc
2014-12-02 17:28 ` [PATCH 05/13] attrib: " Szymon Janc
2014-12-02 17:28 ` [PATCH 06/13] core: " Szymon Janc
2014-12-02 17:28 ` [PATCH 07/13] gobex: " Szymon Janc
2014-12-02 17:28 ` [PATCH 08/13] obexd: " Szymon Janc
2014-12-02 17:28 ` [PATCH 09/13] shared: " Szymon Janc
2014-12-02 17:28 ` [PATCH 10/13] android: " Szymon Janc
2014-12-02 17:28 ` [PATCH 11/13] unit: " Szymon Janc
2014-12-02 17:28 ` [PATCH 12/13] tools: " Szymon Janc
2014-12-02 17:28 ` [PATCH 13/13] build: Enable -Wswitch-enum in maintainer mode Szymon Janc
2014-12-08 13:25 ` [PATCH 01/13] doc/coding-style: Update 'enum as switch variable' section Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).