s390/qeth: Use constant for IP address buffers
authorThorsten Winkler <twinkler@linux.ibm.com>
Thu, 9 Feb 2023 11:04:22 +0000 (12:04 +0100)
committerJakub Kicinski <kuba@kernel.org>
Sat, 11 Feb 2023 03:49:53 +0000 (19:49 -0800)
Use INET6_ADDRSTRLEN constant with size of 48 which be used for char arrays
storing ip addresses (for IPv4 and IPv6)

Reviewed-by: Alexandra Winter <wintera@linux.ibm.com>
Signed-off-by: Thorsten Winkler <twinkler@linux.ibm.com>
Signed-off-by: Alexandra Winter <wintera@linux.ibm.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/s390/net/qeth_l3_main.c
drivers/s390/net/qeth_l3_sys.c

index d8487a10cd5557fca98fe2859bba23696159212e..1cf4e354693f07a2f3163d77e1ffdc35a70166f8 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/etherdevice.h>
 #include <linux/ip.h>
 #include <linux/in.h>
+#include <linux/inet.h>
 #include <linux/ipv6.h>
 #include <linux/inetdevice.h>
 #include <linux/igmp.h>
@@ -158,7 +159,7 @@ static int qeth_l3_add_ip(struct qeth_card *card, struct qeth_ipaddr *tmp_addr)
 {
        int rc = 0;
        struct qeth_ipaddr *addr;
-       char buf[40];
+       char buf[INET6_ADDRSTRLEN];
 
        if (tmp_addr->type == QETH_IP_TYPE_RXIP)
                QETH_CARD_TEXT(card, 2, "addrxip");
index 1082380b21f852258371798d4ef93da4e5976c4d..6143dd485810c97f123d2610517ecbc198153ed2 100644 (file)
@@ -371,7 +371,7 @@ static ssize_t qeth_l3_dev_ipato_add_show(char *buf, struct qeth_card *card,
 
        mutex_lock(&card->ip_lock);
        list_for_each_entry(ipatoe, &card->ipato.entries, entry) {
-               char addr_str[40];
+               char addr_str[INET6_ADDRSTRLEN];
                int entry_len;
 
                if (ipatoe->proto != proto)
@@ -413,7 +413,7 @@ static int qeth_l3_parse_ipatoe(const char *buf, enum qeth_prot_versions proto,
        int rc;
 
        /* Expected input pattern: %addr/%mask */
-       sep = strnchr(buf, 40, '/');
+       sep = strnchr(buf, INET6_ADDRSTRLEN, '/');
        if (!sep)
                return -EINVAL;
 
@@ -592,7 +592,7 @@ static ssize_t qeth_l3_dev_ip_add_show(struct device *dev, char *buf,
 
        mutex_lock(&card->ip_lock);
        hash_for_each(card->ip_htable, i, ipaddr, hnode) {
-               char addr_str[40];
+               char addr_str[INET6_ADDRSTRLEN];
                int entry_len;
 
                if (ipaddr->proto != proto || ipaddr->type != type)