Skip to contentSkip to conversation

mesh: Remove unused but set variable

PATCH In review Bastien Nocera 3 participants 5 messages May 11 – May 12 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 mesh: Remove unused but set variable

We played around with the bits, but didn't do anything with it.

mesh/net.c: In function ‘ack_received’:
mesh/net.c:1569:18: error: variable ‘ack_copy’ set but not used [-Werror=unused-but-set-variable=]

 1569 |         uint32_t ack_copy = ack_flag;
      |                  ^~~~~~~~
---
 mesh/net.c | 5 -----
 1 file changed, 5 deletions(-)
mesh/net.c +0 -5
index b29e24f5d4a9..2c1be1f2cc63 100644
@@ -1566,7 +1566,6 @@ static void ack_received(struct mesh_net *net, bool timeout,
 {
 	struct mesh_sar *outgoing;
 	uint32_t seg_flag = 0x00000001;
-	uint32_t ack_copy = ack_flag;
 	uint16_t i;
 
 	l_debug("ACK Rxed (%x) (to:%d): %8.8x", seq0, timeout, ack_flag);
@@ -1599,8 +1598,6 @@ static void ack_received(struct mesh_net *net, bool timeout,
 
 	outgoing->last_nak |= ack_flag;
 
-	ack_copy &= outgoing->flags;
-
 	for (i = 0; i <= SEG_MAX(true, outgoing->len); i++, seg_flag <<= 1) {
 		if (seg_flag & ack_flag) {
 			l_debug("Skipping Seg %d of %d",
@@ -1608,8 +1605,6 @@ static void ack_received(struct mesh_net *net, bool timeout,
 			continue;
 		}
 
-		ack_copy |= seg_flag;
-
 		l_debug("Resend Seg %d net:%p dst:%x app_idx:%3.3x",
 				i, net, outgoing->remote, outgoing->app_idx);
 
Signature · 1 line
2.54.0
#1 lore raw

PATCH 2/3 mesh: Fix str{r,}chr usage

Fix the code manipulating "const char *" return values from json_object_to_json_string_ext() to modify it for printing, we're not allowed to do that.

tools/mesh/mesh-db.c: In function ‘mesh_db_finish_export’:
tools/mesh/mesh-db.c:2598:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
2598 | pos = strrchr(hdr, '}');
| ^
tools/mesh/mesh-db.c:2604:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
2604 | pos = strrchr(hdr, '"');
| ^
tools/mesh/mesh-db.c:2613:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
2613 | pos = strchr(str, '{');
| ^

---
 tools/mesh/mesh-db.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)
tools/mesh/mesh-db.c +13 -4
index fb9c436d1d06..7bb8ab53ecbb 100644
@@ -2547,7 +2547,9 @@ void *mesh_db_prepare_export(void)
 bool mesh_db_finish_export(bool is_error, void *expt_cfg, const char *fname)
 {
 	FILE *outfile = NULL;
-	const char *str, *hdr;
+	const char *str_s, *hdr_s;
+	char *str = NULL;
+	char *hdr = NULL;
 	json_object *jhdr = NULL;
 	bool result = false;
 	char *pos;
@@ -2581,15 +2583,18 @@ bool mesh_db_finish_export(bool is_error, void *expt_cfg, const char *fname)
 	if (!add_string(jhdr, "version", schema_version))
 		goto done;
 
-	hdr = json_object_to_json_string_ext(jhdr, JSON_C_TO_STRING_PRETTY |
+	hdr_s = json_object_to_json_string_ext(jhdr, JSON_C_TO_STRING_PRETTY |
 						JSON_C_TO_STRING_NOSLASHESCAPE);
 
-	str = json_object_to_json_string_ext(expt_cfg, JSON_C_TO_STRING_PRETTY |
+	str_s = json_object_to_json_string_ext(expt_cfg, JSON_C_TO_STRING_PRETTY |
 						JSON_C_TO_STRING_NOSLASHESCAPE);
 
-	if (!hdr || !str)
+	if (!hdr_s || !str_s)
 		goto done;
 
+	hdr = strdup(hdr_s);
+	str = strdup(str_s);
+
 	/*
 	 * Write two strings to the output while stripping closing "}" from the
 	 * header string and opening "{" from the config object.
@@ -2624,6 +2629,10 @@ bool mesh_db_finish_export(bool is_error, void *expt_cfg, const char *fname)
 	result = true;
 
 done:
+	if (hdr != NULL)
+		free(hdr);
+	if (str != NULL)
+		free(str);
 	if (outfile)
 		fclose(outfile);
 
Signature · 1 line
2.54.0
#2 lore raw

PATCH 3/3 mesh: Fix const qualifier dropping when using strchr()

In reply to Bastien Nocera

strchr() with a const string returns a const string, we don't change that string or "next", so make both const and get rid of the warning.

mesh/util.c: In function ‘create_dir’:
mesh/util.c:108:14: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]
108 | prev = strchr(dir_name, '/');
| ^

---
 mesh/util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mesh/util.c +2 -1
index 348401ae5582..a21882a2d9f0 100644
@@ -95,7 +95,8 @@ size_t hex2str(const uint8_t *in, size_t in_len, char *out, size_t out_len)
 int create_dir(const char *dir_name)
 {
 	struct stat st;
-	char dir[PATH_MAX + 1], *prev, *next;
+	const char *prev, *next;
+	char dir[PATH_MAX + 1];
 	int err;
 
 	err = stat(dir_name, &st);
Signature · 1 line
2.54.0
#3 lore raw
In reply to Bastien Nocera

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1092724

---Test result---

Test Summary:

CheckPatch                    FAIL      1.45 seconds
GitLint                       FAIL      1.04 seconds
BuildEll                      PASS      20.50 seconds
BluezMake                     PASS      610.73 seconds
MakeCheck                     PASS      1.04 seconds
MakeDistcheck                 PASS      235.67 seconds
CheckValgrind                 PASS      201.97 seconds
CheckSmatch                   PASS      322.12 seconds
bluezmakeextell               PASS      164.82 seconds
IncrementalBuild              PASS      604.45 seconds
ScanBuild                     PASS      905.83 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ,2/3] mesh: Fix str{r,}chr usage WARNING:LONG_LINE: line length of 82 exceeds 80 columns #95: FILE: tools/mesh/mesh-db.c:2589:
+ str_s = json_object_to_json_string_ext(expt_cfg, JSON_C_TO_STRING_PRETTY |

/github/workspace/src/patch/14565358.patch total: 0 errors, 1 warnings, 41 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
mechanically convert to the typical style using --fix or --fix-inplace.

/github/workspace/src/patch/14565358.patch has style problems, please review.

NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO

NOTE: If any of the errors are false positives, please report
them to the maintainer, see CHECKPATCH in MAINTAINERS.

##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,1/3] mesh: Remove unused but set variable

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
6: B1 Line exceeds max length (98>80): "mesh/net.c:1569:18: error: variable ‘ack_copy’ set but not used [-Werror=unused-but-set-variable=]"
[BlueZ,2/3] mesh: Fix str{r,}chr usage

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
8: B1 Line exceeds max length (130>80): "tools/mesh/mesh-db.c:2598:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]"
11: B1 Line exceeds max length (130>80): "tools/mesh/mesh-db.c:2604:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]"
14: B1 Line exceeds max length (130>80): "tools/mesh/mesh-db.c:2613:13: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]"
[BlueZ,3/3] mesh: Fix const qualifier dropping when using strchr()

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
7: B1 Line exceeds max length (120>80): "mesh/util.c:108:14: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers]"

https://github.com/bluez/bluez/pull/2117

---
Regards,
Linux Bluetooth

#4 lore raw
In reply to Bastien Nocera
This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Hello:

This series was applied to bluetooth/bluez.git (master) by Luiz Augusto von Dentz <[email protected]>:

Quoted 8 lines · On Mon, 11 May 2026 13:35:05 +0200 you wrote:

We played around with the bits, but didn't do anything with it.

mesh/net.c: In function ‘ack_received’:
mesh/net.c:1569:18: error: variable ‘ack_copy’ set but not used [-Werror=unused-but-set-variable=]

 1569 |         uint32_t ack_copy = ack_flag;
      |                  ^~~~~~~~

[...]

Here is the summary with links:
- [BlueZ,1/3] mesh: Remove unused but set variable

    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f95b524e5a1d
  - [BlueZ,2/3] mesh: Fix str{r,}chr usage
    (no matching commit)
  - [BlueZ,3/3] mesh: Fix const qualifier dropping when using strchr()
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=7b2b51ac6f64

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html