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

This commit is contained in:
fengbojiang 2024-10-14 15:12:38 +08:00
parent fc0f76b7b5
commit e7450d75e9
2 changed files with 8 additions and 0 deletions

View File

@ -217,10 +217,14 @@ NgDeliverMsg(int cs, const char *path,
/* Prepare socket address */ /* Prepare socket address */
sg->sg_family = AF_NETGRAPH; sg->sg_family = AF_NETGRAPH;
/* XXX handle overflow */ /* XXX handle overflow */
#if __GNUC__ >= 13
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow" #pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
strncpy(sg->sg_data, path, NG_PATHSIZ); strncpy(sg->sg_data, path, NG_PATHSIZ);
#if __GNUC__ >= 13
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
sg->sg_len = strlen(sg->sg_data) + 1 + NGSA_OVERHEAD; sg->sg_len = strlen(sg->sg_data) + 1 + NGSA_OVERHEAD;
/* Debugging */ /* Debugging */

View File

@ -108,10 +108,14 @@ WriteCmd(int ac, char **av)
/* Send data */ /* Send data */
sag->sg_len = 3 + strlen(hook); sag->sg_len = 3 + strlen(hook);
sag->sg_family = AF_NETGRAPH; sag->sg_family = AF_NETGRAPH;
#if __GNUC__ >= 13
#pragma GCC diagnostic push #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-overflow" #pragma GCC diagnostic ignored "-Wstringop-overflow"
#endif
strlcpy(sag->sg_data, hook, sizeof(sagbuf) - 2); strlcpy(sag->sg_data, hook, sizeof(sagbuf) - 2);
#if __GNUC__ >= 13
#pragma GCC diagnostic pop #pragma GCC diagnostic pop
#endif
if (sendto(dsock, buf, len, if (sendto(dsock, buf, len,
0, (struct sockaddr *)sag, sag->sg_len) == -1) { 0, (struct sockaddr *)sag, sag->sg_len) == -1) {
warn("writing to hook \"%s\"", hook); warn("writing to hook \"%s\"", hook);