[PATCH 11/11] Rename HWADDR_SIZE for clarity
Daniel M. Weeks
weeksd2 at rpi.edu
Fri Apr 17 03:56:31 AEST 2020
Any remaining references to HWADDR_SIZE are for MAC address comparisons
or transformations. This renames them to provide clarity when other
sizes may be possible/significant.
Signed-off-by: Daniel M. Weeks <weeksd2 at rpi.edu>
---
discover/ipmi.c | 2 +-
discover/network.c | 6 +++---
discover/platform-powerpc.c | 2 +-
discover/udev.c | 6 +++---
lib/pb-protocol/pb-protocol.c | 16 ++++++++--------
lib/types/types.h | 4 ++--
test/parser/network.c | 4 ++--
ui/ncurses/nc-sysinfo.c | 2 +-
8 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/discover/ipmi.c b/discover/ipmi.c
index 14a9e07..01955ea 100644
--- a/discover/ipmi.c
+++ b/discover/ipmi.c
@@ -244,7 +244,7 @@ int parse_ipmi_interface_override(struct config *config, uint8_t *buf,
}
/* At the moment only support 6-byte MAC addresses */
- if (hwsize != HWADDR_SIZE) {
+ if (hwsize != MAC_HWADDR_SIZE) {
pb_log("Unsupported HW address size in network override: %u\n",
hwsize);
return -1;
diff --git a/discover/network.c b/discover/network.c
index a2a17e0..338762b 100644
--- a/discover/network.c
+++ b/discover/network.c
@@ -25,7 +25,7 @@
#include "device-handler.h"
#include "paths.h"
-#define HWADDR_SIZE 6
+#define MAC_HWADDR_SIZE 6
#define PIDFILE_BASE (LOCAL_STATE_DIR "/petitboot/")
#define INITIAL_BUFSIZE 4096
@@ -42,7 +42,7 @@
struct interface {
int ifindex;
char name[IFNAMSIZ];
- uint8_t hwaddr[HWADDR_SIZE];
+ uint8_t hwaddr[MAC_HWADDR_SIZE];
unsigned int hwaddr_len;
enum {
@@ -673,7 +673,7 @@ void network_mark_interface_ready(struct device_handler *handler,
return;
}
- if (hwsize != HWADDR_SIZE)
+ if (hwsize != MAC_HWADDR_SIZE)
return;
if (strncmp(ifname, "lo", strlen("lo")) == 0)
diff --git a/discover/platform-powerpc.c b/discover/platform-powerpc.c
index 9bdba30..29f8003 100644
--- a/discover/platform-powerpc.c
+++ b/discover/platform-powerpc.c
@@ -1329,7 +1329,7 @@ static int get_sysinfo(struct platform *p, struct system_info *sysinfo)
sysinfo->identifier = talloc_steal(sysinfo, buf);
talloc_free(filename);
- sysinfo->bmc_mac = talloc_zero_size(sysinfo, HWADDR_SIZE);
+ sysinfo->bmc_mac = talloc_zero_size(sysinfo, MAC_HWADDR_SIZE);
if (platform->ipmi)
get_ipmi_bmc_mac(p, sysinfo->bmc_mac);
diff --git a/discover/udev.c b/discover/udev.c
index 45a8b56..470bbc3 100644
--- a/discover/udev.c
+++ b/discover/udev.c
@@ -272,7 +272,7 @@ static int udev_check_interface_ready(struct device_handler *handler,
return -1;
}
- mac = talloc_array(handler, uint8_t, HWADDR_SIZE);
+ mac = talloc_array(handler, uint8_t, MAC_HWADDR_SIZE);
if (!mac)
return -1;
@@ -282,13 +282,13 @@ static int udev_check_interface_ready(struct device_handler *handler,
*/
byte[2] = '\0';
for (i = strlen("enx"), j = 0;
- i < strlen(mac_name) && j < HWADDR_SIZE; i += 2) {
+ i < strlen(mac_name) && j < MAC_HWADDR_SIZE; i += 2) {
memcpy(byte, &mac_name[i], 2);
mac[j++] = strtoul(byte, NULL, 16);
}
network_mark_interface_ready(handler,
- atoi(ifindex), interface, mac, HWADDR_SIZE);
+ atoi(ifindex), interface, mac, MAC_HWADDR_SIZE);
talloc_free(mac);
return 0;
diff --git a/lib/pb-protocol/pb-protocol.c b/lib/pb-protocol/pb-protocol.c
index b5186ad..569c83d 100644
--- a/lib/pb-protocol/pb-protocol.c
+++ b/lib/pb-protocol/pb-protocol.c
@@ -264,7 +264,7 @@ int pb_protocol_system_info_len(const struct system_info *sysinfo)
}
/* BMC MAC */
- len += HWADDR_SIZE;
+ len += MAC_HWADDR_SIZE;
return len;
}
@@ -508,10 +508,10 @@ int pb_protocol_serialise_system_info(const struct system_info *sysinfo,
}
if (sysinfo->bmc_mac)
- memcpy(pos, sysinfo->bmc_mac, HWADDR_SIZE);
+ memcpy(pos, sysinfo->bmc_mac, MAC_HWADDR_SIZE);
else
- memset(pos, 0, HWADDR_SIZE);
- pos += HWADDR_SIZE;
+ memset(pos, 0, MAC_HWADDR_SIZE);
+ pos += MAC_HWADDR_SIZE;
assert(pos <= buf + buf_len);
(void)buf_len;
@@ -1041,15 +1041,15 @@ int pb_protocol_deserialise_system_info(struct system_info *sysinfo,
sysinfo->blockdevs[i] = bd_info;
}
- for (i = 0; i < HWADDR_SIZE; i++) {
+ for (i = 0; i < MAC_HWADDR_SIZE; i++) {
if (pos[i] != 0) {
- sysinfo->bmc_mac = talloc_memdup(sysinfo, pos, HWADDR_SIZE);
+ sysinfo->bmc_mac = talloc_memdup(sysinfo, pos, MAC_HWADDR_SIZE);
break;
}
}
- pos += HWADDR_SIZE;
- len -= HWADDR_SIZE;
+ pos += MAC_HWADDR_SIZE;
+ len -= MAC_HWADDR_SIZE;
rc = 0;
out:
diff --git a/lib/types/types.h b/lib/types/types.h
index 719332a..674a748 100644
--- a/lib/types/types.h
+++ b/lib/types/types.h
@@ -136,11 +136,11 @@ struct system_info {
unsigned int n_blockdevs;
};
-#define HWADDR_SIZE 6
+#define MAC_HWADDR_SIZE 6
struct interface_config {
unsigned int hwaddr_len;
- uint8_t hwaddr[HWADDR_SIZE];
+ uint8_t hwaddr[MAC_HWADDR_SIZE];
bool ignore;
enum {
CONFIG_METHOD_DHCP,
diff --git a/test/parser/network.c b/test/parser/network.c
index 6870dd2..fab1d9b 100644
--- a/test/parser/network.c
+++ b/test/parser/network.c
@@ -8,7 +8,7 @@
struct interface {
int ifindex;
char name[IFNAMSIZ];
- uint8_t hwaddr[HWADDR_SIZE];
+ uint8_t hwaddr[MAC_HWADDR_SIZE];
enum {
IFSTATE_NEW,
@@ -49,7 +49,7 @@ uint8_t *find_mac_by_name(void *ctx, struct network *network,
return NULL;
return talloc_memdup(ctx, &interface->hwaddr,
- sizeof(uint8_t) * HWADDR_SIZE);
+ sizeof(uint8_t) * MAC_HWADDR_SIZE);
}
void network_requery_device(struct network *network,
diff --git a/ui/ncurses/nc-sysinfo.c b/ui/ncurses/nc-sysinfo.c
index 8252b45..f0f9cb1 100644
--- a/ui/ncurses/nc-sysinfo.c
+++ b/ui/ncurses/nc-sysinfo.c
@@ -113,7 +113,7 @@ static void sysinfo_screen_populate(struct sysinfo_screen *screen,
if (sysinfo->bmc_mac) {
line(NULL);
- mac_str(sysinfo->bmc_mac, HWADDR_SIZE, macbuf, sizeof(macbuf));
+ mac_str(sysinfo->bmc_mac, MAC_HWADDR_SIZE, macbuf, sizeof(macbuf));
line(_("Management (BMC) interface"));
line(_(" MAC: %s"), macbuf);
}
--
Daniel M. Weeks
--
Daniel M. Weeks
Lead HPC Developer
Center for Computational Innovations
Rensselaer Polytechnic Institute
Troy, NY 12180
518-276-4458
More information about the Petitboot
mailing list