From: Waldemar Kozaczuk <jwkozac...@gmail.com> Committer: Waldemar Kozaczuk <jwkozac...@gmail.com> Branch: master
musl: stop older gcc produce warnings caused by usage of strncpy When bulding OSv on Travis which uses gcc 7.5.0 we get an compilation warning like so: musl/src/network/if_nametoindex.c:14:2: error: 'strncpy' specified bound 16 equals destination size [-Werror=stringop-truncation] 14 | strncpy(ifr.ifr_name, name, sizeof ifr.ifr_name); There is a similar one caused by the usage of strncpy in if_indextoname.c. At some point I sent an email to musl about changing strncpy to strlcpy and you can see Rich Felker's response here: https://inbox.vuxu.org/musl/20200817235454.gc3...@brightrain.aerifal.cx/T/#t There is also an interesting article about strlcpy() here - https://lwn.net/Articles/507319/. It is also interesting that newer gcc (> 11.0.0 but possible older as well) does not raise this warning about strncpy which might mean it is sometimes treated as false positive (see this gcc issue https://gcc.gnu.org/legacy-ml/gcc-patches/2018-08/msg01549.html). One way to fix this problem would be to change strncpy to strlcpy in those two musl source files which would mean to bring those as copies. I chose to turn off this warning for these 2 sources instead. Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com> --- diff --git a/Makefile b/Makefile --- a/Makefile +++ b/Makefile @@ -1496,9 +1496,9 @@ musl += network/inet_pton.o musl += network/inet_ntop.o musl += network/proto.o musl += network/if_indextoname.o -$(out)/musl/src/network/if_indextoname.o: CFLAGS += --include libc/syscall_to_function.h --include libc/network/__socket.h +$(out)/musl/src/network/if_indextoname.o: CFLAGS += --include libc/syscall_to_function.h --include libc/network/__socket.h -Wno-stringop-truncation musl += network/if_nametoindex.o -$(out)/musl/src/network/if_nametoindex.o: CFLAGS += --include libc/syscall_to_function.h --include libc/network/__socket.h +$(out)/musl/src/network/if_nametoindex.o: CFLAGS += --include libc/syscall_to_function.h --include libc/network/__socket.h -Wno-stringop-truncation musl += network/gai_strerror.o musl += network/h_errno.o musl += network/getservbyname_r.o -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/osv-dev/000000000000cbaf7b05e158c96c%40google.com.