From 8a66430fa8b0bd2e7bafc870c9aacaa492e1fec1 Mon Sep 17 00:00:00 2001 From: fengbojiang Date: Mon, 14 Oct 2024 19:29:31 +0800 Subject: [PATCH] Fix ff tools error, compatible with -Wstringop-overflow with different gcc versions. --- dpdk/kernel/linux/kni/kni_net.c | 5 +++++ tools/libnetgraph/msg.c | 4 ++++ tools/ngctl/write.c | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/dpdk/kernel/linux/kni/kni_net.c b/dpdk/kernel/linux/kni/kni_net.c index 779ee3451..30eb53221 100644 --- a/dpdk/kernel/linux/kni/kni_net.c +++ b/dpdk/kernel/linux/kni/kni_net.c @@ -832,8 +832,13 @@ static const struct net_device_ops kni_net_netdev_ops = { static void kni_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) { +#if __GNUC__ >= 13 + strscpy(info->version, KNI_VERSION, sizeof(info->version)); + strscpy(info->driver, "kni", sizeof(info->driver)); +#else strlcpy(info->version, KNI_VERSION, sizeof(info->version)); strlcpy(info->driver, "kni", sizeof(info->driver)); +#endif } static const struct ethtool_ops kni_net_ethtool_ops = { diff --git a/tools/libnetgraph/msg.c b/tools/libnetgraph/msg.c index 62d14c8f2..d8c3faf80 100644 --- a/tools/libnetgraph/msg.c +++ b/tools/libnetgraph/msg.c @@ -233,10 +233,14 @@ NgDeliverMsg(int cs, const char *path, /* Prepare socket address */ sg->sg_family = AF_NETGRAPH; /* XXX handle overflow */ +#if __GNUC__ >= 13 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif strncpy(sg->sg_data, path, NG_PATHSIZ); +#if __GNUC__ >= 13 #pragma GCC diagnostic pop +#endif sg->sg_len = strlen(sg->sg_data) + 1 + NGSA_OVERHEAD; /* Debugging */ diff --git a/tools/ngctl/write.c b/tools/ngctl/write.c index 9c6b3fa5a..25cc99a2e 100644 --- a/tools/ngctl/write.c +++ b/tools/ngctl/write.c @@ -108,10 +108,14 @@ WriteCmd(int ac, char **av) /* Send data */ sag->sg_len = 3 + strlen(hook); sag->sg_family = AF_NETGRAPH; +#if __GNUC__ >= 13 #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif strlcpy(sag->sg_data, hook, sizeof(sagbuf) - 2); +#if __GNUC__ >= 13 #pragma GCC diagnostic pop +#endif if (sendto(dsock, buf, len, 0, (struct sockaddr *)sag, sag->sg_len) == -1) { warn("writing to hook \"%s\"", hook);