]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
remove redudant #ifdef; address imprecise #ifdef usage
authorMark Andrews <marka@isc.org>
Wed, 2 Oct 2013 01:59:39 +0000 (11:59 +1000)
committerMark Andrews <marka@isc.org>
Wed, 2 Oct 2013 01:59:39 +0000 (11:59 +1000)
lib/isc/unix/net.c

index 187a64bd0645c373f41292dba1e9613338c785ea..f64ea6d328d49f8efd7f6a6f486cce3acd3ceaaa 100644 (file)
@@ -530,22 +530,34 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) {
        cmsgp->cmsg_level = level;
        cmsgp->cmsg_type = type;
 
+       switch (cmsgp->cmsg_type) {
 #ifdef IP_TOS
-       if (cmsgp->cmsg_type == IP_TOS) {
+       case IP_TOS:
                cmsgp->cmsg_len = cmsg_len(sizeof(char));
                *(unsigned char*)CMSG_DATA(cmsgp) = dscp;
-       } else {
+               break;
+#endif
+#ifdef IPV6_TCLASS
+       case IPV6_TCLASS:
                cmsgp->cmsg_len = cmsg_len(sizeof(dscp));
                memcpy(CMSG_DATA(cmsgp), &dscp, sizeof(dscp));
+               break;
+#endif
+       default:
+               INSIST(0);
        }
-#endif /* IP_TOS */
 
        if (sendmsg(s, &msg, 0) < 0) {
                int debug = ISC_LOG_DEBUG(10);
+               switch (errno) {
 #ifdef ENOPROTOOPT
-               if (errno != ENOPROTOOPT && errno != EINVAL)
-                       debug = ISC_LOG_NOTICE;
+               case ENOPROTOOPT:
 #endif
+               case EINVAL:
+                       break;
+               default:
+                       debug = ISC_LOG_NOTICE;
+               }
                isc__strerror(errno, strbuf, sizeof(strbuf));
                if (debug != ISC_LOG_NOTICE) {
                        isc_log_write(isc_lctx, ISC_LOGCATEGORY_GENERAL,
@@ -623,10 +635,8 @@ try_dscp_v4(void) {
                return;
        }
 
-#ifdef IP_TOS
        if (setsockopt(s, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) == 0)
                dscp_result |= ISC_NET_DSCPSETV4;
-#endif /* IP_TOS */
 
 #ifdef IP_RECVTOS
        on = 1;