]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/iucv: Convert sprintf/snprintf to scnprintf
authorAswin Karuvally <aswin@linux.ibm.com>
Fri, 17 Oct 2025 09:49:54 +0000 (11:49 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 21 Oct 2025 01:35:21 +0000 (18:35 -0700)
Convert sprintf/snprintf calls to scnprintf to better align with the
kernel development community practices [1].

Link: https://lwn.net/Articles/69419
Reviewed-by: Alexandra Winter <wintera@linux.ibm.com>
Signed-off-by: Aswin Karuvally <aswin@linux.ibm.com>
Signed-off-by: Alexandra Winter <wintera@linux.ibm.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20251017094954.1402684-1-wintera@linux.ibm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/s390/net/smsgiucv_app.c
net/iucv/af_iucv.c
net/iucv/iucv.c

index 4bd4d6bfc1262e84f6d1023ae080a34f08685953..768108c90b325ead210d3c0f3df3eda2fffa5642 100644 (file)
@@ -88,9 +88,10 @@ static struct smsg_app_event *smsg_app_event_alloc(const char *from,
        ev->envp[3] = NULL;
 
        /* setting up environment: sender, prefix name, and message text */
-       snprintf(ev->envp[0], ENV_SENDER_LEN, ENV_SENDER_STR "%s", from);
-       snprintf(ev->envp[1], ENV_PREFIX_LEN, ENV_PREFIX_STR "%s", SMSG_PREFIX);
-       snprintf(ev->envp[2], ENV_TEXT_LEN(msg), ENV_TEXT_STR "%s", msg);
+       scnprintf(ev->envp[0], ENV_SENDER_LEN, ENV_SENDER_STR "%s", from);
+       scnprintf(ev->envp[1], ENV_PREFIX_LEN, ENV_PREFIX_STR "%s",
+                 SMSG_PREFIX);
+       scnprintf(ev->envp[2], ENV_TEXT_LEN(msg), ENV_TEXT_STR "%s", msg);
 
        return ev;
 }
index 6c717a7ef292831b49c1dca22ecc2bb7a7179b0f..4ddfc633d30cf483b921fc44551730362118c2f9 100644 (file)
@@ -553,10 +553,11 @@ static void __iucv_auto_name(struct iucv_sock *iucv)
 {
        char name[12];
 
-       sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
+       scnprintf(name, sizeof(name),
+                 "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
        while (__iucv_get_sock_by_name(name)) {
-               sprintf(name, "%08x",
-                       atomic_inc_return(&iucv_sk_list.autobind_name));
+               scnprintf(name, sizeof(name), "%08x",
+                         atomic_inc_return(&iucv_sk_list.autobind_name));
        }
        memcpy(iucv->src_name, name, 8);
 }
index 473a7847d80bba36d838cfd99f82e707db46f149..008be0abe3a57861b36ee464bf396ba6619b87fa 100644 (file)
@@ -95,7 +95,7 @@ struct device *iucv_alloc_device(const struct attribute_group **attrs,
        if (!dev)
                goto out_error;
        va_start(vargs, fmt);
-       vsnprintf(buf, sizeof(buf), fmt, vargs);
+       vscnprintf(buf, sizeof(buf), fmt, vargs);
        rc = dev_set_name(dev, "%s", buf);
        va_end(vargs);
        if (rc)