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 <konrada@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/74474
Reviewed-by: Jakub Czapiga <jacz@semihalf.com>
Reviewed-by: Grzegorz Bernacki
Reviewed-by: Robert Zieba <robertzieba@google.com>
Reviewed-by: Elyes Haouas <ehaouas@noos.fr>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Konrad Adamczyk 2023-04-11 10:26:12 +00:00 committed by Felix Held
parent 9203f5ee85
commit d6b4db159b
8 changed files with 12 additions and 13 deletions

View File

@ -14,13 +14,12 @@
#include <limits.h> #include <limits.h>
#include <assert.h> #include <assert.h>
#include <commonlib/bsd/sysincludes.h> #include <commonlib/bsd/sysincludes.h>
#include <commonlib/bsd/helpers.h>
#include "fmap.h" #include "fmap.h"
#include "kv_pair.h" #include "kv_pair.h"
#include "valstr.h" #include "valstr.h"
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
const struct valstr flag_lut[] = { const struct valstr flag_lut[] = {
{ FMAP_AREA_STATIC, "static" }, { FMAP_AREA_STATIC, "static" },
{ FMAP_AREA_COMPRESSED, "compressed" }, { FMAP_AREA_COMPRESSED, "compressed" },

View File

@ -33,8 +33,6 @@
#include <x86intrin.h> #include <x86intrin.h>
#endif #endif
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
typedef uint8_t u8; typedef uint8_t u8;
typedef uint16_t u16; typedef uint16_t u16;
typedef uint32_t u32; typedef uint32_t u32;

View File

@ -2,10 +2,12 @@
PROGRAM = intelmetool PROGRAM = intelmetool
TOP ?= $(abspath ../..)
CC ?= gcc CC ?= gcc
INSTALL ?= /usr/bin/env install INSTALL ?= /usr/bin/env install
PREFIX ?= /usr/local 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 LDFLAGS += -lpci -lz
OBJS = intelmetool.o me.o me_status.o mmap.o rcba.o msr.o OBJS = intelmetool.o me.o me_status.o mmap.o rcba.o msr.o

View File

@ -1,10 +1,9 @@
/* SPDX-License-Identifier: GPL-2.0-only */ /* SPDX-License-Identifier: GPL-2.0-only */
#include <stdio.h> #include <stdio.h>
#include <commonlib/bsd/helpers.h>
#include "me.h" #include "me.h"
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
/* HFS1[3:0] Current Working State Values */ /* HFS1[3:0] Current Working State Values */
static const char *me_cws_values[] = { static const char *me_cws_values[] = {
[ME_HFS_CWS_RESET] = "Reset", [ME_HFS_CWS_RESET] = "Reset",

View File

@ -1,8 +1,9 @@
## SPDX-License-Identifier: GPL-2.0-only ## SPDX-License-Identifier: GPL-2.0-only
TOP = $(abspath ../../..)
DOIMAGE_FOLDER = marvell/doimage_mv DOIMAGE_FOLDER = marvell/doimage_mv
DOIMAGE_BINARY = doimage 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): $(objutil)/$(DOIMAGE_FOLDER):
mkdir -p $@ mkdir -p $@

View File

@ -19,6 +19,7 @@ disclaimer.
#define _INC_DOIMAGE_H #define _INC_DOIMAGE_H
#include <sys/types.h> #include <sys/types.h>
#include <commonlib/bsd/helpers.h>
/* use the same version as in "bootrom.inc" file */ /* use the same version as in "bootrom.inc" file */
#define VERSION_NUMBER "2.20" #define VERSION_NUMBER "2.20"
@ -57,8 +58,6 @@ disclaimer.
#define O_BINARY 0 #define O_BINARY 0
#endif #endif
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
typedef enum { typedef enum {
IMG_SATA, IMG_SATA,
IMG_UART, IMG_UART,

View File

@ -2,6 +2,7 @@
PROGRAM = superiotool PROGRAM = superiotool
TOP ?= $(abspath ../..)
CC ?= gcc CC ?= gcc
INSTALL ?= /usr/bin/env install INSTALL ?= /usr/bin/env install
PREFIX ?= /usr/local PREFIX ?= /usr/local
@ -11,7 +12,8 @@ PREFIX ?= /usr/local
VERSION := -D'SUPERIOTOOL_VERSION="$(shell git describe 2>/dev/null)"' VERSION := -D'SUPERIOTOOL_VERSION="$(shell git describe 2>/dev/null)"'
CFLAGS += -O2 -Wall -Wstrict-prototypes -Wundef -Wstrict-aliasing \ 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 LDFLAGS += -lz
OBJS = superiotool.o serverengines.o ali.o exar.o fintek.o ite.o nsc.o \ OBJS = superiotool.o serverengines.o ali.o exar.o fintek.o ite.o nsc.o \

View File

@ -8,6 +8,7 @@
#include <stdint.h> #include <stdint.h>
#include <string.h> #include <string.h>
#include <getopt.h> #include <getopt.h>
#include <commonlib/bsd/helpers.h>
#if defined(__linux__) #if defined(__linux__)
#include <sys/io.h> #include <sys/io.h>
#endif #endif
@ -109,8 +110,6 @@ and print its vendor, name, ID, revision, and config port.\n"
#define NOTFOUND " Failed. Returned data: " #define NOTFOUND " Failed. Returned data: "
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#define EOT -1 /* End Of Table */ #define EOT -1 /* End Of Table */
#define NOLDN -2 /* NO LDN needed */ #define NOLDN -2 /* NO LDN needed */
#define NANA -3 /* Not Available: #define NANA -3 /* Not Available: