]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
clang: use ETHER_ADDR_LEN instead of sizeof()
authorVincent Bernat <bernat@luffy.cx>
Sat, 23 Nov 2013 09:16:38 +0000 (10:16 +0100)
committerVincent Bernat <bernat@luffy.cx>
Sat, 23 Nov 2013 09:16:38 +0000 (10:16 +0100)
This allows clang to not choke on inappropriate types.

src/daemon/cdp.c
src/daemon/edp.c
src/daemon/interfaces.c
src/daemon/lldp.c
src/daemon/sonmp.c

index bf5921d90c0715979012a47cbe374591c81b70db..3ddbdffb687b002eb8814e820fad5575b3ca56f1 100644 (file)
@@ -67,7 +67,7 @@ cdp_send(struct lldpd *global,
        /* Ethernet header */
        if (!(
              POKE_BYTES(mcastaddr, sizeof(mcastaddr)) &&
-             POKE_BYTES(&hardware->h_lladdr, sizeof(hardware->h_lladdr)) &&
+             POKE_BYTES(&hardware->h_lladdr, ETHER_ADDR_LEN) &&
              POKE_SAVE(pos_len_eh) && /* We compute the len later */
              POKE_UINT16(0)))
                goto toobig;
index 4a9cfbdc6662e089bf55369f9288b08affe315a0..106d9f6387bc5ae84e722666f39dc487cfed924f 100644 (file)
@@ -64,7 +64,7 @@ edp_send(struct lldpd *global,
                /* Ethernet header */
                if (!(
                      POKE_BYTES(mcastaddr, sizeof(mcastaddr)) &&
-                     POKE_BYTES(&hardware->h_lladdr, sizeof(hardware->h_lladdr)) &&
+                     POKE_BYTES(&hardware->h_lladdr, ETHER_ADDR_LEN) &&
                      POKE_SAVE(pos_len_eh) && /* We compute the len later */
                      POKE_UINT16(0)))
                        goto toobig;
index 2af06331c3cb2407920dcda7d4ae4b68311f698c..1a39e18d9536a829d2b74bcfccaf7c1dd7c4fac9 100644 (file)
@@ -344,15 +344,15 @@ interfaces_helper_chassis(struct lldpd *cfg,
                        /* That's odd. Let's skip. */
                        continue;
 
-               name = malloc(sizeof(hardware->h_lladdr));
+               name = malloc(ETHER_ADDR_LEN);
                if (!name) {
                        log_warn("interfaces", "not enough memory for chassis ID");
                        return;
                }
                free(LOCAL_CHASSIS(cfg)->c_id);
-               memcpy(name, hardware->h_lladdr, sizeof(hardware->h_lladdr));
+               memcpy(name, hardware->h_lladdr, ETHER_ADDR_LEN);
                LOCAL_CHASSIS(cfg)->c_id = name;
-               LOCAL_CHASSIS(cfg)->c_id_len = sizeof(hardware->h_lladdr);
+               LOCAL_CHASSIS(cfg)->c_id_len = ETHER_ADDR_LEN;
                LOCAL_CHASSIS(cfg)->c_id_subtype = LLDP_CHASSISID_SUBTYPE_LLADDR;
                return;
        }
@@ -476,11 +476,10 @@ interfaces_helper_port_name_desc(struct lldpd_hardware *hardware,
                    hardware->h_ifname);
                port->p_id_subtype = LLDP_PORTID_SUBTYPE_LLADDR;
                if ((port->p_id =
-                       calloc(1, sizeof(hardware->h_lladdr))) == NULL)
+                       calloc(1, ETHER_ADDR_LEN)) == NULL)
                        fatal("interfaces", NULL);
-               memcpy(port->p_id, hardware->h_lladdr,
-                   sizeof(hardware->h_lladdr));
-               port->p_id_len = sizeof(hardware->h_lladdr);
+               memcpy(port->p_id, hardware->h_lladdr, ETHER_ADDR_LEN);
+               port->p_id_len = ETHER_ADDR_LEN;
                port->p_descr = strdup(hardware->h_ifname);
                return;
        }
index 658430902f2b237925d32a5cf7e1f66c75a8bdf4..38403aa9b94cd49041a17953adb6e157a1933d94 100644 (file)
@@ -94,7 +94,7 @@ lldp_send(struct lldpd *global,
              /* LLDP multicast address */
              POKE_BYTES(mcastaddr, sizeof(mcastaddr)) &&
              /* Source MAC address */
-             POKE_BYTES(&hardware->h_lladdr, sizeof(hardware->h_lladdr)) &&
+             POKE_BYTES(&hardware->h_lladdr, ETHER_ADDR_LEN) &&
              /* LLDP frame */
              POKE_UINT16(ETHERTYPE_LLDP)))
                goto toobig;
index 75638d1c3efd9f8a84e9a09ee23556bf7a77d86c..30930cb340934dae8e3022f40d947b60ecae0747 100644 (file)
@@ -207,7 +207,7 @@ sonmp_send(struct lldpd *global,
              /* SONMP multicast address as target */
              POKE_BYTES(mcastaddr, sizeof(mcastaddr)) &&
              /* Source MAC addresss */
-             POKE_BYTES(&hardware->h_lladdr, sizeof(hardware->h_lladdr)) &&
+             POKE_BYTES(&hardware->h_lladdr, ETHER_ADDR_LEN) &&
              /* SONMP frame is of fixed size */
              POKE_UINT16(SONMP_SIZE)))
                goto toobig;