* Kim Barrett: > And strlen is not even necessarily the best solution, as it likely > introduces an additional otherwise unnecessary string traversal. For > example, getFlags could be changed to reject an overly long ifname, > without using strlen, thusly: > > strncpy(if2.ifr_name, ifname, sizeof(if2.ifr_name)); > if (if2.ifr_name[sizeof(if2.ifr_name) - 1] != '\0') { > return -1; > } > > Unfortunately, gcc10 -Wstringop-truncation whines about this entirely > reasonable code.
Thanks, I filed this as: <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96951> Florian -- Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn, Commercial register: Amtsgericht Muenchen, HRB 153243, Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill