@@ -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;
@@ -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)
@@ -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);
@@ -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;
@@ -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:
@@ -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,
@@ -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,
@@ -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);
}
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@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(-)