]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Clean up some compiler warnings
authorShawn Routhier <sar@isc.org>
Tue, 2 Feb 2010 00:44:06 +0000 (00:44 +0000)
committerShawn Routhier <sar@isc.org>
Tue, 2 Feb 2010 00:44:06 +0000 (00:44 +0000)
common/options.c
configure.ac
includes/dhcp6.h
omapip/hash.c
relay/dhcrelay.c
server/dhcp.c
server/dhcpv6.c
server/mdb6.c
server/omapi.c

index bc3282fd06f612619e1e62c230b35a0a70e5e9fb..52003ab6f070da4fe9cee4a7a2308998c5fc635c 100644 (file)
@@ -3782,13 +3782,13 @@ packet6_len_okay(const char *packet, int len) {
        }
        if ((packet[0] == DHCPV6_RELAY_FORW) || 
            (packet[0] == DHCPV6_RELAY_REPL)) {
-               if (len >= sizeof(struct dhcpv6_relay_packet)) {
+               if (len >= offsetof(struct dhcpv6_relay_packet, options)) {
                        return 1;
                } else {
                        return 0;
                }
        } else {
-               if (len >= sizeof(struct dhcpv6_packet)) {
+               if (len >= offsetof(struct dhcpv6_packet, options)) {
                        return 1;
                } else {
                        return 0;
index 2af548c4152db1f2c275582143dd40e07ad2cfab..707137f45578f4712b1857d4d9434a49797ded82 100644 (file)
@@ -508,6 +508,8 @@ CFLAGS="$CFLAGS $STD_CWARNINGS"
 # Try to add the bind include directory
 CFLAGS="$CFLAGS -I$libbind/include"
 
+AC_C_FLEXIBLE_ARRAY_MEMBER
+
 AC_OUTPUT([
   Makefile
   client/Makefile
index 36c1535b02480c7cb5b22724ca13c37945541728..03db160e93fac440d84be235168753cbed3dd7a1 100644 (file)
@@ -177,7 +177,7 @@ extern const int dhcpv6_type_name_max;
 struct dhcpv6_packet {
        unsigned char msg_type;
        unsigned char transaction_id[3];
-       unsigned char options[0];
+       unsigned char options[FLEXIBLE_ARRAY_MEMBER];
 };
 
 /* Offset into DHCPV6 Reply packets where Options spaces commence. */
@@ -191,7 +191,7 @@ struct dhcpv6_relay_packet {
        unsigned char hop_count;
        unsigned char link_address[16];
        unsigned char peer_address[16];
-       unsigned char options[0];
+       unsigned char options[FLEXIBLE_ARRAY_MEMBER];
 };
 
 /* Leasequery query-types (RFC 5007) */
index bace3cd4d35f2537ab019777755242b3c6f6d5b7..e33f803e0a62133afca4416676ecb48a913c6633 100644 (file)
@@ -297,23 +297,27 @@ do_id_hash(const void *name, unsigned len, unsigned size)
        if (len == 0)
                return 0;
 
-       /* The switch indexes our starting position into the do/while loop,
-        * taking up the remainder after hashing in all the other bytes in
-        * threes.
+       /*
+        * The switch handles our starting conditions, then we hash the
+        * remaining bytes in groups of 3
         */
+          
        switch (len % 3) {
-               do {
-             case 0:
-                       accum ^= *s++ << 16;
-             case 2:
-                       accum ^= *s++ << 8;
-             case 1:
-                       accum ^= *s++;
-               } while (s < end);
-
+       case 0:
+               break;
+       case 2:
+               accum ^= *s++ << 8;
+       case 1:
+               accum ^= *s++;
                break;
        }
 
+       while (s < end) {
+               accum ^= *s++ << 16;
+               accum ^= *s++ << 8;
+               accum ^= *s++;
+       }
+
        return accum % size;
 }
 
index 0bed393c556eb70dcbd97fdfeb88e72057cfaae5..53651b640ad555a4d963bc98e73c13c75946de64 100644 (file)
@@ -1355,7 +1355,7 @@ process_up6(struct packet *packet, struct stream_list *dp) {
 
        /* Build the relay-forward header. */
        relay = (struct dhcpv6_relay_packet *) forw_data;
-       cursor = sizeof(*relay);
+       cursor = offsetof(struct dhcpv6_relay_packet, options);
        relay->msg_type = DHCPV6_RELAY_FORW;
        if (packet->dhcpv6_msg_type == DHCPV6_RELAY_FORW) {
                if (packet->dhcpv6_hop_count >= max_hop_count) {
@@ -1483,7 +1483,7 @@ process_down6(struct packet *packet) {
        if (!evaluate_option_cache(&relay_msg, packet, NULL, NULL,
                                   packet->options, NULL,
                                   &global_scope, oc, MDL) ||
-           (relay_msg.len < sizeof(struct dhcpv6_packet))) {
+           (relay_msg.len < offsetof (struct dhcpv6_packet, options))) {
                log_error("Can't evaluate relay-msg.");
                return;
        }
index f49cee38f6cd095ca267ccf4d131ca2fa13e4848..3601bd1ac9bba615a31d10bcbc47f5cdd314480d 100644 (file)
@@ -3423,7 +3423,6 @@ int find_lease (struct lease **lp,
                                  piaddr (hw_lease -> ip_addr));
 #endif
                        goto n_hw;
-                       continue;
                }
                if (hw_lease -> subnet -> shared_network != share) {
 #if defined (DEBUG_FIND_LEASE)
@@ -3431,7 +3430,6 @@ int find_lease (struct lease **lp,
                                  piaddr (hw_lease -> ip_addr));
 #endif
                        goto n_hw;
-                       continue;
                }
                if ((hw_lease -> pool -> prohibit_list &&
                      permitted (packet, hw_lease -> pool -> prohibit_list)) ||
index 6ad7681e9c8ef1e08a1268b29019d43002be7112..5cd7c4bc111bab4dd9ff5d965b6369aef89dc645 100644 (file)
@@ -4226,7 +4226,7 @@ dhcpv6_confirm(struct data_string *reply_ret, struct packet *packet) {
        isc_boolean_t inappropriate, has_addrs;
        char reply_data[65536];
        struct dhcpv6_packet *reply = (struct dhcpv6_packet *)reply_data;
-       int reply_ofs = (int)((char *)reply->options - (char *)reply);
+       int reply_ofs = (int)(offsetof(struct dhcpv6_packet, options));
 
        /* 
         * Basic client message validation.
@@ -4583,7 +4583,7 @@ iterate_over_ia_na(struct data_string *reply_ret,
        int iaaddr_is_found;
        char reply_data[65536];
        struct dhcpv6_packet *reply = (struct dhcpv6_packet *)reply_data;
-       int reply_ofs = (int)((char *)reply->options - (char *)reply);
+       int reply_ofs = (int)(offsetof(struct dhcpv6_packet, options));
        char status_msg[32];
        struct iasubopt *lease;
        struct ia_xx *existing_ia_na;
@@ -5555,7 +5555,7 @@ dhcpv6_relay_forw(struct data_string *reply_ret, struct packet *packet) {
               sizeof(reply->link_address));
        memcpy(reply->peer_address, &packet->dhcpv6_peer_address,
               sizeof(reply->peer_address));
-       reply_ofs = (int)((char *)reply->options - (char *)reply);
+       reply_ofs = (int)(offsetof(struct dhcpv6_relay_packet, options));
 
        /*
         * Get the reply option state.
index 31a8dfcc44f5339cca50091559d51b6098fbf43f..bbd671f4704f79956bd8640650112899de1fb5ee 100644 (file)
 #include <isc/md5.h>
 
 HASH_FUNCTIONS(ia, unsigned char *, struct ia_xx, ia_hash_t,
-              ia_reference, ia_dereference, do_string_hash);
+              ia_reference, ia_dereference, do_string_hash)
 
 ia_hash_t *ia_na_active;
 ia_hash_t *ia_ta_active;
 ia_hash_t *ia_pd_active;
 
 HASH_FUNCTIONS(iasubopt, struct in6_addr *, struct iasubopt, iasubopt_hash_t,
-              iasubopt_reference, iasubopt_dereference, do_string_hash);
+              iasubopt_reference, iasubopt_dereference, do_string_hash)
 
 struct ipv6_pool **pools;
 int num_pools;
index c9dbb254fd4302d430bb6221633165382bb6e6f5..262943524960b7e9f7079b51c3fe9ff0331b5a0f 100644 (file)
@@ -1891,7 +1891,12 @@ class_set_value (omapi_object_t *h,
                } else
                        return DHCP_R_INVALIDARG;
 
-               return ISC_R_SUCCESS;
+               /* 
+                * Currently no way to get here, if we update the above
+                * code so that we do get here this return needs to be
+                * uncommented.
+                * return ISC_R_SUCCESS;
+                */
        }