Skip to contentSkip to conversation

media: si2165: Replace strlcat() with snprintf()

PATCH New Ian Bridges 1 participant 1 message Jul 2

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: si2165: Replace strlcat() with snprintf()

In preparation for removing the strlcat() API[1], replace its uses in si2165_probe(). The chip name and the supported delivery systems are already known when the frontend name is built, so the whole name can be produced by a single snprintf(), seeded from the same si2165_ops template default that the strlcat() calls appended to.

---
I don't have si2165 hardware, so I tested the patch with:
- x86_64 build at W=1 with no warnings. Applies cleanly on the media tree next branch.
- Module load/unload in an x86_64 QEMU guest.
- A userspace comparison of the old and new name construction for both chip types; outputs are identical.

 drivers/media/dvb-frontends/si2165.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
drivers/media/dvb-frontends/si2165.c +6 -10
index f1241b63aa5c..ebb4083b99a8 100644
@@ -1243,20 +1243,16 @@ static int si2165_probe(struct i2c_client *client)
 		chip_name, rev_char, state->chip_type,
 		state->chip_revcode);
 
-	strlcat(state->fe.ops.info.name, chip_name,
-		sizeof(state->fe.ops.info.name));
+	snprintf(state->fe.ops.info.name, sizeof(state->fe.ops.info.name),
+		 "%s%s%s%s", si2165_ops.info.name, chip_name,
+		 state->has_dvbt ? " DVB-T" : "",
+		 state->has_dvbc ? " DVB-C" : "");
 
 	n = 0;
-	if (state->has_dvbt) {
+	if (state->has_dvbt)
 		state->fe.ops.delsys[n++] = SYS_DVBT;
-		strlcat(state->fe.ops.info.name, " DVB-T",
-			sizeof(state->fe.ops.info.name));
-	}
-	if (state->has_dvbc) {
+	if (state->has_dvbc)
 		state->fe.ops.delsys[n++] = SYS_DVBC_ANNEX_A;
-		strlcat(state->fe.ops.info.name, " DVB-C",
-			sizeof(state->fe.ops.info.name));
-	}
 
 	/* return fe pointer */
 	*pdata->fe = &state->fe;
Signature · 1 line
2.47.3