From patchwork Thu Apr 16 17:56:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Daniel M. Weeks" X-Patchwork-Id: 1271835 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4936Sk4gsNz9sWT for ; Fri, 17 Apr 2020 04:00:06 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=rpi.edu Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4936Sk0vlNzDsJQ for ; Fri, 17 Apr 2020 04:00:06 +1000 (AEST) X-Original-To: petitboot@lists.ozlabs.org Delivered-To: petitboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=rpi.edu (client-ip=128.113.2.229; helo=smtp9.server.rpi.edu; envelope-from=weeksd2@rpi.edu; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=rpi.edu Received: from smtp9.server.rpi.edu (smtp9.server.rpi.edu [128.113.2.229]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4936Nl36nZzDqFD for ; Fri, 17 Apr 2020 03:56:38 +1000 (AEST) Received: from smtp-auth2.server.rpi.edu (route.canit.rpi.edu [128.113.2.232]) by smtp9.server.rpi.edu (8.14.4/8.14.4/Debian-8+deb8u2) with ESMTP id 03GHuZ3b116208 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 Apr 2020 13:56:35 -0400 Received: from smtp-auth2.server.rpi.edu (localhost [127.0.0.1]) by smtp-auth2.server.rpi.edu (Postfix) with ESMTP id 222B91A0E9 for ; Thu, 16 Apr 2020 13:56:35 -0400 (EDT) Received: from dev.danweeks.net (cpe-74-70-107-6.nycap.res.rr.com [74.70.107.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: weeksd2) by smtp-auth2.server.rpi.edu (Postfix) with ESMTPSA id 018651A0E8 for ; Thu, 16 Apr 2020 13:56:34 -0400 (EDT) Date: Thu, 16 Apr 2020 13:56:31 -0400 From: "Daniel M. Weeks" To: petitboot@lists.ozlabs.org Subject: [PATCH 11/11] Rename HWADDR_SIZE for clarity Message-ID: <1392b2684ad07f20633299a66f252b5267517164.1587059210.git.weeksd2@rpi.edu> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Virus-Scanned: ClamAV using ClamSMTP X-Bayes-Prob: 0.0001 (Score 0, tokens from: outgoing, @@RPTN) X-Spam-Score: 0.00 () [Hold at 10.10] X-CanIt-Incident-Id: 022rtUzcX X-CanIt-Geo: ip=74.70.107.6; country=US; region=New York; city=Troy; latitude=42.7273; longitude=-73.6696; http://maps.google.com/maps?q=42.7273,-73.6696&z=6 X-CanItPRO-Stream: outgoing X-Canit-Stats-ID: Bayes signature not available X-Scanned-By: CanIt (www . roaringpenguin . com) on 128.113.2.229 X-BeenThere: petitboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Petitboot bootloader development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: petitboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Petitboot" 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 --- 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); }