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.

Link: https://github.com/KSPP/linux/issues/370 [1]
Signed-off-by: Ian Bridges <[email protected]>
---
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(-)

diff --git a/drivers/media/dvb-frontends/si2165.c 
b/drivers/media/dvb-frontends/si2165.c
index f1241b63aa5c..ebb4083b99a8 100644
--- a/drivers/media/dvb-frontends/si2165.c
+++ b/drivers/media/dvb-frontends/si2165.c
@@ -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;
-- 
2.47.3


Reply via email to