From patchwork Tue Jan 16 14:00:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520846 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBA8E1BF22 for ; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EOBE93on" Received: by smtp.kernel.org (Postfix) with ESMTPS id 653A8C43390; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=cY1EFVtNLYb6BnE4vY936MpLQpP0/+KwBPVabl5ffKM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=EOBE93onrejdTMpfclbXdi7VLrBcHAhK+G0WSR1lQRZd2UmhB3l9tGo8RRB+tpSo7 u/49JaihkRlNZNclHlYyP6xo4jEgOsbQa1bUj9z4tOjGYLW4KYjsHZihW/GzNRxZ/r 7fIR4TTw2faDbjy1CDhwO9qLwCGL4mI1oTMFnZRev5LBuxof71jxWk0BZ8vnRT9aYf harR5Q8r3TmX0GQNDrM2TUfDATskDJDAcMo8TD8WDWgqg2s2A/m7DzyVqCGUnZ10DI 3gdfkoR28yQhBbBFVdd62AmIo5jThT77W0hIts6DpxKYUTwlSMOhBer9Nkr7tavJb4 B/2/T3wz01JUg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F55AC47077; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:26 +0000 Subject: [PATCH BlueZ 01/20] src: const annotate the bluetooth plugin API Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-1-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=3210; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=I/Oyu/RLwK0OSGqSTjaoDbqWB2lkqBZyCxJ1p08rwK0=; b=B4d7cr/nEAueGQRAzNE6jXDNbg/BF+MsrQJuV3PGUMU58kDpixDvokem2nLIHF1Mcshsz2RN0 m5a2Pe0JHSuCGMXYZtL9lxOfOlTEmcCfzumhnXPLpcyHUdgLWp+/8ls X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov The data was never mutable, so there's no API/ABI breakage here. --- src/genbuiltin | 4 ++-- src/log.c | 2 +- src/plugin.c | 6 +++--- src/plugin.h | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/genbuiltin b/src/genbuiltin index 8b6f04761..010e4ed2f 100755 --- a/src/genbuiltin +++ b/src/genbuiltin @@ -2,11 +2,11 @@ for i in $* do - echo "extern struct bluetooth_plugin_desc __bluetooth_builtin_$i;" + echo "extern const struct bluetooth_plugin_desc __bluetooth_builtin_$i;" done echo -echo "static struct bluetooth_plugin_desc *__bluetooth_builtin[] = {" +echo "static const struct bluetooth_plugin_desc *__bluetooth_builtin[] = {" for i in $* do diff --git a/src/log.c b/src/log.c index 0155a6bba..ca8ae2d0e 100644 --- a/src/log.c +++ b/src/log.c @@ -123,7 +123,7 @@ extern struct btd_debug_desc __stop___debug[]; static char **enabled = NULL; -static gboolean is_enabled(struct btd_debug_desc *desc) +static gboolean is_enabled(const struct btd_debug_desc *desc) { int i; diff --git a/src/plugin.c b/src/plugin.c index 80990f8c3..69c4138f0 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -31,7 +31,7 @@ static GSList *plugins = NULL; struct bluetooth_plugin { void *handle; gboolean active; - struct bluetooth_plugin_desc *desc; + const struct bluetooth_plugin_desc *desc; }; static int compare_priority(gconstpointer a, gconstpointer b) @@ -42,7 +42,7 @@ static int compare_priority(gconstpointer a, gconstpointer b) return plugin2->desc->priority - plugin1->desc->priority; } -static gboolean add_plugin(void *handle, struct bluetooth_plugin_desc *desc) +static gboolean add_plugin(void *handle, const struct bluetooth_plugin_desc *desc) { struct bluetooth_plugin *plugin; @@ -141,7 +141,7 @@ gboolean plugin_init(const char *enable, const char *disable) goto start; while ((file = g_dir_read_name(dir)) != NULL) { - struct bluetooth_plugin_desc *desc; + const struct bluetooth_plugin_desc *desc; void *handle; char *filename; diff --git a/src/plugin.h b/src/plugin.h index a5f92a557..dcf54a5bf 100644 --- a/src/plugin.h +++ b/src/plugin.h @@ -23,7 +23,7 @@ struct bluetooth_plugin_desc { #ifdef BLUETOOTH_PLUGIN_BUILTIN #define BLUETOOTH_PLUGIN_DEFINE(name, version, priority, init, exit) \ - struct bluetooth_plugin_desc __bluetooth_builtin_ ## name = { \ + const struct bluetooth_plugin_desc __bluetooth_builtin_ ## name = { \ #name, version, priority, init, exit \ }; #else @@ -32,9 +32,9 @@ struct bluetooth_plugin_desc { __attribute__ ((weak, visibility("hidden"))); \ extern struct btd_debug_desc __stop___debug[] \ __attribute__ ((weak, visibility("hidden"))); \ - extern struct bluetooth_plugin_desc bluetooth_plugin_desc \ + extern const struct bluetooth_plugin_desc bluetooth_plugin_desc \ __attribute__ ((visibility("default"))); \ - struct bluetooth_plugin_desc bluetooth_plugin_desc = { \ + const struct bluetooth_plugin_desc bluetooth_plugin_desc = { \ #name, version, priority, init, exit, \ __start___debug, __stop___debug \ }; From patchwork Tue Jan 16 14:00:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520847 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBA6C1BF21 for ; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eITnELqp" Received: by smtp.kernel.org (Postfix) with ESMTPS id 70C1FC433C7; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=cWdugJEuHZ01hL67IcYj3CskgRjmmsH+t0DUp0K4p1k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=eITnELqpiLzQJdPg2jgIk42wkz3Ln1hZpS+CWfvLWbsxtN3FKFfSzFHZ9ctfRGF6i U1QY9aprVijerHX3U5R0RuQTIV/Af1DGpzRqst4eTIicwvr6l9/Dq+zlHXC1OjeC+T Xc6qzjY3R7LGZDNvDNockDKQVDUnY+7gqlw3jolCfbrfuhLuO3Jzls5HEW2n6Io3+f da5N448yIhya1J/hHIRAryLZAwjRYjBWoCYguqPgtVJTKxDz6xEHHa6jvukZk9bRZM 7CRdtPdZKvQnWK+VoH+VGQo6EdhyXr5z97pdNplgaheHWqKxGJAnmgW6dmFqWq3kfK zB4cVxJDFr4UQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59C61C47DA9; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:27 +0000 Subject: [PATCH BlueZ 02/20] monitor: const annotate util_ltv_debugger instances and API Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-2-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=2252; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=SWETOT2uVy6nUDBhnJWLVd9iTSKcoM2gRJYy59LqmtQ=; b=LSW+gQOehX9oFttXX2MOvyPWVh81sCxYC31oTPd+wg3hT0QDevNUgrrtgAbIOlLsZDVSm6NCK 7BsgwcMBXFCDTKXIR0rHHqGyN5vHq0yCvUV1y9dLjxmFQARNa4QH/Yn X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- monitor/att.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/monitor/att.c b/monitor/att.c index 9db273223..51a5a759c 100644 --- a/monitor/att.c +++ b/monitor/att.c @@ -683,7 +683,7 @@ static void print_ltv(const char *str, void *user_data) } static bool print_ase_lv(const struct l2cap_frame *frame, const char *label, - struct util_ltv_debugger *decoder, size_t decoder_len) + const struct util_ltv_debugger *decoder, size_t decoder_len) { struct bt_hci_lv_data *lv; @@ -705,7 +705,7 @@ static bool print_ase_lv(const struct l2cap_frame *frame, const char *label, } static bool print_ase_cc(const struct l2cap_frame *frame, const char *label, - struct util_ltv_debugger *decoder, size_t decoder_len) + const struct util_ltv_debugger *decoder, size_t decoder_len) { return print_ase_lv(frame, label, decoder, decoder_len); } @@ -813,7 +813,7 @@ done: print_hex_field(" Data", frame.data, frame.size); } -struct util_ltv_debugger ase_metadata_table[] = { +static const struct util_ltv_debugger ase_metadata_table[] = { UTIL_LTV_DEBUG(0x01, ase_debug_preferred_context), UTIL_LTV_DEBUG(0x02, ase_debug_context), UTIL_LTV_DEBUG(0x03, ase_debug_program_info), @@ -994,7 +994,7 @@ done: print_hex_field(" Data", frame.data, frame.size); } -struct util_ltv_debugger pac_cap_table[] = { +static const struct util_ltv_debugger pac_cap_table[] = { UTIL_LTV_DEBUG(0x01, pac_decode_freq), UTIL_LTV_DEBUG(0x02, pac_decode_duration), UTIL_LTV_DEBUG(0x03, pac_decode_channels), @@ -1336,7 +1336,7 @@ done: print_hex_field(" Data", frame.data, frame.size); } -struct util_ltv_debugger ase_cc_table[] = { +static const struct util_ltv_debugger ase_cc_table[] = { UTIL_LTV_DEBUG(0x01, ase_debug_freq), UTIL_LTV_DEBUG(0x02, ase_debug_duration), UTIL_LTV_DEBUG(0x03, ase_debug_location), @@ -2769,7 +2769,7 @@ static const struct big_enc_decoder { static bool print_subgroup_lv(const struct l2cap_frame *frame, const char *label, - struct util_ltv_debugger *debugger, + const struct util_ltv_debugger *debugger, size_t debugger_len) { struct bt_hci_lv_data *lv; From patchwork Tue Jan 16 14:00:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520848 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5BF91BF24 for ; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FzC+T/+8" Received: by smtp.kernel.org (Postfix) with ESMTPS id 78480C43394; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=cqdV2I3I+b5GbZV1r5Mv7tER+zyrDeorukPEH9l5Wa0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=FzC+T/+8G+lItp5ZUCQpM3qNusFPxq6b45yJo3BmA+ckU5r3lyMgW3vab7MrBXXy/ wUctUYXPiL1WZI4yHpC7JLhRMJVJG1DEcc7zxPAfa9gJQWUhclRyj6ObY5IRgHSv36 EzpnpXdP3/eaDuzJTFh2/w8E+eFkmq90E4a8DbzoEbqxHRB49s8MuZuJesYQjkN9Vw gRRUAW9o72QN6e4caJBsDtJjwQ049RKPNEbPq7CcEdknPCrOnr7gq2N5QXki6jJ+L5 0EC9paksHyErRA1aruEGqXQ7io3DcapP1QikdYokUN8fk97GCuQyzNuUDNK+Yusuhk kc2vAd5gbMrgg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64DABC47DA6; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:28 +0000 Subject: [PATCH BlueZ 03/20] monitor: const annotate cmd/handler tables Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-3-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=5458; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=G1oEfndUXIx9ZaeJOw7f2lTR5gMal19DcxjjtpnQtrs=; b=R7vMkF9cbteTavwtxRP9dxHoEc0n4CB2WuzcnwQx4JRJffUWOWPULHeMofmlzGEjadiCn6Uld +g0KVozorfOBYoSyJXe1jvS18Tw4pUcOaVtQDjfKbFjqZZW2QXYoKNY X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- monitor/att.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/monitor/att.c b/monitor/att.c index 51a5a759c..d016e58df 100644 --- a/monitor/att.c +++ b/monitor/att.c @@ -1710,7 +1710,7 @@ static bool ase_release_cmd(const struct l2cap_frame *frame) .func = _func, \ } -struct ase_cmd { +static const struct ase_cmd { const char *desc; bool (*func)(const struct l2cap_frame *frame); } ase_cmd_table[] = { @@ -1732,7 +1732,7 @@ struct ase_cmd { ASE_CMD(0x08, "Release", ase_release_cmd), }; -static struct ase_cmd *ase_get_cmd(uint8_t op) +static const struct ase_cmd *ase_get_cmd(uint8_t op) { if (op > ARRAY_SIZE(ase_cmd_table)) return NULL; @@ -1743,7 +1743,7 @@ static struct ase_cmd *ase_get_cmd(uint8_t op) static void print_ase_cmd(const struct l2cap_frame *frame) { uint8_t op, num, i; - struct ase_cmd *cmd; + const struct ase_cmd *cmd; if (!l2cap_frame_get_u8((void *)frame, &op)) { print_text(COLOR_ERROR, "opcode: invalid size"); @@ -1911,7 +1911,7 @@ static bool print_ase_cp_rsp_reason(const struct l2cap_frame *frame) static void print_ase_cp_rsp(const struct l2cap_frame *frame) { uint8_t op, num, i; - struct ase_cmd *cmd; + const struct ase_cmd *cmd; if (!l2cap_frame_get_u8((void *)frame, &op)) { print_text(COLOR_ERROR, " opcode: invalid size"); @@ -2161,7 +2161,7 @@ static bool vcs_absolute_cmd(const struct l2cap_frame *frame) .func = _func, \ } -struct vcs_cmd { +static const struct vcs_cmd { const char *desc; bool (*func)(const struct l2cap_frame *frame); } vcs_cmd_table[] = { @@ -2181,7 +2181,7 @@ struct vcs_cmd { VCS_CMD(0x06, "Mute", vcs_config_cmd), }; -static struct vcs_cmd *vcs_get_cmd(uint8_t op) +static const struct vcs_cmd *vcs_get_cmd(uint8_t op) { if (op > ARRAY_SIZE(vcs_cmd_table)) return NULL; @@ -2192,7 +2192,7 @@ static struct vcs_cmd *vcs_get_cmd(uint8_t op) static void print_vcs_cmd(const struct l2cap_frame *frame) { uint8_t op; - struct vcs_cmd *cmd; + const struct vcs_cmd *cmd; if (!l2cap_frame_get_u8((void *)frame, &op)) { print_text(COLOR_ERROR, "opcode: invalid size"); @@ -3135,7 +3135,7 @@ static void bcast_audio_scan_cp_remove_src_cmd(const struct l2cap_frame *frame) print_field(" Source_ID: %u", id); } -struct bcast_audio_scan_cp_cmd { +static const struct bcast_audio_scan_cp_cmd { const char *desc; void (*func)(const struct l2cap_frame *frame); } bcast_audio_scan_cp_cmd_table[] = { @@ -3157,7 +3157,7 @@ struct bcast_audio_scan_cp_cmd { bcast_audio_scan_cp_remove_src_cmd), }; -static struct bcast_audio_scan_cp_cmd *bcast_audio_scan_cp_get_cmd(uint8_t op) +static const struct bcast_audio_scan_cp_cmd *bcast_audio_scan_cp_get_cmd(uint8_t op) { if (op > ARRAY_SIZE(bcast_audio_scan_cp_cmd_table)) return NULL; @@ -3168,7 +3168,7 @@ static struct bcast_audio_scan_cp_cmd *bcast_audio_scan_cp_get_cmd(uint8_t op) static void print_bcast_audio_scan_cp_cmd(const struct l2cap_frame *frame) { uint8_t op; - struct bcast_audio_scan_cp_cmd *cmd; + const struct bcast_audio_scan_cp_cmd *cmd; if (!l2cap_frame_get_u8((void *)frame, &op)) { print_text(COLOR_ERROR, "Opcode: invalid size"); @@ -3340,7 +3340,7 @@ static void bgr_features_read(const struct l2cap_frame *frame) .notify = _notify \ } -struct gatt_handler { +static const struct gatt_handler { bt_uuid_t uuid; void (*read)(const struct l2cap_frame *frame); void (*write)(const struct l2cap_frame *frame); @@ -3392,7 +3392,7 @@ struct gatt_handler { GMAS }; -static struct gatt_handler *get_handler_uuid(const bt_uuid_t *uuid) +static const struct gatt_handler *get_handler_uuid(const bt_uuid_t *uuid) { size_t i; @@ -3400,7 +3400,7 @@ static struct gatt_handler *get_handler_uuid(const bt_uuid_t *uuid) return NULL; for (i = 0; i < ARRAY_SIZE(gatt_handlers); i++) { - struct gatt_handler *handler = &gatt_handlers[i]; + const struct gatt_handler *handler = &gatt_handlers[i]; if (!bt_uuid_cmp(&handler->uuid, uuid)) return handler; @@ -3409,7 +3409,7 @@ static struct gatt_handler *get_handler_uuid(const bt_uuid_t *uuid) return NULL; } -static struct gatt_handler *get_handler(struct gatt_db_attribute *attr) +static const struct gatt_handler *get_handler(struct gatt_db_attribute *attr) { return get_handler_uuid(gatt_db_attribute_get_type(attr)); } @@ -3580,7 +3580,7 @@ static void queue_read(const struct l2cap_frame *frame, bt_uuid_t *uuid, struct att_conn_data *data; struct att_read *read; struct gatt_db_attribute *attr = NULL; - struct gatt_handler *handler; + const struct gatt_handler *handler; if (handle) { attr = get_attribute(frame, handle, false); @@ -3761,7 +3761,7 @@ static void print_write(const struct l2cap_frame *frame, uint16_t handle, size_t len) { struct gatt_db_attribute *attr; - struct gatt_handler *handler; + const struct gatt_handler *handler; print_handle(frame, handle, false); @@ -3837,7 +3837,7 @@ static void print_notify(const struct l2cap_frame *frame, uint16_t handle, size_t len) { struct gatt_db_attribute *attr; - struct gatt_handler *handler; + const struct gatt_handler *handler; struct l2cap_frame clone; print_handle(frame, handle, true); From patchwork Tue Jan 16 14:00:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520855 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 086AD1BDE2 for ; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DZwjJL0D" Received: by smtp.kernel.org (Postfix) with ESMTPS id 84F0DC43399; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=YDtggDbWyd/etpo+RvAJzGr0MRIxghX9+ZHGi2Em1a0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=DZwjJL0DVTVH+a3EuPTPP4GRtUkeREeQoRFkNKEMHt3oR7FbJlEQk0jsDBEABfILq 8xY36R53AI3ED1vMQ6YYpMqyN9zPkiFEQeL6AzfyMD9hUg7WESbtZTLuhOoymWMf6p SDVxsUKDNLk3JE8edSDjTrHp6C+wiXDxWZs96ju64aP4/7pTHJ8t1oSW/zjRhnlEqG QRsx3nUKd4wDI0GCumc8jzgjVZeJX2U/gGDy6SubLDoeIGjvA7npKp7jawidGRM6ZJ Y5lI6sLziVZjhs2siPoAZYjeVjKgZZza+tVPyME66BXI8QwbBM5rUp38erMaJlOfUF R2RhGwatkHDPg== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 771A4C47DAC; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:29 +0000 Subject: [PATCH BlueZ 04/20] monitor: const annotate misc arrays Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-4-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=3310; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=sDFz/h5HNC2kVyVsavc6FYhQwHcER0nnd3cc13qPQdk=; b=p+E599P8FUnPy1mWk/ocsd4lxhjB07GHNOyenW456WJYuZdwCMm8xAzwmuhjJTh7zyfaPDT8w zPuFMJDhn5fDgurnm4qC1eUio9V67HyWPRFrqNM4kOp0co5Uv6KauTA X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- monitor/att.c | 8 ++++---- monitor/avctp.c | 2 +- monitor/intel.c | 2 +- monitor/l2cap.c | 2 +- monitor/rfcomm.c | 2 +- monitor/sdp.c | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/monitor/att.c b/monitor/att.c index d016e58df..ac0d881fd 100644 --- a/monitor/att.c +++ b/monitor/att.c @@ -2581,7 +2581,7 @@ static void media_state_notify(const struct l2cap_frame *frame) print_media_state(frame); } -struct media_cp_opcode { +static const struct media_cp_opcode { uint8_t opcode; const char *opcode_str; } media_cp_opcode_table[] = { @@ -2739,7 +2739,7 @@ static void content_control_id_read(const struct l2cap_frame *frame) static const struct pa_sync_state_decoder { uint8_t code; - char *value; + const char *value; } pa_sync_state_decoders[] = { { 0x00, "Not synchronized to PA" }, { 0x01, "SyncInfo Request" }, @@ -2750,7 +2750,7 @@ static const struct pa_sync_state_decoder { static const struct cp_pa_sync_state_decoder { uint8_t code; - char *value; + const char *value; } cp_pa_sync_state_decoders[] = { { 0x00, "Do not synchronize to PA" }, { 0x01, "Synchronize to PA - PAST available" }, @@ -2759,7 +2759,7 @@ static const struct cp_pa_sync_state_decoder { static const struct big_enc_decoder { uint8_t code; - char *value; + const char *value; } big_enc_decoders[] = { { 0x00, "Not encrypted" }, { 0x01, "Broadcast_Code required" }, diff --git a/monitor/avctp.c b/monitor/avctp.c index fb2628282..c59e93b20 100644 --- a/monitor/avctp.c +++ b/monitor/avctp.c @@ -1802,7 +1802,7 @@ response: } -static struct { +static const struct { const char *str; bool reserved; } features_table[] = { diff --git a/monitor/intel.c b/monitor/intel.c index 0191987d4..1b2414290 100644 --- a/monitor/intel.c +++ b/monitor/intel.c @@ -1798,7 +1798,7 @@ static const struct vendor_evt vendor_prefix_evt_table[] = { { } }; -const uint8_t intel_vendor_prefix[] = {0x87, 0x80}; +static const uint8_t intel_vendor_prefix[] = {0x87, 0x80}; #define INTEL_VENDOR_PREFIX_SIZE sizeof(intel_vendor_prefix) /* diff --git a/monitor/l2cap.c b/monitor/l2cap.c index 8f3d8e65b..dff183bd0 100644 --- a/monitor/l2cap.c +++ b/monitor/l2cap.c @@ -718,7 +718,7 @@ static void print_config_result(uint16_t result) print_field("Result: %s (0x%4.4x)", str, le16_to_cpu(result)); } -static struct { +static const struct { uint8_t type; uint8_t len; const char *str; diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c index 02300a8b5..a855152c6 100644 --- a/monitor/rfcomm.c +++ b/monitor/rfcomm.c @@ -32,7 +32,7 @@ #include "sdp.h" #include "rfcomm.h" -static char *cr_str[] = { +static const char *cr_str[] = { "RSP", "CMD" }; diff --git a/monitor/sdp.c b/monitor/sdp.c index daf9a9da8..2c69dc83b 100644 --- a/monitor/sdp.c +++ b/monitor/sdp.c @@ -167,7 +167,7 @@ static struct { { } }; -static struct { +static const struct { uint8_t index; uint8_t bits; uint8_t size; @@ -322,7 +322,7 @@ static uint32_t get_bytes(const uint8_t *data, uint32_t size) return 0; } -static struct { +static const struct { uint16_t id; const char *str; } attribute_table[] = { From patchwork Tue Jan 16 14:00:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520854 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1EA751BDEB for ; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L2KhSXDa" Received: by smtp.kernel.org (Postfix) with ESMTPS id 91FC5C433B1; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=LVMnZlTkxWcpStNU6Xl+mRoEwUNK0FYdkJjY5mOEHKs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=L2KhSXDaJfU2l1mGGA1YLAtfnYF6yleEgClpuZZLc/zRFm6185Z2mp32AXbIedfff pfox8XwugeTiLClbjTAnEEBX/BuMNukCxSFFcevt2irTlgleNnwHhONXr88aHdMnH9 pLTPpT9onoP4qwjWJBXe6Vv3tozkVV0S9SHWX5U+dQ1PL6+TuBEYCAjMMRaP+uffeb tVO3FFWkmz71cCJaL5W3hhMUV1YxdBAlt+I3DuPw/A0yPgYgWAjRuQInEhEWZ1ld2c 4qdE5hEqpRLDWUIZYSbF6vjDq7Ba8jpjgdYk3+jH1MGhbxpxvlp4THk+8gRQxH106h t7njYG3l++xKw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80BF5C47077; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:30 +0000 Subject: [PATCH BlueZ 05/20] monitor: const annotate intel_version_tlv_desc::type_str and API Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-5-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=3446; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=wahNKDM8iDeiZs6EV1R7VsClaT+QYMSeKeI21SRP6Aw=; b=Gdy8Fb4gEVdZRo4gvD5rfT/5wHjL+tFQXVs8a5soi0m05zIDj/c71TZAkIjwMmFZzSZ4VmXld Llp1vuZnqopC+ulU8e/VkD5vQ8moTkPyDVbGG+TXmDB+C6J9ZRrucwB X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- monitor/intel.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/monitor/intel.c b/monitor/intel.c index 1b2414290..0de864d8a 100644 --- a/monitor/intel.c +++ b/monitor/intel.c @@ -171,25 +171,25 @@ struct intel_version_tlv { }; static void print_version_tlv_u32(const struct intel_version_tlv *tlv, - char *type_str) + const char *type_str) { print_field("%s(%u): 0x%8.8x", type_str, tlv->type, get_le32(tlv->val)); } static void print_version_tlv_u16(const struct intel_version_tlv *tlv, - char *type_str) + const char *type_str) { print_field("%s(%u): 0x%4.4x", type_str, tlv->type, get_le16(tlv->val)); } static void print_version_tlv_u8(const struct intel_version_tlv *tlv, - char *type_str) + const char *type_str) { print_field("%s(%u): 0x%2.2x", type_str, tlv->type, get_u8(tlv->val)); } static void print_version_tlv_enabled(const struct intel_version_tlv *tlv, - char *type_str) + const char *type_str) { print_field("%s(%u): %s(%u)", type_str, tlv->type, tlv->val[0] ? "Enabled" : "Disabled", @@ -197,7 +197,7 @@ static void print_version_tlv_enabled(const struct intel_version_tlv *tlv, } static void print_version_tlv_img_type(const struct intel_version_tlv *tlv, - char *type_str) + const char *type_str) { const char *str; @@ -217,34 +217,34 @@ static void print_version_tlv_img_type(const struct intel_version_tlv *tlv, } static void print_version_tlv_timestamp(const struct intel_version_tlv *tlv, - char *type_str) + const char *type_str) { print_field("%s(%u): %u-%u", type_str, tlv->type, tlv->val[1], tlv->val[0]); } static void print_version_tlv_min_fw(const struct intel_version_tlv *tlv, - char *type_str) + const char *type_str) { print_field("%s(%u): %u-%u.%u", type_str, tlv->type, tlv->val[0], tlv->val[1], 2000 + tlv->val[2]); } static void print_version_tlv_otp_bdaddr(const struct intel_version_tlv *tlv, - char *type_str) + const char *type_str) { packet_print_addr(type_str, tlv->val, 0x00); } static void print_version_tlv_unknown(const struct intel_version_tlv *tlv, - char *type_str) + const char *type_str) { print_field("%s(%u): ", type_str, tlv->type); packet_hexdump(tlv->val, tlv->len); } static void print_version_tlv_mfg(const struct intel_version_tlv *tlv, - char *type_str) + const char *type_str) { uint16_t mfg_id = get_le16(tlv->val); @@ -254,8 +254,8 @@ static void print_version_tlv_mfg(const struct intel_version_tlv *tlv, static const struct intel_version_tlv_desc { uint8_t type; - char *type_str; - void (*func)(const struct intel_version_tlv *tlv, char *type_str); + const char *type_str; + void (*func)(const struct intel_version_tlv *tlv, const char *type_str); } intel_version_tlv_table[] = { { 16, "CNVi TOP", print_version_tlv_u32 }, { 17, "CNVr TOP", print_version_tlv_u32 }, @@ -365,7 +365,7 @@ static void read_version_rsp(uint16_t index, const void *data, uint8_t size) static void read_version_cmd(uint16_t index, const void *data, uint8_t size) { - char *str; + const char *str; uint8_t type; /* This is the legacy read version command format and no further action From patchwork Tue Jan 16 14:00:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520852 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3C801BDDC for ; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="I5gGWYec" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9A7BFC433A6; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=U2DzD3b78s55wlx35CDPqjgOb5JquvuRvmtj7Z426WA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=I5gGWYecmV/Ntc5HVsnpUKTucN93C5fKaJ0QofhlbIwx4+lMidbNU/irgHdX56ZS1 T4vbWJdXjzzwfN/4pMvMar0tdihoRs1Ril3c3sGt0b9b1xETZ+3mgfnorRcryY3FKC O8XscsljCD5GlvQsemwQ2ZDv3kDAF3FBo0z33oNd0MCzDl3GuMvWN2mgkAggi+AcIX DUAasRJgiiXtoYvodQjxx/BoqXIhgeZo/mowUMFjtgboNvL9KQ8AWXZctBvnoeXEBY rPml+uoHVpSforzMI23hZlurJGXyV82QNBeIUzAD5jNPn0mZ8DWAZRW65WfQRkP0Js iZIFWcNyWcjtQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8AE30C47DA2; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:31 +0000 Subject: [PATCH BlueZ 06/20] monitor: const annotate type_table and related API Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-6-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=783; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=xa4m8BsqTwPsc2SbBBo+2BlpNjfQfWB+tZ+SM4CKAmo=; b=wuusPUs7wV1y9nQqPDEeVU00HLz/4Zdq0v8wX4r6qgkspyKyLOFd0JQJvXwvE2XQz2fc6GGXH /502u705obvC8TgKotC2wO8DmTfKS/eL+ifhg35AFVy5pK+FGyjqQB5 X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- monitor/sdp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/monitor/sdp.c b/monitor/sdp.c index 2c69dc83b..5fe4f2979 100644 --- a/monitor/sdp.c +++ b/monitor/sdp.c @@ -148,9 +148,9 @@ static void print_boolean(uint8_t indent, const uint8_t *data, uint32_t size) #define SIZES(args...) ((uint8_t[]) { args, 0xff } ) -static struct { +static const struct { uint8_t value; - uint8_t *sizes; + const uint8_t *sizes; bool recurse; const char *str; void (*print) (uint8_t indent, const uint8_t *data, uint32_t size); @@ -184,7 +184,7 @@ static const struct { { } }; -static bool valid_size(uint8_t size, uint8_t *sizes) +static bool valid_size(uint8_t size, const uint8_t *sizes) { int i; From patchwork Tue Jan 16 14:00:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520849 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3C231BDDA for ; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OAfjWIoW" Received: by smtp.kernel.org (Postfix) with ESMTPS id A51E6C433B2; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=na334TBbRBjw2qVD+xMWJoUTfj6hp7KP/IkojBZmryQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=OAfjWIoWkmh7ekVvXk0qzfIPB8wL/B+5mnTqbnP0QQ5wN65pB+XBuvlrvoc4HZJfo uU3m2Spm3dapTx8lzX9n9eLsbMdM8b60Im21csa8dtVY5nEJnmcJrw1p6em3QvC0R8 sKw/jR96XWIchf7gCZ3Q7MOhnnvP5NwPiQmS/JTClwSyVeNeumBqKwkmN+CTe9Dy66 qqRft9bbFeYfAWZhNVecI7FaTs6sh8k2OV3aXSTU8xkA/yrOVGWVbvxCxZLZH0nc55 s+phrz+6oyQKh9IzYsVGlpeZr7jlDcGBDG6m8N294hHmdw9gaU1eiaas/Iq28XgRU5 fe1hHwxAndEYA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9493BC47DA6; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:32 +0000 Subject: [PATCH BlueZ 07/20] profiles: annotate immutable data as const Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-7-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=8753; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=g6wwF3j8HEcST+PrUgGInINZna2D5QT+NY4sabsh4b4=; b=7YGywLiv4ShsvjHgFg4rhMRUlQLvUNf8W6lcdDhyUURWdq2JTenya+Ow4zsx7454vDPr7UsQP b0u+sd0uIFjALbY+m0NKNcNpVpdnSnvgPWC7UKbXBnmLnIDDy4Zuol8 X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- profiles/audio/avctp.c | 2 +- profiles/audio/avrcp.c | 8 ++++---- profiles/audio/media.c | 6 +++--- profiles/audio/sink.c | 2 +- profiles/audio/source.c | 2 +- profiles/audio/transport.c | 12 ++++++------ profiles/health/hdp_util.c | 15 +++++++-------- profiles/iap/main.c | 2 +- 8 files changed, 24 insertions(+), 25 deletions(-) diff --git a/profiles/audio/avctp.c b/profiles/audio/avctp.c index 6f64f162b..8ad146df1 100644 --- a/profiles/audio/avctp.c +++ b/profiles/audio/avctp.c @@ -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; diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c index dda9a303f..439fa27a9 100644 --- a/profiles/audio/avrcp.c +++ b/profiles/audio/avrcp.c @@ -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[] = { @@ -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, }; @@ -2118,7 +2118,7 @@ failed: 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); @@ -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, diff --git a/profiles/audio/media.c b/profiles/audio/media.c index 1faa1c289..edaff7867 100644 --- a/profiles/audio/media.c +++ b/profiles/audio/media.c @@ -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); @@ -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; @@ -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, diff --git a/profiles/audio/sink.c b/profiles/audio/sink.c index 56c491778..a547dcb41 100644 --- a/profiles/audio/sink.c +++ b/profiles/audio/sink.c @@ -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", diff --git a/profiles/audio/source.c b/profiles/audio/source.c index c6009d0ea..9fac352c8 100644 --- a/profiles/audio/source.c +++ b/profiles/audio/source.c @@ -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", diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index a4696154a..dd7d0e0a2 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -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", @@ -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; }; @@ -1749,7 +1749,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), @@ -1762,12 +1762,12 @@ 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; @@ -1784,7 +1784,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); diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c index ab3b78f6a..ad3702f01 100644 --- a/profiles/health/hdp_util.c +++ b/profiles/health/hdp_util.c @@ -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; }; @@ -67,7 +67,7 @@ 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) @@ -75,7 +75,6 @@ static gboolean parse_dict_entry(struct dict_entry_func dict_context[], 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); @@ -88,9 +87,9 @@ 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, @@ -98,7 +97,7 @@ static gboolean parse_dict_entry(struct dict_entry_func dict_context[], 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) @@ -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}, diff --git a/profiles/iap/main.c b/profiles/iap/main.c index 9a04f5cc0..054ff600e 100644 --- a/profiles/iap/main.c +++ b/profiles/iap/main.c @@ -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 }, From patchwork Tue Jan 16 14:00:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520850 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3C501BDDB for ; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IflnjvBu" Received: by smtp.kernel.org (Postfix) with ESMTPS id AD66CC43330; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=C/GsgVYTO24HtdUD7Qa68p2BDP9gQb9IsuNnwC5g/I4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=IflnjvBuooE0bhvtaCqRWx+gp/zeCru6pbnUVmtrSYAWKtU1UJqko1eOTgyRNS2oA 8QIPjDQCgBYYAsDND6KpWrWYV30Wr6lvUQHa2UgLI/1qE5/1+skG95D/JguykFHDJ/ eMV2i+OqrVWBre3CmoP75t0FmwZEsRvudFpUvsPpCqr9SpxNn56/5FHoqoVSnftwlo Xz4+vPc2KmOJeuG09FR98wu3aH6bSw+qxi35dPCydslcbhxdpXyJ/q+I3HkImXZUs+ 2O5hPAl8boz6WCgAmli9HUHb3rsGel1APrv4kZxaiuooGygBf/Z6eBxx302/t4Mv6m PRb2//ZpIi54g== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D73FC47DA9; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:33 +0000 Subject: [PATCH BlueZ 08/20] attrib: annotate immutable data as const Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-8-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=2060; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=r4UogXNZcqpBuo7KQeXLw6rUdfC5zty52k+yB4yl1Y0=; b=mcb7UxZAS4sKzhr8clOsa8yzBMZk2BwF27jvxTI5K8j3tC/6Wgv1EI5UQnd75d/catNnLTzad FKDbyDo5gtyB8i22pOqv89O7cIbPK4PnN/t01btFwkVOaq8KqxZTUeY X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- attrib/gatttool.c | 8 ++++---- attrib/interactive.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/attrib/gatttool.c b/attrib/gatttool.c index 2d03875b0..4309d20b1 100644 --- a/attrib/gatttool.c +++ b/attrib/gatttool.c @@ -454,7 +454,7 @@ static gboolean parse_uuid(const char *key, const char *value, return TRUE; } -static GOptionEntry primary_char_options[] = { +static const GOptionEntry primary_char_options[] = { { "start", 's' , 0, G_OPTION_ARG_INT, &opt_start, "Starting handle (optional)", "0x0001" }, { "end", 'e' , 0, G_OPTION_ARG_INT, &opt_end, @@ -464,7 +464,7 @@ static GOptionEntry primary_char_options[] = { { NULL }, }; -static GOptionEntry char_rw_options[] = { +static const GOptionEntry char_rw_options[] = { { "handle", 'a' , 0, G_OPTION_ARG_INT, &opt_handle, "Read/Write characteristic by handle (required)", "0x0001" }, { "value", 'n' , 0, G_OPTION_ARG_STRING, &opt_value, @@ -473,7 +473,7 @@ static GOptionEntry char_rw_options[] = { {NULL}, }; -static GOptionEntry gatt_options[] = { +static const GOptionEntry gatt_options[] = { { "primary", 0, 0, G_OPTION_ARG_NONE, &opt_primary, "Primary Service Discovery", NULL }, { "characteristics", 0, 0, G_OPTION_ARG_NONE, &opt_characteristics, @@ -494,7 +494,7 @@ static GOptionEntry gatt_options[] = { { NULL }, }; -static GOptionEntry options[] = { +static const GOptionEntry options[] = { { "adapter", 'i', 0, G_OPTION_ARG_STRING, &opt_src, "Specify local adapter interface", "hciX" }, { "device", 'b', 0, G_OPTION_ARG_STRING, &opt_dst, diff --git a/attrib/interactive.c b/attrib/interactive.c index 171b95738..c0262e87c 100644 --- a/attrib/interactive.c +++ b/attrib/interactive.c @@ -760,7 +760,7 @@ static void cmd_mtu(int argcp, char **argvp) gatt_exchange_mtu(attrib, opt_mtu, exchange_mtu_cb, NULL); } -static struct { +static const struct { const char *cmd; void (*func)(int argcp, char **argvp); const char *params; From patchwork Tue Jan 16 14:00:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520858 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20D001BDEC for ; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EJg3ObeA" Received: by smtp.kernel.org (Postfix) with ESMTPS id B6C06C43601; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=AUF3zzlQtcTB0ubd1yjXLqY4gdLbjtT5gK/qnbMuHnk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=EJg3ObeAi2/ofaEnK/yaKkXu+682lwlSWjxs4jrUdDyjSpDEk+Ji40bIEtZD8KAiK iCl1cBRx8np7SUfiGhR/qTA964yIM+whmeVbYhzJ7Od6qJrO/5ARKoIf+ptbjB8JfJ fInuXlk8AZx0dsnmys+a5+GAG8F8IujVLlDz0e4772M3zuChLMZEhzrveQBeKKQ6Lz oKI6Tkyk/ukAVltpnlKqAu8S07ihIqWTrpzaxrueVZc7ZyGdSXnNVD+cnYEfxX5qAZ ExY+9eYmzpo+ofvEHGIizBo0uCxb7gpzWbpp30e4y/eJjfKDkUlngUIT6sCGMKHDdD H3I/GFrdyKI6A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id A61C2C47DAC; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:34 +0000 Subject: [PATCH BlueZ 09/20] client: annotate struct option instances as const Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-9-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=6759; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=sm/sfgP6dAU9AbC/N7qkwROmrCzswI0+Dh2WodmZU+Q=; b=LY+e8oNSg0qw+uyxpfMnP8rqtceevobSufhTdWwfpjETR7I23ZGLcadAe+aDVXWsL/Mub4Q7u N4XswtaZ7I+BZiIsVU8F3nhuLXnbNnTebP1hLhvzg4EbmKM5k1nL7wX X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- client/mgmt.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/client/mgmt.c b/client/mgmt.c index e9ebb3d93..6fd43887d 100644 --- a/client/mgmt.c +++ b/client/mgmt.c @@ -2203,7 +2203,7 @@ static void get_flags_rsp(uint8_t status, uint16_t len, const void *param, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static struct option get_flags_options[] = { +static const struct option get_flags_options[] = { { "help", 0, 0, 'h' }, { "type", 1, 0, 't' }, { 0, 0, 0, 0 } @@ -2272,7 +2272,7 @@ static void set_flags_rsp(uint8_t status, uint16_t len, const void *param, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static struct option set_flags_options[] = { +static const struct option set_flags_options[] = { { "help", 0, 0, 'h' }, { "type", 1, 0, 't' }, { "flags", 1, 0, 'f' }, @@ -2678,7 +2678,7 @@ static void disconnect_rsp(uint8_t status, uint16_t len, const void *param, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static struct option disconnect_options[] = { +static const struct option disconnect_options[] = { { "help", 0, 0, 'h' }, { "type", 1, 0, 't' }, { 0, 0, 0, 0 } @@ -2783,7 +2783,7 @@ static void find_service_rsp(uint8_t status, uint16_t len, const void *param, discovery = true; } -static struct option find_service_options[] = { +static const struct option find_service_options[] = { { "help", no_argument, 0, 'h' }, { "le-only", no_argument, 0, 'l' }, { "bredr-only", no_argument, 0, 'b' }, @@ -2880,7 +2880,7 @@ static void find_rsp(uint8_t status, uint16_t len, const void *param, discovery = true; } -static struct option find_options[] = { +static const struct option find_options[] = { { "help", 0, 0, 'h' }, { "le-only", 1, 0, 'l' }, { "bredr-only", 1, 0, 'b' }, @@ -2952,7 +2952,7 @@ static void stop_find_rsp(uint8_t status, uint16_t len, const void *param, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static struct option stop_find_options[] = { +static const struct option stop_find_options[] = { { "help", 0, 0, 'h' }, { "le-only", 1, 0, 'l' }, { "bredr-only", 1, 0, 'b' }, @@ -3074,7 +3074,7 @@ static void register_pair_callbacks(struct mgmt *mgmt, uint16_t index) passkey_notify, mgmt, NULL); } -static struct option pair_options[] = { +static const struct option pair_options[] = { { "help", 0, 0, 'h' }, { "capability", 1, 0, 'c' }, { "type", 1, 0, 't' }, @@ -3169,7 +3169,7 @@ static void cancel_pair_rsp(uint8_t status, uint16_t len, const void *param, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static struct option cancel_pair_options[] = { +static const struct option cancel_pair_options[] = { { "help", 0, 0, 'h' }, { "type", 1, 0, 't' }, { 0, 0, 0, 0 } @@ -3251,7 +3251,7 @@ static void unpair_rsp(uint8_t status, uint16_t len, const void *param, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static struct option unpair_options[] = { +static const struct option unpair_options[] = { { "help", 0, 0, 'h' }, { "type", 1, 0, 't' }, { 0, 0, 0, 0 } @@ -3378,7 +3378,7 @@ static void irks_rsp(uint8_t status, uint16_t len, const void *param, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static struct option irks_options[] = { +static const struct option irks_options[] = { { "help", 0, 0, 'h' }, { "local", 1, 0, 'l' }, { "file", 1, 0, 'f' }, @@ -3492,7 +3492,7 @@ static void block_rsp(uint16_t op, uint16_t id, uint8_t status, uint16_t len, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static struct option block_options[] = { +static const struct option block_options[] = { { "help", 0, 0, 'h' }, { "type", 1, 0, 't' }, { 0, 0, 0, 0 } @@ -3736,7 +3736,7 @@ static void remote_oob_rsp(uint8_t status, uint16_t len, const void *param, print("Remote OOB data added for %s (%u)", addr, rp->type); } -static struct option remote_oob_opt[] = { +static const struct option remote_oob_opt[] = { { "help", 0, 0, '?' }, { "type", 1, 0, 't' }, { 0, 0, 0, 0 } @@ -3979,7 +3979,7 @@ static void conn_info_rsp(uint8_t status, uint16_t len, const void *param, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static struct option conn_info_options[] = { +static const struct option conn_info_options[] = { { "help", 0, 0, 'h' }, { "type", 1, 0, 't' }, { 0, 0, 0, 0 } @@ -4150,7 +4150,7 @@ static void add_device_rsp(uint8_t status, uint16_t len, const void *param, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static struct option add_device_options[] = { +static const struct option add_device_options[] = { { "help", 0, 0, 'h' }, { "action", 1, 0, 'a' }, { "type", 1, 0, 't' }, @@ -4223,7 +4223,7 @@ static void remove_device_rsp(uint8_t status, uint16_t len, const void *param, bt_shell_noninteractive_quit(EXIT_SUCCESS); } -static struct option del_device_options[] = { +static const struct option del_device_options[] = { { "help", 0, 0, 'h' }, { "type", 1, 0, 't' }, { 0, 0, 0, 0 } @@ -4477,7 +4477,7 @@ static void advsize_usage(void) "\t -n, --local-name \"local-name\" flag"); } -static struct option advsize_options[] = { +static const struct option advsize_options[] = { { "help", 0, 0, 'h' }, { "connectable", 0, 0, 'c' }, { "general-discov", 0, 0, 'g' }, @@ -4597,7 +4597,7 @@ static void add_adv_usage(void) "\tadd-adv -u 180d -u 180f -d 080954657374204C45 1"); } -static struct option add_adv_options[] = { +static const struct option add_adv_options[] = { { "help", 0, 0, 'h' }, { "uuid", 1, 0, 'u' }, { "adv-data", 1, 0, 'd' }, @@ -4935,7 +4935,7 @@ static void add_ext_adv_params_usage(void) "\tadd-ext-adv-params -r 0x801 -x 0x802 -P 2M -g 1"); } -static struct option add_ext_adv_params_options[] = { +static const struct option add_ext_adv_params_options[] = { { "help", 0, 0, 'h' }, { "duration", 1, 0, 'd' }, { "timeout", 1, 0, 't' }, @@ -5113,7 +5113,7 @@ static void add_ext_adv_data_usage(void) "\tadd-ext-adv-data -u 180d -u 180f -d 080954657374204C45 1"); } -static struct option add_ext_adv_data_options[] = { +static const struct option add_ext_adv_data_options[] = { { "help", 0, 0, 'h' }, { "uuid", 1, 0, 'u' }, { "adv-data", 1, 0, 'd' }, @@ -5557,7 +5557,7 @@ static bool str2pattern(struct mgmt_adv_pattern *pattern, const char *str) return true; } -static struct option add_monitor_rssi_options[] = { +static const struct option add_monitor_rssi_options[] = { { "help", 0, 0, 'h' }, { "high-threshold", 1, 0, 'R' }, { "low-threshold", 1, 0, 'r' }, From patchwork Tue Jan 16 14:00:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520853 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBB4A1BDDD for ; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="omrmkIQK" Received: by smtp.kernel.org (Postfix) with ESMTPS id BE233C43609; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=gIkAEz9KvugeA7i0ffO2YgeIQYSh8u8S2ex1hCjShcw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=omrmkIQKaSUfBQuFXGz9+hBr2FIbPebzfboHEy66fvWO8bcRd+//hQuINqEH4BosJ 4+yioxg3tP3K44PA1YykcvIAZsiR74ciCZE3mdH89olRIpcp4fV+XLN8U3ye/HpXWg eEfmkOWsGS4y9hRy43prlb+/niyGmv0veH2XJv0sLYQ+b3bfpWicsURj2LdENbFZow g6VGOILOOoj4489QMRFinq/o2hm0/qE8GSHnnAbKimCz3qUiNidhe/TZvdJKi4oJh8 he/L0TPjye8Secpy7b1SWrlHAbJh00MRJdxqG8pd/dC4x/EpyMrr6AAL5dSQ5Lc9Zx QFVOxHdTcYNJQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEB5CC47077; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:35 +0000 Subject: [PATCH BlueZ 10/20] emulator: const annotate rfcomm_crc_table[] Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-10-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=627; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=NZds5ZvHb3CFb81d/ppE/ipwe1m7zAUlnTKfMKDPIOM=; b=JxjwP7lKY5Pg7j09p3ZEbOT71Tw8Ib18YwZ4TDIjxFhOCQxGaNUXmL7K23zo0UhNa49UhZRkH svAikt0TR3nDE16//G9EPLt4XDSoelPdMjcM+sipvmLjGkU/btfzd4a X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- emulator/bthost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emulator/bthost.c b/emulator/bthost.c index c7d59eefc..8c40fce90 100644 --- a/emulator/bthost.c +++ b/emulator/bthost.c @@ -59,7 +59,7 @@ /* RFCOMM FCS calculation */ #define CRC(data) (rfcomm_crc_table[rfcomm_crc_table[0xff ^ data[0]] ^ data[1]]) -static unsigned char rfcomm_crc_table[256] = { +static const unsigned char rfcomm_crc_table[256] = { 0x00, 0x91, 0xe3, 0x72, 0x07, 0x96, 0xe4, 0x75, 0x0e, 0x9f, 0xed, 0x7c, 0x09, 0x98, 0xea, 0x7b, 0x1c, 0x8d, 0xff, 0x6e, 0x1b, 0x8a, 0xf8, 0x69, From patchwork Tue Jan 16 14:00:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520860 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BD341BDFA for ; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EssZOpOX" Received: by smtp.kernel.org (Postfix) with ESMTPS id C8C35C43141; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=NvolrZ1r/y7wWC9D7JKhSSVI2sMbcjnlzO+Cd5rTv/I=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=EssZOpOXZXZxPTlnV+WEkxHnCo+IOyvS8xvHu+wO51Lb1iOB3TqBokUYIc13hXXmc xDNAOfsZyBJc3z535VM78QS/FY64nXDRBy+ee5PX37xraHGwAgFgYvcdEUORf/fksK nHKZ2sykjN7giOeaHackeJ0roOMc8cjGWfsW3OYUzQ/P+bPFxyWwZOTx15AXjh/Uig Kg4W997iBiEspFRFeeLDm587UDqwuwbarowjK4HYC7Kp/W2mcJepoAWHgLJKHwZdnA NNh6Hi7vS+57YaWY+dmr4097IBMWhSHhVAktW8twtGlw1uloezAsIzwPlE2+U+pPLk TZfmZn1uo14PA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id B80B2C47DAF; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:36 +0000 Subject: [PATCH BlueZ 11/20] gobex: const annotate RO arrays, use G_N_ELEMENTS Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-11-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=1328; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=fKEuOSVKg0zguPSlbGmjQMiLNTaWi6zZrrBTQ9MTicY=; b=0OUt50pFkhUCXUGGFl5FRDpNCvoyOOEqLLNQNxqu1qafyrRwAGipXGI30lQSczquLxIwZZGYu FL5ynJpKvwYDlAD42F5dtJcDo8NiyUJt2WB5MEa+s7VAwqXWknO3tCX X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- gobex/gobex.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gobex/gobex.c b/gobex/gobex.c index e9b89cead..8924e059f 100644 --- a/gobex/gobex.c +++ b/gobex/gobex.c @@ -122,7 +122,7 @@ struct setpath_data { guint8 constants; } __attribute__ ((packed)); -static struct error_code { +static const struct error_code { guint8 code; const char *name; } obex_errors[] = { @@ -169,7 +169,7 @@ static struct error_code { const char *g_obex_strerror(guint8 err_code) { - struct error_code *error; + const struct error_code *error; for (error = obex_errors; error->name != NULL; error++) { if (error->code == err_code) @@ -1423,7 +1423,7 @@ failed: return FALSE; } -static GDebugKey keys[] = { +static const GDebugKey keys[] = { { "error", G_OBEX_DEBUG_ERROR }, { "command", G_OBEX_DEBUG_COMMAND }, { "transfer", G_OBEX_DEBUG_TRANSFER }, @@ -1443,7 +1443,7 @@ GObex *g_obex_new(GIOChannel *io, GObexTransportType transport_type, const char *env = g_getenv("GOBEX_DEBUG"); if (env) { - gobex_debug = g_parse_debug_string(env, keys, 7); + gobex_debug = g_parse_debug_string(env, keys, G_N_ELEMENTS(keys)); g_setenv("G_MESSAGES_DEBUG", "gobex", FALSE); } else gobex_debug = G_OBEX_DEBUG_NONE; From patchwork Tue Jan 16 14:00:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520862 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BD5F1BDFB for ; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WRTZP9JX" Received: by smtp.kernel.org (Postfix) with ESMTPS id D68EAC43143; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=/kkyCayW86QPB7bv2KKkQj8ka4jKmnUp4RSzD3PbMBI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=WRTZP9JXP/zhswap8dH8BBAYHGv2+HQo4BJhSfAIGgkDu6QJ/Sv3jLHnvsweI6x7a 84Y+4FRA5/iyzQ5zey05ebyr+wrOeaMh1PRnxkOlIFXP3rm4dTxcZLDGxavwNdvCO9 zr1zSAE8UUKZvhU0SizGLypOD5qjlW9e1edjDreLCuLxfatftrg9cnD0q1BkvwT5ck YPfVL0lNbFqwuxaCpAP/T8RvLaJOrWtgD9iC0fShYSvd2wRna7y74NGAgHLFZCKszD OkmrApxam7GOxwL2L1Nw0uL3rbtnZqQST/jW9UOzpfFFrbGCWdSqhZwD+R+t4fZFub 1/I9rhmKix3Iw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id C49BBC47DA2; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:37 +0000 Subject: [PATCH BlueZ 12/20] lib: const annotate hci_map instances and related API Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-12-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=6405; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=G1T1BpY+ViXL5Nqm153cSzTMq0Gn6gXun3Ula2nPawc=; b=Elld4fq5Oyb9/L/sc946Ajt+HH/VyXPxr5oX80RiYGtIQrdE9QDJxAonB6VxBMeY5ExMvAk8d 7ykQs7iAeYLBPGEsSkQF3HS0lx4SZDlzzlhfS2bM6LeJvfVzdwc+jkY X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- client/mgmt.c | 2 +- lib/hci.c | 42 +++++++++++++++++++++--------------------- lib/hci_lib.h | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/client/mgmt.c b/client/mgmt.c index 6fd43887d..62167727c 100644 --- a/client/mgmt.c +++ b/client/mgmt.c @@ -1484,7 +1484,7 @@ static void ext_index_rsp(uint8_t status, uint16_t len, const void *param, for (i = 0; i < count; i++) { uint16_t index = le16_to_cpu(rp->entry[i].index); - char *busstr = hci_bustostr(rp->entry[i].bus); + const char *busstr = hci_bustostr(rp->entry[i].bus); switch (rp->entry[i].type) { case 0x00: diff --git a/lib/hci.c b/lib/hci.c index bd735a440..937e65d48 100644 --- a/lib/hci.c +++ b/lib/hci.c @@ -42,7 +42,7 @@ typedef struct { unsigned int val; } hci_map; -static char *hci_bit2str(hci_map *m, unsigned int val) +static char *hci_bit2str(const hci_map *m, unsigned int val) { char *str = malloc(120); char *ptr = str; @@ -59,10 +59,10 @@ static char *hci_bit2str(hci_map *m, unsigned int val) return str; } -static int hci_str2bit(hci_map *map, char *str, unsigned int *val) +static int hci_str2bit(const hci_map *map, char *str, unsigned int *val) { char *t, *ptr; - hci_map *m; + const hci_map *m; int set; if (!str || !(str = ptr = strdup(str))) @@ -83,7 +83,7 @@ static int hci_str2bit(hci_map *map, char *str, unsigned int *val) return set; } -static char *hci_uint2str(hci_map *m, unsigned int val) +static char *hci_uint2str(const hci_map *m, unsigned int val) { char *str = malloc(50); char *ptr = str; @@ -102,10 +102,10 @@ static char *hci_uint2str(hci_map *m, unsigned int val) return str; } -static int hci_str2uint(hci_map *map, char *str, unsigned int *val) +static int hci_str2uint(const hci_map *map, char *str, unsigned int *val) { char *t, *ptr; - hci_map *m; + const hci_map *m; int set = 0; if (!str) @@ -127,7 +127,7 @@ static int hci_str2uint(hci_map *map, char *str, unsigned int *val) return set; } -char *hci_bustostr(int bus) +const char *hci_bustostr(int bus) { switch (bus) { case HCI_VIRTUAL: @@ -157,7 +157,7 @@ char *hci_bustostr(int bus) } } -char *hci_dtypetostr(int type) +const char *hci_dtypetostr(int type) { return hci_bustostr(type & 0x0f); } @@ -175,7 +175,7 @@ char *hci_typetostr(int type) } /* HCI dev flags mapping */ -static hci_map dev_flags_map[] = { +static const hci_map dev_flags_map[] = { { "UP", HCI_UP }, { "INIT", HCI_INIT }, { "RUNNING", HCI_RUNNING }, @@ -192,7 +192,7 @@ char *hci_dflagstostr(uint32_t flags) { char *str = bt_malloc(50); char *ptr = str; - hci_map *m = dev_flags_map; + const hci_map *m = dev_flags_map; if (!str) return NULL; @@ -211,7 +211,7 @@ char *hci_dflagstostr(uint32_t flags) } /* HCI packet type mapping */ -static hci_map pkt_type_map[] = { +static const hci_map pkt_type_map[] = { { "DM1", HCI_DM1 }, { "DM3", HCI_DM3 }, { "DM5", HCI_DM5 }, @@ -230,7 +230,7 @@ static hci_map pkt_type_map[] = { { NULL } }; -static hci_map sco_ptype_map[] = { +static const hci_map sco_ptype_map[] = { { "HV1", 0x0001 }, { "HV2", 0x0002 }, { "HV3", 0x0004 }, @@ -265,7 +265,7 @@ int hci_strtoscoptype(char *str, unsigned int *val) } /* Link policy mapping */ -static hci_map link_policy_map[] = { +static const hci_map link_policy_map[] = { { "NONE", 0 }, { "RSWITCH", HCI_LP_RSWITCH }, { "HOLD", HCI_LP_HOLD }, @@ -285,7 +285,7 @@ int hci_strtolp(char *str, unsigned int *val) } /* Link mode mapping */ -static hci_map link_mode_map[] = { +static const hci_map link_mode_map[] = { { "NONE", 0 }, { "ACCEPT", HCI_LM_ACCEPT }, { "CENTRAL", HCI_LM_MASTER }, @@ -332,7 +332,7 @@ int hci_strtolm(char *str, unsigned int *val) } /* Command mapping */ -static hci_map commands_map[] = { +static const hci_map commands_map[] = { { "Inquiry", 0 }, { "Inquiry Cancel", 1 }, { "Periodic Inquiry Mode", 2 }, @@ -605,7 +605,7 @@ char *hci_cmdtostr(unsigned int cmd) char *hci_commandstostr(uint8_t *commands, char *pref, int width) { unsigned int maxwidth = width - 3; - hci_map *m; + const hci_map *m; char *off, *ptr, *str; int size = 10; @@ -645,7 +645,7 @@ char *hci_commandstostr(uint8_t *commands, char *pref, int width) } /* Version mapping */ -static hci_map ver_map[] = { +static const hci_map ver_map[] = { { "1.0b", 0x00 }, { "1.1", 0x01 }, { "1.2", 0x02 }, @@ -683,7 +683,7 @@ int lmp_strtover(char *str, unsigned int *ver) return hci_str2uint(ver_map, str, ver); } -static hci_map pal_map[] = { +static const hci_map pal_map[] = { { "3.0", 0x01 }, { NULL } }; @@ -699,7 +699,7 @@ int pal_strtover(char *str, unsigned int *ver) } /* LMP features mapping */ -static hci_map lmp_features_map[8][9] = { +static const hci_map lmp_features_map[8][9] = { { /* Byte 0 */ { "<3-slot packets>", LMP_3SLOT }, /* Bit 0 */ { "<5-slot packets>", LMP_5SLOT }, /* Bit 1 */ @@ -794,7 +794,7 @@ char *lmp_featurestostr(uint8_t *features, char *pref, int width) int i, size = 10; for (i = 0; i < 8; i++) { - hci_map *m = lmp_features_map[i]; + const hci_map *m = lmp_features_map[i]; while (m->str) { if (m->val & features[i]) @@ -816,7 +816,7 @@ char *lmp_featurestostr(uint8_t *features, char *pref, int width) off = ptr; for (i = 0; i < 8; i++) { - hci_map *m = lmp_features_map[i]; + const hci_map *m = lmp_features_map[i]; while (m->str) { if (m->val & features[i]) { diff --git a/lib/hci_lib.h b/lib/hci_lib.h index 6b1a548b5..baf3d3e12 100644 --- a/lib/hci_lib.h +++ b/lib/hci_lib.h @@ -132,9 +132,9 @@ int hci_le_read_remote_features(int dd, uint16_t handle, uint8_t *features, int int hci_for_each_dev(int flag, int(*func)(int dd, int dev_id, long arg), long arg); int hci_get_route(bdaddr_t *bdaddr); -char *hci_bustostr(int bus); +const char *hci_bustostr(int bus); char *hci_typetostr(int type); -char *hci_dtypetostr(int type); +const char *hci_dtypetostr(int type); char *hci_dflagstostr(uint32_t flags); char *hci_ptypetostr(unsigned int ptype); int hci_strtoptype(char *str, unsigned int *val); From patchwork Tue Jan 16 14:00:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520857 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BF821BDE3 for ; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gq6AoN3v" Received: by smtp.kernel.org (Postfix) with ESMTPS id E0F11C43142; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=IzvUTumHXOfkV/ry8X9/6+DvfQ+Xg4pAZnneqSWRREk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=gq6AoN3vQWw38kdu8RGEzRrKnIuG9+BQDtVKMj9jNIRtjtiIUzgbpFnLZcVtYXomZ +geGfYISf+NHEP2zMU+JTeJfrthV8pam35Ik3cKRVdxG3lIpUjLL1woSD25a0vx+Ut BmInnGMSNCbm0Mi8KAYr97YkDVqdBTvumTz6iqQ2xGO4KqjiQf6ZfOhUvj92lBn5ix QJ3IKUee7ZJzxaxo566ilQ4yek2sg8WU+wjt/0+WBys2zzl2RdejtYwjqydqIP3UaF E4excrkBSi5pOU44uBU67CAmkfz5pj79o3DTVWvD89aGBYPFBXnasQA3Hz/1XpDfLK nGEe6geuhBUcA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CED0BC47DA6; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:38 +0000 Subject: [PATCH BlueZ 13/20] lib: const annotate tupla instances and API Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-13-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=2511; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=jDi4yeZBNrEVszZnWoWgZxRy4Pha0pVHgMKoCcz3L8I=; b=oElQ0FaEz0C869vXKMWPjsbjXYUTIwNGgSZni9WiZK5IhI+4OqCrU7V8exHYsioHzC1td2d/T 81CI9qrwPPGDzuax5h/DEmc7gI3DK7eEi2x8CoMLyeZegekZT32hO8m X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- lib/sdp.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/sdp.c b/lib/sdp.c index dfc06b6df..5475c7eba 100644 --- a/lib/sdp.c +++ b/lib/sdp.c @@ -47,7 +47,7 @@ #define SDPDBG(fmt...) #endif -static uint128_t bluetooth_base_uuid = { +static const uint128_t bluetooth_base_uuid = { .data = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB } }; @@ -65,10 +65,10 @@ static int sdp_gen_buffer(sdp_buf_t *buf, sdp_data_t *d); /* Message structure. */ struct tupla { int index; - char *str; + const char *str; }; -static struct tupla Protocol[] = { +static const struct tupla Protocol[] = { { SDP_UUID, "SDP" }, { UDP_UUID, "UDP" }, { RFCOMM_UUID, "RFCOMM" }, @@ -97,7 +97,7 @@ static struct tupla Protocol[] = { { 0 } }; -static struct tupla ServiceClass[] = { +static const struct tupla ServiceClass[] = { { SDP_SERVER_SVCLASS_ID, "SDP Server" }, { BROWSE_GRP_DESC_SVCLASS_ID, "Browse Group Descriptor" }, { PUBLIC_BROWSE_GROUP, "Public Browse Group" }, @@ -176,9 +176,9 @@ static struct tupla ServiceClass[] = { #define Profile ServiceClass -static char *string_lookup(struct tupla *pt0, int index) +static const char *string_lookup(const struct tupla *pt0, int index) { - struct tupla *pt; + const struct tupla *pt; for (pt = pt0; pt->index; pt++) if (pt->index == index) @@ -187,7 +187,7 @@ static char *string_lookup(struct tupla *pt0, int index) return ""; } -static char *string_lookup_uuid(struct tupla *pt0, const uuid_t *uuid) +static const char *string_lookup_uuid(const struct tupla *pt0, const uuid_t *uuid) { uuid_t tmp_uuid; @@ -209,9 +209,9 @@ static char *string_lookup_uuid(struct tupla *pt0, const uuid_t *uuid) * Prints into a string the Protocol UUID * coping a maximum of n characters. */ -static int uuid2str(struct tupla *message, const uuid_t *uuid, char *str, size_t n) +static int uuid2str(const struct tupla *message, const uuid_t *uuid, char *str, size_t n) { - char *str2; + const char *str2; if (!uuid) { snprintf(str, n, "NULL"); @@ -2763,7 +2763,7 @@ uuid_t *sdp_uuid_to_uuid128(const uuid_t *uuid) */ int sdp_uuid128_to_uuid(uuid_t *uuid) { - uint128_t *b = &bluetooth_base_uuid; + const uint128_t *b = &bluetooth_base_uuid; uint128_t *u = &uuid->value.uuid128; uint32_t data; unsigned int i; From patchwork Tue Jan 16 14:00:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520856 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0BFB21BDE4 for ; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OYfawNJg" Received: by smtp.kernel.org (Postfix) with ESMTPS id E77F7C4166B; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413639; bh=OvbIhiPoQS5zM/o2nWQnkAR+ZmHVvUDGRnRbY42KlSk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=OYfawNJgCEU9eFqZC629+Fh2eJMtCB11hKseBso6LB6AGBrcctVONthKb74tLeXz/ k/tBw/cMDCAOi/Gb8CkbTVNtyYgUSl1t2ZvJhxESYaTk17RcNnFVtTKdF6o3VfBjZW pWDYnLwt3KNDPqloBH8pv3Tvr0ex04CuRqQn0HrBBIpc9H50/R8UWyIzOzJE9Y6RR+ jiltmVJ7JpJivLuHvsIdIsweFhcX9nAESr8r3XjVxd0pAj0uJssXmZ9R3GTCyszTSo LYsGIghP3WN73SWCUgIo9UpOJgClbNzt+FgWuRO4Jpt7EeaED7sYLRP+pSciU+o+yn TuQn+jEDayigw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8232C47DA9; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:39 +0000 Subject: [PATCH BlueZ 14/20] mesh: const annotate misc data Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-14-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=736; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=6tOC6zO5jyNErTKsxfQ8UiUAUopjHEVML0310cw+Lzg=; b=JSjJXFSnWAE4MeQNJ4JzFZDEPQDGDb7ZoYs/5pg4Leodg964HThBOPwsTxYDcraVqr6GQ41w6 GLijVFiDJeVD/eu0cYAe+C+K/ZZsOgzfY5PHdKxAvdNX/6qAuimDG0n X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- mesh/agent.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesh/agent.c b/mesh/agent.c index 5058d0d8d..2f9697a33 100644 --- a/mesh/agent.c +++ b/mesh/agent.c @@ -61,7 +61,7 @@ struct oob_info { uint16_t mask; }; -static struct prov_action cap_table[] = { +static const struct prov_action cap_table[] = { {"blink", 0x0001, 0x0000, 1}, {"beep", 0x0002, 0x0000, 1}, {"vibrate", 0x0004, 0x0000, 1}, @@ -73,7 +73,7 @@ static struct prov_action cap_table[] = { {"in-alpha", 0x0000, 0x0008, 8} }; -static struct oob_info oob_table[] = { +static const struct oob_info oob_table[] = { {"other", 0x0001}, {"uri", 0x0002}, {"machine-code-2d", 0x0004}, From patchwork Tue Jan 16 14:00:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520851 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C5AA1BDE6 for ; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qTVLSlm1" Received: by smtp.kernel.org (Postfix) with ESMTPS id 01240C4166C; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413640; bh=TR9F2RPPvJHIFxes0JTiv67JcVgotqOY+uk+Nc16LlY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=qTVLSlm11wZtV6CQidqsY8se4kX+Zaw4w9OB+HRJG9B4SKCw1PHf6u5Y91piGxiCG qnKT1f6PrzU3+RbN8Jk0CXf6XT7Gi2Hwwu2fNNGTw7nY6VGEPpz9S8a8cx40Hp/xUR aHkA5a0r7aKoVT//YPXgGipS+MIyHt9fFzGVHwR3kMr0sVBUtPPim6+Db80kEuSijA bghkcPClfwyC3B+OUv6qsBg1rUvc0OBgutzCtIO8OHPtlQS6ECQkv4M9iN8oQZcgfa +DCR1DUJKIoQyKkMavlQphGdKdfG0PR4nexBt9oG6fVzBQd2AclhiSjmlGoHEc/Bev 1aJNSQDF1sNhQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4991C47DAF; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:40 +0000 Subject: [PATCH BlueZ 15/20] obexd: remove obex_mime_type_driver::set_io_watch Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-15-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=4552; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=zsTwDFizPZhsw58JcxkEmEoCqpzsEk9q9cIgVjeeEeA=; b=NyXbU9u7LdlNGWQ27bcbqF/0lSzH8Ny/exHjIwbMsbRo97CUkGYCyDLKc1VTXw8Xxxj0m1p3v 4ZI3l7d4oNkD5t5iSWklcTfxr0c3IYQdG3Rxy+2Mxk7aK4utSEE+7J3 X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov All the drivers use the default function, where the register function modifies what should be a constant vtable. Instead let's remove the indirection, export and use the function as applicable. Since we have set and reset, export both functions and cleanup the users. --- obexd/src/mimetype.c | 12 ++---------- obexd/src/mimetype.h | 6 ++++-- obexd/src/obex.c | 12 ++++++------ 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/obexd/src/mimetype.c b/obexd/src/mimetype.c index 212f24b18..cf6e15dc6 100644 --- a/obexd/src/mimetype.c +++ b/obexd/src/mimetype.c @@ -73,7 +73,7 @@ static struct io_watch *find_io_watch(void *object) return NULL; } -static void reset_io_watch(void *object) +void obex_object_reset_io_watch(void *object) { struct io_watch *watch; @@ -85,16 +85,11 @@ static void reset_io_watch(void *object) g_free(watch); } -static int set_io_watch(void *object, obex_object_io_func func, +int obex_object_set_io_watch(void *object, obex_object_io_func func, void *user_data) { struct io_watch *watch; - if (func == NULL) { - reset_io_watch(object); - return 0; - } - watch = find_io_watch(object); if (watch) return -EPERM; @@ -181,9 +176,6 @@ int obex_mime_type_driver_register(struct obex_mime_type_driver *driver) return -EPERM; } - if (driver->set_io_watch == NULL) - driver->set_io_watch = set_io_watch; - DBG("driver %p mimetype %s registered", driver, driver->mimetype); drivers = g_slist_append(drivers, driver); diff --git a/obexd/src/mimetype.h b/obexd/src/mimetype.h index e1c14f405..55ddded08 100644 --- a/obexd/src/mimetype.h +++ b/obexd/src/mimetype.h @@ -28,8 +28,6 @@ struct obex_mime_type_driver { int (*copy) (const char *name, const char *destname); int (*move) (const char *name, const char *destname); int (*remove) (const char *name); - int (*set_io_watch) (void *object, obex_object_io_func func, - void *user_data); }; int obex_mime_type_driver_register(struct obex_mime_type_driver *driver); @@ -40,3 +38,7 @@ struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, unsigned int who_size); void obex_object_set_io_flags(void *object, int flags, int err); + +void obex_object_reset_io_watch(void *object); +int obex_object_set_io_watch(void *object, obex_object_io_func func, + void *user_data); diff --git a/obexd/src/obex.c b/obexd/src/obex.c index 3a68fd66c..4bf5ad124 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -119,7 +119,7 @@ static void os_reset_session(struct obex_session *os) os_session_mark_aborted(os); if (os->object) { - os->driver->set_io_watch(os->object, NULL, NULL); + obex_object_reset_io_watch(os->object); os->driver->close(os->object); if (os->aborted && os->cmd == G_OBEX_OP_PUT && os->path && os->driver->remove) @@ -357,7 +357,7 @@ static gssize driver_read(struct obex_session *os, void *buf, gsize size) if (len == -ENOSTR) return 0; if (len == -EAGAIN) - os->driver->set_io_watch(os->object, handle_async_io, + obex_object_set_io_watch(os->object, handle_async_io, os); } @@ -395,7 +395,7 @@ static void transfer_complete(GObex *obex, GError *err, gpointer user_data) if (os->object && os->driver && os->driver->flush) { if (os->driver->flush(os->object) == -EAGAIN) { g_obex_suspend(os->obex); - os->driver->set_io_watch(os->object, handle_async_io, + obex_object_set_io_watch(os->object, handle_async_io, os); return; } @@ -525,7 +525,7 @@ static gboolean recv_data(const void *buf, gsize size, gpointer user_data) if (ret == -EAGAIN) { g_obex_suspend(os->obex); - os->driver->set_io_watch(os->object, handle_async_io, os); + obex_object_set_io_watch(os->object, handle_async_io, os); return TRUE; } @@ -699,7 +699,7 @@ int obex_get_stream_start(struct obex_session *os, const char *filename) return err; g_obex_suspend(os->obex); - os->driver->set_io_watch(os->object, handle_async_io, os); + obex_object_set_io_watch(os->object, handle_async_io, os); return 0; } @@ -772,7 +772,7 @@ static gboolean check_put(GObex *obex, GObexPacket *req, void *user_data) break; case -EAGAIN: g_obex_suspend(os->obex); - os->driver->set_io_watch(os->object, handle_async_io, os); + obex_object_set_io_watch(os->object, handle_async_io, os); return TRUE; default: os_set_response(os, ret); From patchwork Tue Jan 16 14:00:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520859 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 258341BDEE for ; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Tt/p427b" Received: by smtp.kernel.org (Postfix) with ESMTPS id 09941C4166A; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413640; bh=A4zsYFYpTRKlrqsyY6x1DPfLv9gONMj13GZ6IqcepLk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Tt/p427by4KWMOYh9tdLZ62Uixw9lMiAmeTquQRNNF6DnPFlwULuJDlr/n0hOPEhZ i+URm+zYPWEchiWbtO/U520xOfF5n0pjjjTSCNIAiA/Wyouf2BRNjT28rFaPNc3/mO 29zuJrFFjb0zYKyqe4ZD0DRjWIgNSxzpL8qYC5MMzNtTWPoY5HAginKpmvaSJYs+sT MC3zLBr6VKssUd76w9/bWFWJykypLByDMVhoYO4dsH3mGR4q+xPn7fZPuUWJ1z7QyP IzLNf/WkBfZO8+pICI0L6nlIK/i1rV9GxQSMDHcOGP23juXPqVNU85Pv1yXAhh9kpR k1n1X1sKEy1RA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id F05D0C47077; Tue, 16 Jan 2024 14:00:39 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:41 +0000 Subject: [PATCH BlueZ 16/20] obexd: const obex_mime_type_driver instances and API Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-16-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=11209; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=SKIZuOUAgBaKwtIir1DXq91Qao7Mu//a+v8uSmhQCl8=; b=mZ4y9YbsB8+qtNzU1j+6wPV4649X3hdExMtlrgsbYOtpJwkG0+e8x6XXmU7jqQ25bLQi4wEeS +cQE8ldcSt9B1JIaAdS4GN9uap0ypk84GMWWThHTZZr4rYojphdAy8G X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- obexd/client/mns.c | 2 +- obexd/plugins/filesystem.c | 8 ++++---- obexd/plugins/irmc.c | 2 +- obexd/plugins/mas.c | 16 ++++++++-------- obexd/plugins/pbap.c | 6 +++--- obexd/plugins/pcsuite.c | 2 +- obexd/plugins/syncevolution.c | 2 +- obexd/src/mimetype.c | 14 +++++++------- obexd/src/mimetype.h | 6 +++--- obexd/src/obex-priv.h | 2 +- 10 files changed, 30 insertions(+), 30 deletions(-) diff --git a/obexd/client/mns.c b/obexd/client/mns.c index e52505642..3b2ae1076 100644 --- a/obexd/client/mns.c +++ b/obexd/client/mns.c @@ -356,7 +356,7 @@ static struct obex_service_driver mns = { .disconnect = mns_disconnect, }; -static struct obex_mime_type_driver mime_event_report = { +static const struct obex_mime_type_driver mime_event_report = { .target = MNS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/MAP-event-report", diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c index 09bff8ad0..f52927541 100644 --- a/obexd/plugins/filesystem.c +++ b/obexd/plugins/filesystem.c @@ -642,7 +642,7 @@ done: return err; } -static struct obex_mime_type_driver file = { +static const struct obex_mime_type_driver file = { .open = filesystem_open, .close = filesystem_close, .read = filesystem_read, @@ -652,7 +652,7 @@ static struct obex_mime_type_driver file = { .copy = filesystem_copy, }; -static struct obex_mime_type_driver capability = { +static const struct obex_mime_type_driver capability = { .target = FTP_TARGET, .target_size = FTP_TARGET_SIZE, .mimetype = "x-obex/capability", @@ -661,7 +661,7 @@ static struct obex_mime_type_driver capability = { .read = capability_read, }; -static struct obex_mime_type_driver folder = { +static const struct obex_mime_type_driver folder = { .target = FTP_TARGET, .target_size = FTP_TARGET_SIZE, .mimetype = "x-obex/folder-listing", @@ -670,7 +670,7 @@ static struct obex_mime_type_driver folder = { .read = folder_read, }; -static struct obex_mime_type_driver pcsuite = { +static const struct obex_mime_type_driver pcsuite = { .target = FTP_TARGET, .target_size = FTP_TARGET_SIZE, .who = PCSUITE_WHO, diff --git a/obexd/plugins/irmc.c b/obexd/plugins/irmc.c index cd143e7a3..e85cf70a1 100644 --- a/obexd/plugins/irmc.c +++ b/obexd/plugins/irmc.c @@ -419,7 +419,7 @@ static ssize_t irmc_read(void *object, void *buf, size_t count) return len; } -static struct obex_mime_type_driver irmc_driver = { +static const struct obex_mime_type_driver irmc_driver = { .target = IRMC_TARGET, .target_size = IRMC_TARGET_SIZE, .open = irmc_open, diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c index 5d00bc563..f0eaf6d82 100644 --- a/obexd/plugins/mas.c +++ b/obexd/plugins/mas.c @@ -793,7 +793,7 @@ static struct obex_service_driver mas = { .disconnect = mas_disconnect, }; -static struct obex_mime_type_driver mime_map = { +static const struct obex_mime_type_driver mime_map = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = NULL, @@ -803,7 +803,7 @@ static struct obex_mime_type_driver mime_map = { .write = any_write, }; -static struct obex_mime_type_driver mime_message = { +static const struct obex_mime_type_driver mime_message = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/message", @@ -813,7 +813,7 @@ static struct obex_mime_type_driver mime_message = { .write = any_write, }; -static struct obex_mime_type_driver mime_folder_listing = { +static const struct obex_mime_type_driver mime_folder_listing = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-obex/folder-listing", @@ -824,7 +824,7 @@ static struct obex_mime_type_driver mime_folder_listing = { .write = any_write, }; -static struct obex_mime_type_driver mime_msg_listing = { +static const struct obex_mime_type_driver mime_msg_listing = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/MAP-msg-listing", @@ -835,7 +835,7 @@ static struct obex_mime_type_driver mime_msg_listing = { .write = any_write, }; -static struct obex_mime_type_driver mime_notification_registration = { +static const struct obex_mime_type_driver mime_notification_registration = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/MAP-NotificationRegistration", @@ -845,7 +845,7 @@ static struct obex_mime_type_driver mime_notification_registration = { .write = any_write, }; -static struct obex_mime_type_driver mime_message_status = { +static const struct obex_mime_type_driver mime_message_status = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/messageStatus", @@ -855,7 +855,7 @@ static struct obex_mime_type_driver mime_message_status = { .write = any_write, }; -static struct obex_mime_type_driver mime_message_update = { +static const struct obex_mime_type_driver mime_message_update = { .target = MAS_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/MAP-messageUpdate", @@ -865,7 +865,7 @@ static struct obex_mime_type_driver mime_message_update = { .write = any_write, }; -static struct obex_mime_type_driver *map_drivers[] = { +static const struct obex_mime_type_driver *map_drivers[] = { &mime_map, &mime_message, &mime_folder_listing, diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c index ab5236316..b363c673b 100644 --- a/obexd/plugins/pbap.c +++ b/obexd/plugins/pbap.c @@ -929,7 +929,7 @@ static ssize_t vobject_vcard_read(void *object, void *buf, size_t count) return string_read(obj->buffer, buf, count); } -static struct obex_mime_type_driver mime_pull = { +static const struct obex_mime_type_driver mime_pull = { .target = PBAP_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/phonebook", @@ -939,7 +939,7 @@ static struct obex_mime_type_driver mime_pull = { .get_next_header = vobject_pull_get_next_header, }; -static struct obex_mime_type_driver mime_list = { +static const struct obex_mime_type_driver mime_list = { .target = PBAP_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/vcard-listing", @@ -949,7 +949,7 @@ static struct obex_mime_type_driver mime_list = { .get_next_header = vobject_list_get_next_header, }; -static struct obex_mime_type_driver mime_vcard = { +static const struct obex_mime_type_driver mime_vcard = { .target = PBAP_TARGET, .target_size = TARGET_SIZE, .mimetype = "x-bt/vcard", diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c index f5a9d9ae8..d4a0394af 100644 --- a/obexd/plugins/pcsuite.c +++ b/obexd/plugins/pcsuite.c @@ -467,7 +467,7 @@ static int backup_flush(void *object) return 0; } -static struct obex_mime_type_driver backup = { +static const struct obex_mime_type_driver backup = { .target = FTP_TARGET, .target_size = TARGET_SIZE, .mimetype = "application/vnd.nokia-backup", diff --git a/obexd/plugins/syncevolution.c b/obexd/plugins/syncevolution.c index 88744f28a..f0387b986 100644 --- a/obexd/plugins/syncevolution.c +++ b/obexd/plugins/syncevolution.c @@ -427,7 +427,7 @@ static ssize_t synce_write(void *object, const void *buf, size_t count) return -EAGAIN; } -static struct obex_mime_type_driver synce_driver = { +static const struct obex_mime_type_driver synce_driver = { .target = SYNCML_TARGET, .target_size = SYNCML_TARGET_SIZE, .open = synce_open, diff --git a/obexd/src/mimetype.c b/obexd/src/mimetype.c index cf6e15dc6..462d4ba2f 100644 --- a/obexd/src/mimetype.c +++ b/obexd/src/mimetype.c @@ -104,7 +104,7 @@ int obex_object_set_io_watch(void *object, obex_object_io_func func, return 0; } -static struct obex_mime_type_driver *find_driver(const uint8_t *target, +static const struct obex_mime_type_driver *find_driver(const uint8_t *target, unsigned int target_size, const char *mimetype, const uint8_t *who, unsigned int who_size) @@ -112,7 +112,7 @@ static struct obex_mime_type_driver *find_driver(const uint8_t *target, GSList *l; for (l = drivers; l; l = l->next) { - struct obex_mime_type_driver *driver = l->data; + const struct obex_mime_type_driver *driver = l->data; if (memncmp0(target, target_size, driver->target, driver->target_size)) continue; @@ -134,12 +134,12 @@ static struct obex_mime_type_driver *find_driver(const uint8_t *target, return NULL; } -struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, +const struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, unsigned int target_size, const char *mimetype, const uint8_t *who, unsigned int who_size) { - struct obex_mime_type_driver *driver; + const struct obex_mime_type_driver *driver; driver = find_driver(target, target_size, mimetype, who, who_size); if (driver == NULL) { @@ -162,7 +162,7 @@ struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, return driver; } -int obex_mime_type_driver_register(struct obex_mime_type_driver *driver) +int obex_mime_type_driver_register(const struct obex_mime_type_driver *driver) { if (!driver) { error("Invalid driver"); @@ -178,12 +178,12 @@ int obex_mime_type_driver_register(struct obex_mime_type_driver *driver) DBG("driver %p mimetype %s registered", driver, driver->mimetype); - drivers = g_slist_append(drivers, driver); + drivers = g_slist_append(drivers, (gpointer)driver); return 0; } -void obex_mime_type_driver_unregister(struct obex_mime_type_driver *driver) +void obex_mime_type_driver_unregister(const struct obex_mime_type_driver *driver) { if (!g_slist_find(drivers, driver)) { error("Unable to unregister: No such driver %p", driver); diff --git a/obexd/src/mimetype.h b/obexd/src/mimetype.h index 55ddded08..35346bb46 100644 --- a/obexd/src/mimetype.h +++ b/obexd/src/mimetype.h @@ -30,9 +30,9 @@ struct obex_mime_type_driver { int (*remove) (const char *name); }; -int obex_mime_type_driver_register(struct obex_mime_type_driver *driver); -void obex_mime_type_driver_unregister(struct obex_mime_type_driver *driver); -struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, +int obex_mime_type_driver_register(const struct obex_mime_type_driver *driver); +void obex_mime_type_driver_unregister(const struct obex_mime_type_driver *driver); +const struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target, unsigned int target_size, const char *mimetype, const uint8_t *who, unsigned int who_size); diff --git a/obexd/src/obex-priv.h b/obexd/src/obex-priv.h index db409e7e4..994144678 100644 --- a/obexd/src/obex-priv.h +++ b/obexd/src/obex-priv.h @@ -38,7 +38,7 @@ struct obex_session { struct obex_server *server; gboolean checked; GObex *obex; - struct obex_mime_type_driver *driver; + const struct obex_mime_type_driver *driver; gboolean headers_sent; }; From patchwork Tue Jan 16 14:00:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520861 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 308F51BDF1 for ; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GWAz+XD5" Received: by smtp.kernel.org (Postfix) with ESMTPS id 150D0C4166D; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413640; bh=+R4T9QSIXlHs4bM3MouqH7eBByUgfKx42G8CxrQ62u4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=GWAz+XD57X7ZZ1orfSNdfHwcCbHl433xmP/3QtQeBUQfh4PN9wEmmnRt9Fz5DySIJ zV7HuY78FpZ6A4jXDsu5KvbbaSEFIUqfFBl+un892I3ZhKf5qOSsgNM+GmobWiRCXt vU85UUfopJOHxzUun5YGe2UYkYQ0wr5slAEIGrqXbPXPgSuqIZ71CGfvOC/6P9TLGw seX3kzItPz5CT1ACLIhZVlCVyGREpuMAx/urnLOHC7CN0j7O5IzAyul/U5IfNQTASe Nk5iv/sUEFS5c/YBjXEWVknumpOYGphTeD6ykq8wR1wLZg1odcNluCl4WRh6RCjKZq JdVnYPYgpw2fQ== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 06D66C47DA6; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:42 +0000 Subject: [PATCH BlueZ 17/20] obexd: const obex_service_driver instances and API Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-17-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=9315; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=PLJ5Voc0l/2l/ZQxlBtjyCuSLocbfz1q4Ph0208Vyz0=; b=YhPEyfLP2GbmdSEVORIMVCnzP4Iwf/iAA8ZKSCko8DHpG1+u/Ybzf+em2HmevlddcV5dbWAWE VE13HVAL1exBrhBC7iw+AKF9d4r5TT5KtNNgNH6wTVU4Lx0fNsez+HE X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- obexd/client/mns.c | 2 +- obexd/plugins/bluetooth.c | 4 ++-- obexd/plugins/ftp.c | 2 +- obexd/plugins/irmc.c | 2 +- obexd/plugins/mas.c | 2 +- obexd/plugins/opp.c | 2 +- obexd/plugins/pbap.c | 2 +- obexd/plugins/pcsuite.c | 2 +- obexd/plugins/syncevolution.c | 2 +- obexd/src/obex-priv.h | 2 +- obexd/src/server.c | 2 +- obexd/src/service.c | 20 ++++++++++---------- obexd/src/service.h | 6 +++--- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/obexd/client/mns.c b/obexd/client/mns.c index 3b2ae1076..702cf0367 100644 --- a/obexd/client/mns.c +++ b/obexd/client/mns.c @@ -346,7 +346,7 @@ static ssize_t event_report_write(void *obj, const void *buf, size_t count) return count; } -static struct obex_service_driver mns = { +static const struct obex_service_driver mns = { .name = "Message Notification server", .service = OBEX_MNS, .target = MNS_TARGET, diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c index d232d3fd5..bcf6e1998 100644 --- a/obexd/plugins/bluetooth.c +++ b/obexd/plugins/bluetooth.c @@ -41,7 +41,7 @@ struct bluetooth_profile { struct obex_server *server; - struct obex_service_driver *driver; + const struct obex_service_driver *driver; char *uuid; char *path; }; @@ -355,7 +355,7 @@ static void *bluetooth_start(struct obex_server *server, int *err) const GSList *l; for (l = server->drivers; l; l = l->next) { - struct obex_service_driver *driver = l->data; + const struct obex_service_driver *driver = l->data; struct bluetooth_profile *profile; const char *uuid; diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c index 4b04bab06..874fe2b8b 100644 --- a/obexd/plugins/ftp.c +++ b/obexd/plugins/ftp.c @@ -494,7 +494,7 @@ static void ftp_reset(struct obex_session *os, void *user_data) manager_emit_transfer_completed(ftp->transfer); } -static struct obex_service_driver ftp = { +static const struct obex_service_driver ftp = { .name = "File Transfer server", .service = OBEX_FTP, .target = FTP_TARGET, diff --git a/obexd/plugins/irmc.c b/obexd/plugins/irmc.c index e85cf70a1..cab97b620 100644 --- a/obexd/plugins/irmc.c +++ b/obexd/plugins/irmc.c @@ -427,7 +427,7 @@ static const struct obex_mime_type_driver irmc_driver = { .read = irmc_read, }; -static struct obex_service_driver irmc = { +static const struct obex_service_driver irmc = { .name = "IRMC Sync server", .service = OBEX_IRMC, .target = IRMC_TARGET, diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c index f0eaf6d82..10b972d65 100644 --- a/obexd/plugins/mas.c +++ b/obexd/plugins/mas.c @@ -781,7 +781,7 @@ static void *notification_registration_open(const char *name, int oflag, return mas; } -static struct obex_service_driver mas = { +static const struct obex_service_driver mas = { .name = "Message Access server", .service = OBEX_MAS, .target = MAS_TARGET, diff --git a/obexd/plugins/opp.c b/obexd/plugins/opp.c index 860161303..777f5f8ed 100644 --- a/obexd/plugins/opp.c +++ b/obexd/plugins/opp.c @@ -155,7 +155,7 @@ static void opp_reset(struct obex_session *os, void *user_data) manager_emit_transfer_completed(user_data); } -static struct obex_service_driver driver = { +static const struct obex_service_driver driver = { .name = "Object Push server", .service = OBEX_OPP, .connect = opp_connect, diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c index b363c673b..4175f9de8 100644 --- a/obexd/plugins/pbap.c +++ b/obexd/plugins/pbap.c @@ -634,7 +634,7 @@ static int pbap_chkput(struct obex_session *os, void *user_data) return -EBADR; } -static struct obex_service_driver pbap = { +static const struct obex_service_driver pbap = { .name = "Phonebook Access server", .service = OBEX_PBAP, .target = PBAP_TARGET, diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c index d4a0394af..752074c08 100644 --- a/obexd/plugins/pcsuite.c +++ b/obexd/plugins/pcsuite.c @@ -231,7 +231,7 @@ static void pcsuite_disconnect(struct obex_session *os, void *user_data) g_free(pcsuite); } -static struct obex_service_driver pcsuite = { +static const struct obex_service_driver pcsuite = { .name = "Nokia OBEX PC Suite Services", .service = OBEX_PCSUITE, .channel = PCSUITE_CHANNEL, diff --git a/obexd/plugins/syncevolution.c b/obexd/plugins/syncevolution.c index f0387b986..ae3dc48c4 100644 --- a/obexd/plugins/syncevolution.c +++ b/obexd/plugins/syncevolution.c @@ -436,7 +436,7 @@ static const struct obex_mime_type_driver synce_driver = { .write = synce_write, }; -static struct obex_service_driver synce = { +static const struct obex_service_driver synce = { .name = "OBEX server for SyncML, using SyncEvolution", .service = OBEX_SYNCEVOLUTION, .channel = SYNCEVOLUTION_CHANNEL, diff --git a/obexd/src/obex-priv.h b/obexd/src/obex-priv.h index 994144678..d2c62a596 100644 --- a/obexd/src/obex-priv.h +++ b/obexd/src/obex-priv.h @@ -33,7 +33,7 @@ struct obex_session { void *object; gboolean aborted; int err; - struct obex_service_driver *service; + const struct obex_service_driver *service; void *service_data; struct obex_server *server; gboolean checked; diff --git a/obexd/src/server.c b/obexd/src/server.c index a8fc45092..eef149272 100644 --- a/obexd/src/server.c +++ b/obexd/src/server.c @@ -82,7 +82,7 @@ int obex_server_init(void) } for (l = drivers; l; l = l->next) { - struct obex_service_driver *driver = l->data; + const struct obex_service_driver *driver = l->data; init_server(driver->service, transports); } diff --git a/obexd/src/service.c b/obexd/src/service.c index 0f4e420e8..332d61939 100644 --- a/obexd/src/service.c +++ b/obexd/src/service.c @@ -26,14 +26,14 @@ static GSList *drivers = NULL; -struct obex_service_driver *obex_service_driver_find(GSList *drivers, +const struct obex_service_driver *obex_service_driver_find(GSList *drivers, const uint8_t *target, unsigned int target_size, const uint8_t *who, unsigned int who_size) { GSList *l; for (l = drivers; l; l = l->next) { - struct obex_service_driver *driver = l->data; + const struct obex_service_driver *driver = l->data; /* who is optional, so only check for it if not NULL */ if (who != NULL && memncmp0(who, who_size, driver->who, @@ -57,10 +57,10 @@ GSList *obex_service_driver_list(uint16_t services) return drivers; for (l = drivers; l && services; l = l->next) { - struct obex_service_driver *driver = l->data; + const struct obex_service_driver *driver = l->data; if (driver->service & services) { - list = g_slist_append(list, driver); + list = g_slist_append(list, (gpointer)driver); services &= ~driver->service; } } @@ -68,12 +68,12 @@ GSList *obex_service_driver_list(uint16_t services) return list; } -static struct obex_service_driver *find_driver(uint16_t service) +static const struct obex_service_driver *find_driver(uint16_t service) { GSList *l; for (l = drivers; l; l = l->next) { - struct obex_service_driver *driver = l->data; + const struct obex_service_driver *driver = l->data; if (driver->service == service) return driver; @@ -82,7 +82,7 @@ static struct obex_service_driver *find_driver(uint16_t service) return NULL; } -int obex_service_driver_register(struct obex_service_driver *driver) +int obex_service_driver_register(const struct obex_service_driver *driver) { if (!driver) { error("Invalid driver"); @@ -99,14 +99,14 @@ int obex_service_driver_register(struct obex_service_driver *driver) /* Drivers that support who has priority */ if (driver->who) - drivers = g_slist_prepend(drivers, driver); + drivers = g_slist_prepend(drivers, (gpointer)driver); else - drivers = g_slist_append(drivers, driver); + drivers = g_slist_append(drivers, (gpointer)driver); return 0; } -void obex_service_driver_unregister(struct obex_service_driver *driver) +void obex_service_driver_unregister(const struct obex_service_driver *driver) { if (!g_slist_find(drivers, driver)) { error("Unable to unregister: No such driver %p", driver); diff --git a/obexd/src/service.h b/obexd/src/service.h index e3aee3bf3..8d9f70558 100644 --- a/obexd/src/service.h +++ b/obexd/src/service.h @@ -32,9 +32,9 @@ struct obex_service_driver { void (*reset) (struct obex_session *os, void *user_data); }; -int obex_service_driver_register(struct obex_service_driver *driver); -void obex_service_driver_unregister(struct obex_service_driver *driver); +int obex_service_driver_register(const struct obex_service_driver *driver); +void obex_service_driver_unregister(const struct obex_service_driver *driver); GSList *obex_service_driver_list(uint16_t services); -struct obex_service_driver *obex_service_driver_find(GSList *drivers, +const struct obex_service_driver *obex_service_driver_find(GSList *drivers, const uint8_t *target, unsigned int target_size, const uint8_t *who, unsigned int who_size); From patchwork Tue Jan 16 14:00:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520863 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E72F1BDFD for ; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Nrx3v3Kr" Received: by smtp.kernel.org (Postfix) with ESMTPS id 20DBBC41679; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413640; bh=qdlAjkkwepTmGDFlzrL38jcr9hfN19bbKIi96l59uRQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=Nrx3v3KrvNDuKG9uky3+AnZ/9VBt0cr3LkB0EzRNvNPDXf4lL8i7tcWquGwweNfp+ B2LlgKtyVD/bWtXaUh0aU/b8qsfZtsj5jMatpDudvUy32J9mz1NxNldnHl8b9m2ZCO TtwnBH6FnRUZcMHtZ4tykG7PGHuNhFJh2YlJ5v4AZ0VA1aPAC59cR3pSuqCTP9phMA YMVyaB/fWFEcj74VbgsyeSyKlfjxLZDpvyVvWW5LRppxz59B4usua34FNRAv0UFQsC fKqucUXEyWzSwMnmscGB3KzbKKZzCx/QLs/nRSjjS0Lh2OroOEGb4tKq1ELU2Xs1Uo B67B3WLraTW6Q== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 120A1C47DA2; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:43 +0000 Subject: [PATCH BlueZ 18/20] obexd: const obex_transport_driver instances and API Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-18-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=5127; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=JDoUhBi2XiJb/UMjdc14J4bi0Pzc2uyYvi1v/YGGtyk=; b=2h9Nl51z4y31plLNxA9+pBsKij7tQV4om4ytOX1ZzbgyGjktrKRZ/81gi7imQBXp53r/rqGmr qVOsISJYekPCnRrA2pONBADY3hfu0WmmEPD5BXlDC+1zB1jT+jsvkUV X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- obexd/plugins/bluetooth.c | 2 +- obexd/src/obex.c | 4 ++-- obexd/src/server.c | 8 ++++---- obexd/src/server.h | 2 +- obexd/src/transport.c | 14 +++++++------- obexd/src/transport.h | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c index bcf6e1998..51afdc9d0 100644 --- a/obexd/plugins/bluetooth.c +++ b/obexd/plugins/bluetooth.c @@ -416,7 +416,7 @@ static int bluetooth_getsockname(GIOChannel *io, char **name) return 0; } -static struct obex_transport_driver driver = { +static const struct obex_transport_driver driver = { .name = "bluetooth", .start = bluetooth_start, .getpeername = bluetooth_getpeername, diff --git a/obexd/src/obex.c b/obexd/src/obex.c index 4bf5ad124..526861f40 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -1085,7 +1085,7 @@ ssize_t obex_get_non_header_data(struct obex_session *os, int obex_getpeername(struct obex_session *os, char **name) { - struct obex_transport_driver *transport = os->server->transport; + const struct obex_transport_driver *transport = os->server->transport; if (transport == NULL || transport->getpeername == NULL) return -ENOTSUP; @@ -1095,7 +1095,7 @@ int obex_getpeername(struct obex_session *os, char **name) int obex_getsockname(struct obex_session *os, char **name) { - struct obex_transport_driver *transport = os->server->transport; + const struct obex_transport_driver *transport = os->server->transport; if (transport == NULL || transport->getsockname == NULL) return -ENOTSUP; diff --git a/obexd/src/server.c b/obexd/src/server.c index eef149272..0dca728d2 100644 --- a/obexd/src/server.c +++ b/obexd/src/server.c @@ -34,12 +34,12 @@ static GSList *servers = NULL; -static void init_server(uint16_t service, GSList *transports) +static void init_server(uint16_t service, const GSList *transports) { - GSList *l; + const GSList *l; for (l = transports; l; l = l->next) { - struct obex_transport_driver *transport = l->data; + const struct obex_transport_driver *transport = l->data; struct obex_server *server; int err; @@ -66,7 +66,7 @@ static void init_server(uint16_t service, GSList *transports) int obex_server_init(void) { GSList *drivers; - GSList *transports; + const GSList *transports; GSList *l; drivers = obex_service_driver_list(0); diff --git a/obexd/src/server.h b/obexd/src/server.h index c31236ec0..ec063ae2e 100644 --- a/obexd/src/server.h +++ b/obexd/src/server.h @@ -10,7 +10,7 @@ */ struct obex_server { - struct obex_transport_driver *transport; + const struct obex_transport_driver *transport; void *transport_data; GSList *drivers; }; diff --git a/obexd/src/transport.c b/obexd/src/transport.c index 4b5895e5d..234a0e004 100644 --- a/obexd/src/transport.c +++ b/obexd/src/transport.c @@ -27,13 +27,13 @@ static GSList *drivers = NULL; -static struct obex_transport_driver *obex_transport_driver_find( +static const struct obex_transport_driver *obex_transport_driver_find( const char *name) { - GSList *l; + const GSList *l; for (l = drivers; l; l = l->next) { - struct obex_transport_driver *driver = l->data; + const struct obex_transport_driver *driver = l->data; if (g_strcmp0(name, driver->name) == 0) return driver; @@ -42,12 +42,12 @@ static struct obex_transport_driver *obex_transport_driver_find( return NULL; } -GSList *obex_transport_driver_list(void) +const GSList *obex_transport_driver_list(void) { return drivers; } -int obex_transport_driver_register(struct obex_transport_driver *driver) +int obex_transport_driver_register(const struct obex_transport_driver *driver) { if (!driver) { error("Invalid driver"); @@ -62,12 +62,12 @@ int obex_transport_driver_register(struct obex_transport_driver *driver) DBG("driver %p transport %s registered", driver, driver->name); - drivers = g_slist_prepend(drivers, driver); + drivers = g_slist_prepend(drivers, (gpointer)driver); return 0; } -void obex_transport_driver_unregister(struct obex_transport_driver *driver) +void obex_transport_driver_unregister(const struct obex_transport_driver *driver) { if (!g_slist_find(drivers, driver)) { error("Unable to unregister: No such driver %p", driver); diff --git a/obexd/src/transport.h b/obexd/src/transport.h index 3a16b7620..fe79432cf 100644 --- a/obexd/src/transport.h +++ b/obexd/src/transport.h @@ -17,6 +17,6 @@ struct obex_transport_driver { void (*stop) (void *data); }; -int obex_transport_driver_register(struct obex_transport_driver *driver); -void obex_transport_driver_unregister(struct obex_transport_driver *driver); -GSList *obex_transport_driver_list(void); +int obex_transport_driver_register(const struct obex_transport_driver *driver); +void obex_transport_driver_unregister(const struct obex_transport_driver *driver); +const GSList *obex_transport_driver_list(void); From patchwork Tue Jan 16 14:00:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520864 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C0581BDFF for ; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="giWoigIy" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2E480C4167D; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413640; bh=KaNZfKSdUM++NRak2Yp5k80sRWCqzIDfSojhCSsSEDY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=giWoigIyVVKsxXEbA7S4GbJatCIwF4IfVQjvWReJELyvaQZx5zPG2pJqXGjrtt/qm VIiYCGVtDd5DHXhSINcTQfEJ93K619rvq5mfJphLUFt24vfAE4O0eLsJ91QLUSL3V4 vzGXAotr7aO/PkClPsseyc0dimq2uXegWopYMA4zntWbZd6Ma5AoOfev29/L9LrHu5 h1X5c8yzaITRJq+GoHIq7cS0OhazlhQ+ptpvhTFqo2M4sg7agEw8ALxoYScin2CMN0 m5LZp4LUcRiQWTHMj/k7U6zLpVFnKL6Ksc26cR9Op+XSl0Spk3e4gyJ3GUBRiloObo xusnwhRREnzNA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C420C47DA9; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:44 +0000 Subject: [PATCH BlueZ 19/20] obexd: const annotate misc immutable data Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-19-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=3937; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=LrDZdJSOkuXg0aaks0vIhPZwBeRbl04SybrYFVckFXg=; b=OUeSwrfDljmljB/eO09WAXjnvynxultMG2EumZa87b/P/KGASR+i3PHVEx+aWJScKZHtVxPs0 q3cHc5NWn0ZDMg6x5xSGZg1R1Tbsosir7IRxgaoQX2ytqXNK9LM/X4h X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- obexd/client/manager.c | 6 +++--- obexd/client/map.c | 4 ++-- obexd/client/mns.c | 4 ++-- obexd/plugins/phonebook-ebook.c | 2 +- obexd/src/main.c | 2 +- obexd/src/obex.c | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/obexd/client/manager.c b/obexd/client/manager.c index 75f1bfb04..ad1fbb04a 100644 --- a/obexd/client/manager.c +++ b/obexd/client/manager.c @@ -241,7 +241,7 @@ static const GDBusMethodTable client_methods[] = { static DBusConnection *conn = NULL; -static struct obc_module { +static const struct obc_module { const char *name; int (*init) (void); void (*exit) (void); @@ -258,7 +258,7 @@ static struct obc_module { int client_manager_init(void) { DBusError derr; - struct obc_module *module; + const struct obc_module *module; dbus_error_init(&derr); @@ -289,7 +289,7 @@ int client_manager_init(void) void client_manager_exit(void) { - struct obc_module *module; + const struct obc_module *module; if (conn == NULL) return; diff --git a/obexd/client/map.c b/obexd/client/map.c index 74828cddb..513dcaf14 100644 --- a/obexd/client/map.c +++ b/obexd/client/map.c @@ -1060,7 +1060,7 @@ static void parse_protected(struct map_msg *msg, const char *value) MAP_MSG_INTERFACE, "Protected"); } -static struct map_msg_parser { +static const struct map_msg_parser { const char *name; void (*func) (struct map_msg *msg, const char *value); } msg_parsers[] = { @@ -1120,7 +1120,7 @@ static void msg_element(GMarkupParseContext *ctxt, const char *element, &msg->path); for (i = 0, key = names[i]; key; key = names[++i]) { - struct map_msg_parser *parser; + const struct map_msg_parser *parser; for (parser = msg_parsers; parser && parser->name; parser++) { if (strcasecmp(key, parser->name) == 0) { diff --git a/obexd/client/mns.c b/obexd/client/mns.c index 702cf0367..c7f86afdc 100644 --- a/obexd/client/mns.c +++ b/obexd/client/mns.c @@ -233,7 +233,7 @@ static void parse_event_report_priority(struct map_event *event, event->priority = g_strdup(value); } -static struct map_event_report_parser { +static const struct map_event_report_parser { const char *name; void (*func) (struct map_event *event, const char *value); } event_report_parsers[] = { @@ -262,7 +262,7 @@ static void event_report_element(GMarkupParseContext *ctxt, return; for (i = 0, key = names[i]; key; key = names[++i]) { - struct map_event_report_parser *parser; + const struct map_event_report_parser *parser; for (parser = event_report_parsers; parser && parser->name; parser++) { diff --git a/obexd/plugins/phonebook-ebook.c b/obexd/plugins/phonebook-ebook.c index 29ec9d213..e509dd29a 100644 --- a/obexd/plugins/phonebook-ebook.c +++ b/obexd/plugins/phonebook-ebook.c @@ -55,7 +55,7 @@ struct query_context { gboolean canceled; }; -static char *attribute_mask[] = { +static const char *attribute_mask[] = { /* 0 */ "VERSION", "FN", "N", diff --git a/obexd/src/main.c b/obexd/src/main.c index d950883f0..151574afa 100644 --- a/obexd/src/main.c +++ b/obexd/src/main.c @@ -138,7 +138,7 @@ static gboolean parse_debug(const char *key, const char *value, return TRUE; } -static GOptionEntry options[] = { +static const GOptionEntry options[] = { { "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK, parse_debug, "Enable debug information output", "DEBUG" }, diff --git a/obexd/src/obex.c b/obexd/src/obex.c index 526861f40..98d6245a4 100644 --- a/obexd/src/obex.c +++ b/obexd/src/obex.c @@ -55,7 +55,7 @@ struct auth_header { } __attribute__ ((packed)); /* Possible commands */ -static struct { +static const struct { int cmd; const char *name; } obex_command[] = { From patchwork Tue Jan 16 14:00:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov via B4 Relay X-Patchwork-Id: 13520865 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 528CB1BF20 for ; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AD7RzYfg" Received: by smtp.kernel.org (Postfix) with ESMTPS id 35F77C41674; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705413640; bh=ncr/8HTu9GduEUF79z9mYZHMTbDjQDdyTAeE4RZ7gJs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=AD7RzYfgukWXTqDXTMi/E+Gm4O88lCiDq6mbJ8IEVIxA4Rr80gyZRtph0hJfgyMLZ 7REsc3V7/ehyHasHDYCchAIMNJpzjT2B9yHspX97npJqtvALzK9oeD2zsR8QOANIS7 vUFs5w+FWtCspmEPKpjvzpcakDOelOoaroRwwgJmWfaaqXprK+UhEOo6yCR5V0PsNA oWfNsPiqi4Oio/WuqYFALMY9SG4Ijru9ZJJGIcEaLb4SqVW3jQN9fuswz8VJlkellh IV4Iotj46gUj8Bywg9Ph13dOiC3Uq+plCja/dRmhMpH0NIpmd+DTOSNtyW5/xb6FbA iZMvIqBnQTofw== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26C2BC47077; Tue, 16 Jan 2024 14:00:40 +0000 (UTC) From: Emil Velikov via B4 Relay Date: Tue, 16 Jan 2024 14:00:45 +0000 Subject: [PATCH BlueZ 20/20] obexd: const annotate obex_plugin_desc entrypoint Precedence: bulk X-Mailing-List: linux-bluetooth@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240116-const-v1-20-17c87978f40b@gmail.com> References: <20240116-const-v1-0-17c87978f40b@gmail.com> In-Reply-To: <20240116-const-v1-0-17c87978f40b@gmail.com> To: linux-bluetooth@vger.kernel.org Cc: Emil Velikov X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1705413636; l=2465; i=emil.l.velikov@gmail.com; s=20230301; h=from:subject:message-id; bh=NqOjgJzWeyVBPk28dTgOSntse3r5l3o0yfOgLtILLQY=; b=xeyoPUXasnGeNeZ/P9F3naSPrGJAwtxNp0n5k37lCwevB+fJIkRYGYrNf6xkaWYCH+YeBf+u3 sPqffyCUj1yBqKGbUAK+Z0lQEwRHpFBUrhqKc5LJMIgKJXIdFfqO4ic X-Developer-Key: i=emil.l.velikov@gmail.com; a=ed25519; pk=qeUTVTNyI3rcR2CfNNWsloTihgzmtbZo98GdxwZKCkY= X-Endpoint-Received: by B4 Relay for emil.l.velikov@gmail.com/20230301 with auth_id=35 X-Original-From: Emil Velikov Reply-To: From: Emil Velikov --- obexd/src/genbuiltin | 4 ++-- obexd/src/plugin.c | 8 ++++---- obexd/src/plugin.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/obexd/src/genbuiltin b/obexd/src/genbuiltin index 39f773527..e60b5189a 100755 --- a/obexd/src/genbuiltin +++ b/obexd/src/genbuiltin @@ -2,11 +2,11 @@ for i in $* do - echo "extern struct obex_plugin_desc __obex_builtin_$i;" + echo "extern const struct obex_plugin_desc __obex_builtin_$i;" done echo -echo "static struct obex_plugin_desc *__obex_builtin[] = {" +echo "static const struct obex_plugin_desc *__obex_builtin[] = {" for i in $* do diff --git a/obexd/src/plugin.c b/obexd/src/plugin.c index 0df9d5258..a3eb24753 100644 --- a/obexd/src/plugin.c +++ b/obexd/src/plugin.c @@ -38,10 +38,10 @@ static GSList *plugins = NULL; struct obex_plugin { void *handle; - struct obex_plugin_desc *desc; + const struct obex_plugin_desc *desc; }; -static gboolean add_plugin(void *handle, struct obex_plugin_desc *desc) +static gboolean add_plugin(void *handle, const struct obex_plugin_desc *desc) { struct obex_plugin *plugin; @@ -66,7 +66,7 @@ static gboolean add_plugin(void *handle, struct obex_plugin_desc *desc) return TRUE; } -static gboolean check_plugin(struct obex_plugin_desc *desc, +static gboolean check_plugin(const struct obex_plugin_desc *desc, char **patterns, char **excludes) { if (excludes) { @@ -132,7 +132,7 @@ gboolean plugin_init(const char *pattern, const char *exclude) } while ((file = g_dir_read_name(dir)) != NULL) { - struct obex_plugin_desc *desc; + const struct obex_plugin_desc *desc; void *handle; char *filename; diff --git a/obexd/src/plugin.h b/obexd/src/plugin.h index 703878460..a91746cbc 100644 --- a/obexd/src/plugin.h +++ b/obexd/src/plugin.h @@ -16,14 +16,14 @@ struct obex_plugin_desc { #ifdef OBEX_PLUGIN_BUILTIN #define OBEX_PLUGIN_DEFINE(name, init, exit) \ - struct obex_plugin_desc __obex_builtin_ ## name = { \ + const struct obex_plugin_desc __obex_builtin_ ## name = { \ #name, init, exit \ }; #else #define OBEX_PLUGIN_DEFINE(name,init,exit) \ extern struct obex_plugin_desc obex_plugin_desc \ __attribute__ ((visibility("default"))); \ - struct obex_plugin_desc obex_plugin_desc = { \ + const struct obex_plugin_desc obex_plugin_desc = { \ #name, init, exit \ }; #endif