diff options
author | Ron Economos <w6rz@comcast.net> | 2021-09-07 18:59:25 -0700 |
---|---|---|
committer | Martin Braun <martin@gnuradio.org> | 2021-09-12 12:51:16 -0700 |
commit | a77d496cbb57f70248ce707ed7a30ac328c84674 (patch) | |
tree | 140150a9ee0576fe98b429a053ffc2c64f95c320 | |
parent | 9b096690ee2d4d13fa645f7c7e25775b04e41d04 (diff) |
gr-network: Fixup tuntap suppress warning on Debian 11.
Signed-off-by: Ron Economos <w6rz@comcast.net>
-rw-r--r-- | gr-network/lib/tuntap_pdu_impl.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/gr-network/lib/tuntap_pdu_impl.cc b/gr-network/lib/tuntap_pdu_impl.cc index ab80e03b65..d98685276c 100644 --- a/gr-network/lib/tuntap_pdu_impl.cc +++ b/gr-network/lib/tuntap_pdu_impl.cc @@ -53,23 +53,14 @@ tuntap_pdu_impl::tuntap_pdu_impl(std::string dev, int MTU, bool istunflag) strncpy(dev_cstr, dev.c_str(), IFNAMSIZ); dev_cstr[IFNAMSIZ - 1] = '\0'; - bool istun = d_istunflag; - -#if defined(__GNUG__) && !defined(__clang__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wstringop-truncation" -#endif + bool istun = d_istunflag; if (istun) { d_fd = tun_alloc(dev_cstr, (IFF_TUN | IFF_NO_PI)); } else { d_fd = tun_alloc(dev_cstr, (IFF_TAP | IFF_NO_PI)); } -#if defined(__GNUG__) && !defined(__clang__) -#pragma GCC diagnostic pop -#endif - if (d_fd <= 0) throw std::runtime_error( "gr::tuntap_pdu::make: tun_alloc failed (are you running as root?)"); @@ -127,10 +118,21 @@ int tuntap_pdu_impl::tun_alloc(char* dev, int flags) * the kernel will try to allocate the "next" device of the * specified type */ + +#if defined(__GNUG__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif + if (*dev) { // copy at most IFNAMSIZ - 1: If everything went well, the last byte is 0 anyway strncpy(ifr.ifr_name, dev, IFNAMSIZ - 1); } + +#if defined(__GNUG__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif + /* try to create the device */ if ((err = ioctl(fd, TUNSETIFF, (void*)&ifr)) < 0) { close(fd); |