]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
improve the conditional declaration and use of variable to silence cppcheck
authorMark Andrews <marka@isc.org>
Tue, 20 Feb 2018 02:08:08 +0000 (13:08 +1100)
committerMark Andrews <marka@isc.org>
Sun, 25 Feb 2018 23:40:11 +0000 (10:40 +1100)
(cherry picked from commit a04bb76973e5d30d0ec7cc268eaa8db2a91934e6)

lib/isc/netscope.c
lib/isc/unix/entropy.c
lib/isc/unix/socket.c

index aa7fc07051391a3df61d817e4da39cb777711150..95f9e3db02115d3af56749f4e49f5e09bc62c080 100644 (file)
@@ -8,11 +8,6 @@
 
 /*! \file */
 
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] =
-       "$Id: netscope.c,v 1.13 2007/06/19 23:47:17 tbox Exp $";
-#endif /* LIBC_SCCS and not lint */
-
 #include <config.h>
 
 #include <isc/string.h>
@@ -25,8 +20,8 @@ isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid) {
        char *ep;
 #ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
        unsigned int ifid;
-#endif
        struct in6_addr *in6;
+#endif
        isc_uint32_t zone;
        isc_uint64_t llz;
 
@@ -34,8 +29,6 @@ isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid) {
        if (af != AF_INET6)
                return (ISC_R_FAILURE);
 
-       in6 = (struct in6_addr *)addr;
-
        /*
         * Basically, "names" are more stable than numeric IDs in terms of
         * renumbering, and are more preferred.  However, since there is no
@@ -45,6 +38,7 @@ isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid) {
         * interfaces and links.
         */
 #ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
+       in6 = (struct in6_addr *)addr;
        if (IN6_IS_ADDR_LINKLOCAL(in6) &&
            (ifid = if_nametoindex((const char *)scopename)) != 0)
                zone = (isc_uint32_t)ifid;
index 5942031577e36f2e851f7da608df4e05d6f41036..53f7d8f3a2d23bdb7c0d66d6f9dcb89a8871edde 100644 (file)
@@ -6,8 +6,6 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-/* $Id: entropy.c,v 1.82 2008/12/01 23:47:45 tbox Exp $ */
-
 /* \file unix/entropy.c
  * \brief
  * This is the system dependent part of the ISC entropy API.
@@ -449,11 +447,14 @@ destroyusocketsource(isc_entropyusocketsource_t *source) {
 static isc_result_t
 make_nonblock(int fd) {
        int ret;
-       int flags;
        char strbuf[ISC_STRERRORSIZE];
 #ifdef USE_FIONBIO_IOCTL
        int on = 1;
+#else
+       int flags;
+#endif
 
+#ifdef USE_FIONBIO_IOCTL
        ret = ioctl(fd, FIONBIO, (char *)&on);
 #else
        flags = fcntl(fd, F_GETFL, 0);
index a5187511be3334134608f41b83f8372bed87ce34..8a3ab0a7bde4c253315f738c1b224f77f407eeb7 100644 (file)
@@ -1223,11 +1223,14 @@ select_poke(isc__socketmgr_t *manager, int fd, int msg) {
 static isc_result_t
 make_nonblock(int fd) {
        int ret;
-       int flags;
        char strbuf[ISC_STRERRORSIZE];
 #ifdef USE_FIONBIO_IOCTL
        int on = 1;
+#else
+       int flags;
+#endif
 
+#ifdef USE_FIONBIO_IOCTL
        ret = ioctl(fd, FIONBIO, (char *)&on);
 #else
        flags = fcntl(fd, F_GETFL, 0);
@@ -1309,6 +1312,7 @@ cmsg_space(ISC_SOCKADDR_LEN_T len) {
  */
 static void
 process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
+#ifdef ISC_NET_BSD44MSGHDR
 #ifdef USE_CMSG
        struct cmsghdr *cmsgp;
 #ifdef ISC_PLATFORM_HAVEIN6PKTINFO
@@ -1317,6 +1321,7 @@ process_cmsg(isc__socket_t *sock, struct msghdr *msg, isc_socketevent_t *dev) {
 #ifdef SO_TIMESTAMP
        void *timevalp;
 #endif
+#endif
 #endif
 
        /*
@@ -1567,6 +1572,7 @@ build_msghdr_send(isc__socket_t *sock, isc_socketevent_t *dev,
                        INSIST((int)sock->dscp == isc_dscp_check_value);
        }
 
+#if defined(IP_TOS) || (defined(IPPROTO_IPV6) && defined(IPV6_TCLASS))
        if ((sock->type == isc_sockettype_udp) &&
            ((dev->attributes & ISC_SOCKEVENTATTR_DSCP) != 0))
        {
@@ -1636,6 +1642,7 @@ build_msghdr_send(isc__socket_t *sock, isc_socketevent_t *dev,
                }
 #endif
        }
+#endif
 #endif /* USE_CMSG */
 #else /* ISC_NET_BSD44MSGHDR */
        msg->msg_accrights = NULL;