Fix ff tools error, compatible with -Wstringop-overflow with different gcc versions.

This commit is contained in:
fengbojiang 2024-10-14 19:29:31 +08:00
parent 50188e997c
commit 8a66430fa8
3 changed files with 13 additions and 0 deletions

View File

@ -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 = {

View File

@ -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 */

View File

@ -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);