From d6b4db159b60089c3d6e9aad993804ea319047e2 Mon Sep 17 00:00:00 2001 From: Konrad Adamczyk Date: Tue, 11 Apr 2023 10:26:12 +0000 Subject: util: Use common ARRAY_SIZE define Remove duplicated definitions of ARRAY_SIZE macro across util/ dir. Instead of duplicates, use the one from commonlib/bsd/helpers.h file. BUG=b:231765496 TEST=make -C util/cbfstool; make -C util/cbmem; make -C util/intelmetool; make -C util/superiotool Change-Id: I29b776586b4f0548d4026b2ac77095791fc9f3a3 Signed-off-by: Konrad Adamczyk Reviewed-on: https://review.coreboot.org/c/coreboot/+/74474 Reviewed-by: Jakub Czapiga Reviewed-by: Grzegorz Bernacki Reviewed-by: Robert Zieba Reviewed-by: Elyes Haouas Tested-by: build bot (Jenkins) --- util/cbfstool/flashmap/fmap.c | 3 +-- util/cbmem/cbmem.c | 2 -- util/intelmetool/Makefile | 4 +++- util/intelmetool/me_status.c | 3 +-- util/marvell/doimage_mv/Makefile.inc | 3 ++- util/marvell/doimage_mv/doimage.h | 3 +-- util/superiotool/Makefile | 4 +++- util/superiotool/superiotool.h | 3 +-- 8 files changed, 12 insertions(+), 13 deletions(-) diff --git a/util/cbfstool/flashmap/fmap.c b/util/cbfstool/flashmap/fmap.c index 7010dbc367..46c31bb16f 100644 --- a/util/cbfstool/flashmap/fmap.c +++ b/util/cbfstool/flashmap/fmap.c @@ -14,13 +14,12 @@ #include #include #include +#include #include "fmap.h" #include "kv_pair.h" #include "valstr.h" -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) - const struct valstr flag_lut[] = { { FMAP_AREA_STATIC, "static" }, { FMAP_AREA_COMPRESSED, "compressed" }, diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c index 060f88c3f4..65c8544656 100644 --- a/util/cbmem/cbmem.c +++ b/util/cbmem/cbmem.c @@ -33,8 +33,6 @@ #include #endif -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; diff --git a/util/intelmetool/Makefile b/util/intelmetool/Makefile index a97f380d60..375118576a 100644 --- a/util/intelmetool/Makefile +++ b/util/intelmetool/Makefile @@ -2,10 +2,12 @@ PROGRAM = intelmetool +TOP ?= $(abspath ../..) CC ?= gcc INSTALL ?= /usr/bin/env install PREFIX ?= /usr/local -CFLAGS ?= -O0 -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function +CFLAGS ?= -O0 -g -Wall -Wextra -Wno-unused-parameter -Wno-sign-compare -Wno-unused-function \ + -I $(TOP)/src/commonlib/bsd/include LDFLAGS += -lpci -lz OBJS = intelmetool.o me.o me_status.o mmap.o rcba.o msr.o diff --git a/util/intelmetool/me_status.c b/util/intelmetool/me_status.c index d186f96511..a6429d0616 100644 --- a/util/intelmetool/me_status.c +++ b/util/intelmetool/me_status.c @@ -1,10 +1,9 @@ /* SPDX-License-Identifier: GPL-2.0-only */ #include +#include #include "me.h" -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - /* HFS1[3:0] Current Working State Values */ static const char *me_cws_values[] = { [ME_HFS_CWS_RESET] = "Reset", diff --git a/util/marvell/doimage_mv/Makefile.inc b/util/marvell/doimage_mv/Makefile.inc index 4020166261..3f4f528abd 100644 --- a/util/marvell/doimage_mv/Makefile.inc +++ b/util/marvell/doimage_mv/Makefile.inc @@ -1,8 +1,9 @@ ## SPDX-License-Identifier: GPL-2.0-only +TOP = $(abspath ../../..) DOIMAGE_FOLDER = marvell/doimage_mv DOIMAGE_BINARY = doimage -CFLAGS = -g -O1 -I./../inc -DMV_CPU_LE +CFLAGS = -g -O1 -I./../inc -DMV_CPU_LE -I $(TOP)/src/commonlib/bsd/include $(objutil)/$(DOIMAGE_FOLDER): mkdir -p $@ diff --git a/util/marvell/doimage_mv/doimage.h b/util/marvell/doimage_mv/doimage.h index d0000c2731..dab236b27f 100644 --- a/util/marvell/doimage_mv/doimage.h +++ b/util/marvell/doimage_mv/doimage.h @@ -19,6 +19,7 @@ disclaimer. #define _INC_DOIMAGE_H #include +#include /* use the same version as in "bootrom.inc" file */ #define VERSION_NUMBER "2.20" @@ -57,8 +58,6 @@ disclaimer. #define O_BINARY 0 #endif -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) - typedef enum { IMG_SATA, IMG_UART, diff --git a/util/superiotool/Makefile b/util/superiotool/Makefile index f8c1cc1f86..e6a2160989 100644 --- a/util/superiotool/Makefile +++ b/util/superiotool/Makefile @@ -2,6 +2,7 @@ PROGRAM = superiotool +TOP ?= $(abspath ../..) CC ?= gcc INSTALL ?= /usr/bin/env install PREFIX ?= /usr/local @@ -11,7 +12,8 @@ PREFIX ?= /usr/local VERSION := -D'SUPERIOTOOL_VERSION="$(shell git describe 2>/dev/null)"' CFLAGS += -O2 -Wall -Wstrict-prototypes -Wundef -Wstrict-aliasing \ - -Werror-implicit-function-declaration -ansi -pedantic $(VERSION) + -Werror-implicit-function-declaration -ansi -pedantic $(VERSION) \ + -Wno-variadic-macros -I $(TOP)/src/commonlib/bsd/include LDFLAGS += -lz OBJS = superiotool.o serverengines.o ali.o exar.o fintek.o ite.o nsc.o \ diff --git a/util/superiotool/superiotool.h b/util/superiotool/superiotool.h index 8c01559759..14090309ee 100644 --- a/util/superiotool/superiotool.h +++ b/util/superiotool/superiotool.h @@ -8,6 +8,7 @@ #include #include #include +#include #if defined(__linux__) #include #endif @@ -109,8 +110,6 @@ and print its vendor, name, ID, revision, and config port.\n" #define NOTFOUND " Failed. Returned data: " -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) - #define EOT -1 /* End Of Table */ #define NOLDN -2 /* NO LDN needed */ #define NANA -3 /* Not Available: -- cgit v1.2.3