Matt DeVillier has submitted this change. ( https://review.coreboot.org/c/coreboot/+/86556?usp=email )
Change subject: util/cbmem: Use uintN_t instead of uN int types ......................................................................
util/cbmem: Use uintN_t instead of uN int types
Replace all occurrences of u8, u16, u32 and u64 with their respective alternatives of uint8_t. There is no need to unnecessarily compress code by using standard types aliases.
BUG=b:391874512 TEST=Compile cbmem
Change-Id: I4fdb4a31923368342ef218144f8cb44624cd4b2a Signed-off-by: Jakub Czapiga czapiga@google.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/86556 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Felix Singer service+coreboot-gerrit@felixsinger.de Reviewed-by: Elyes Haouas ehaouas@noos.fr --- M util/cbmem/cbmem.c 1 file changed, 15 insertions(+), 20 deletions(-)
Approvals: Elyes Haouas: Looks good to me, approved build bot (Jenkins): Verified Felix Singer: Looks good to me, approved
diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c index 15b6770..bdb6794 100644 --- a/util/cbmem/cbmem.c +++ b/util/cbmem/cbmem.c @@ -35,13 +35,8 @@ #include <x86intrin.h> #endif
-typedef uint8_t u8; -typedef uint16_t u16; -typedef uint32_t u32; -typedef uint64_t u64; - /* Return < 0 on error, 0 on success. */ -static int parse_cbtable(u64 address, size_t table_size); +static int parse_cbtable(uint64_t address, size_t table_size);
struct mapping { void *virt; @@ -178,8 +173,8 @@ */ static void *aligned_memcpy(void *dest, const void *src, size_t n) { - u8 *d = dest; - const volatile u8 *s = src; /* volatile to prevent optimization */ + uint8_t *d = dest; + const volatile uint8_t *s = src; /* volatile to prevent optimization */
while ((uintptr_t)s & (sizeof(size_t) - 1)) { if (n-- == 0) @@ -353,7 +348,7 @@ }
/* Return < 0 on error, 0 on success. */ -static int parse_cbtable(u64 address, size_t table_size) +static int parse_cbtable(uint64_t address, size_t table_size) { const void *buf; struct mapping header_mapping; @@ -441,7 +436,7 @@ char freqs[100]; int size; char *endp; - u64 rv; + uint64_t rv;
const char* freq_file = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"; @@ -509,7 +504,7 @@ debug("Timestamp tick frequency: %ld MHz\n", tick_freq_mhz); }
-static u64 arch_convert_raw_ts_entry(u64 ts) +static uint64_t arch_convert_raw_ts_entry(uint64_t ts) { return ts / tick_freq_mhz; } @@ -518,14 +513,14 @@ * Print an integer in 'normalized' form - with commas separating every three * decimal orders. */ -static void print_norm(u64 v) +static void print_norm(uint64_t v) { if (v >= 1000) { /* print the higher order sections first */ print_norm(v / 1000); - printf(",%3.3u", (u32)(v % 1000)); + printf(",%3.3u", (uint32_t)(v % 1000)); } else { - printf("%u", (u32)(v % 1000)); + printf("%u", (uint32_t)(v % 1000)); } }
@@ -1096,9 +1091,9 @@ }
struct cbmem_console { - u32 size; - u32 cursor; - u8 body[]; + uint32_t size; + uint32_t cursor; + uint8_t body[]; } __attribute__ ((__packed__));
#define CBMC_CURSOR_MASK ((1 << 28) - 1) @@ -1828,7 +1823,7 @@
int i; size_t size_to_read = addr_cells * 4 + size_cells * 4; - u8 *dtbuffer = alloca(size_to_read); + uint8_t *dtbuffer = alloca(size_to_read); if (read(fd, dtbuffer, size_to_read) < 0) { perror(reg); return 1; @@ -1836,13 +1831,13 @@ close(fd);
/* No variable-length byte swap function anywhere in C... how sad. */ - u64 baseaddr = 0; + uint64_t baseaddr = 0; for (i = 0; i < addr_cells * 4; i++) { baseaddr <<= 8; baseaddr |= *dtbuffer; dtbuffer++; } - u64 cb_table_size = 0; + uint64_t cb_table_size = 0; for (i = 0; i < size_cells * 4; i++) { cb_table_size <<= 8; cb_table_size |= *dtbuffer;