Skip to content

Commit e7450d7

Browse files
committed
Fix ff tools error, compatible with -Wstringop-overflow with different gcc versions.
1 parent fc0f76b commit e7450d7

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

tools/libnetgraph/msg.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,14 @@ NgDeliverMsg(int cs, const char *path,
217217
/* Prepare socket address */
218218
sg->sg_family = AF_NETGRAPH;
219219
/* XXX handle overflow */
220+
#if __GNUC__ >= 13
220221
#pragma GCC diagnostic push
221222
#pragma GCC diagnostic ignored "-Wstringop-overflow"
223+
#endif
222224
strncpy(sg->sg_data, path, NG_PATHSIZ);
225+
#if __GNUC__ >= 13
223226
#pragma GCC diagnostic pop
227+
#endif
224228
sg->sg_len = strlen(sg->sg_data) + 1 + NGSA_OVERHEAD;
225229

226230
/* Debugging */

tools/ngctl/write.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,14 @@ WriteCmd(int ac, char **av)
108108
/* Send data */
109109
sag->sg_len = 3 + strlen(hook);
110110
sag->sg_family = AF_NETGRAPH;
111+
#if __GNUC__ >= 13
111112
#pragma GCC diagnostic push
112113
#pragma GCC diagnostic ignored "-Wstringop-overflow"
114+
#endif
113115
strlcpy(sag->sg_data, hook, sizeof(sagbuf) - 2);
116+
#if __GNUC__ >= 13
114117
#pragma GCC diagnostic pop
118+
#endif
115119
if (sendto(dsock, buf, len,
116120
0, (struct sockaddr *)sag, sag->sg_len) == -1) {
117121
warn("writing to hook \"%s\"", hook);

0 commit comments

Comments
 (0)