treewide: Drop most cases of `sizeof(struct ...)`

Spelling out the struct type name hurts readability and introduces
opportunities for bugs to happen when the pointer variable type is
changed but the corresponding sizeof is (are) not.

Tested: `make CONFIG_EVERYTHING=yes CONFIG_JLINK_SPI=no VERSION=none -j`
with and without this patch; the flashrom executable does not change.

flashrom-stable: Applied partially.

Change-Id: Icc0b60ca6ef9f5ece6ed2a0e03600bb6ccd7dcc6
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/55266
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71371
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/flashrom.c b/flashrom.c
index 8edfd0e..cbb9eab 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -762,12 +762,12 @@
 		}
 
 		/* Start filling in the dynamic data. */
-		flash->chip = calloc(1, sizeof(struct flashchip));
+		flash->chip = calloc(1, sizeof(*flash->chip));
 		if (!flash->chip) {
 			msg_gerr("Out of memory!\n");
 			exit(1);
 		}
-		memcpy(flash->chip, chip, sizeof(struct flashchip));
+		memcpy(flash->chip, chip, sizeof(*flash->chip));
 		flash->mst = mst;
 
 		if (map_flash(flash) != 0)
diff --git a/fmap.c b/fmap.c
index ca25651..e13de67 100644
--- a/fmap.c
+++ b/fmap.c
@@ -195,7 +195,7 @@
 	if (prepare_flash_access(flashctx, true, false, false, false))
 		return 1;
 
-	fmap = malloc(sizeof(struct fmap));
+	fmap = malloc(sizeof(*fmap));
 	if (!fmap) {
 		msg_gerr("Out of memory.\n");
 		goto _free_ret;
diff --git a/hwaccess.c b/hwaccess.c
index 48ccb34..3a9ca57 100644
--- a/hwaccess.c
+++ b/hwaccess.c
@@ -247,7 +247,7 @@
 #define register_undo_mmio_write(a, c)					\
 {									\
 	struct undo_mmio_write_data *undo_mmio_write_data;		\
-	undo_mmio_write_data = malloc(sizeof(struct undo_mmio_write_data)); \
+	undo_mmio_write_data = malloc(sizeof(*undo_mmio_write_data));	\
 	if (!undo_mmio_write_data) {					\
 		msg_gerr("Out of memory!\n");				\
 		exit(1);						\
diff --git a/ichspi.c b/ichspi.c
index 3e1040d..90bbd13 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1734,7 +1734,7 @@
 	ich_generation = ich_gen;
 	ich_spibar = spibar;
 
-	memset(&desc, 0x00, sizeof(struct ich_descriptors));
+	memset(&desc, 0x00, sizeof(desc));
 
 	/* Moving registers / bits */
 	switch (ich_generation) {
diff --git a/layout.c b/layout.c
index d80b01f..231a962 100644
--- a/layout.c
+++ b/layout.c
@@ -122,7 +122,7 @@
 		tmp = tmp->next;
 	}
 
-	tmp = malloc(sizeof(struct layout_include_args));
+	tmp = malloc(sizeof(*tmp));
 	if (tmp == NULL) {
 		msg_gerr("Could not allocate memory");
 		return 1;
diff --git a/pcidev.c b/pcidev.c
index 892f7b1..9ffe05c 100644
--- a/pcidev.c
+++ b/pcidev.c
@@ -296,7 +296,7 @@
 #define register_undo_pci_write(a, b, c)				\
 {									\
 	struct undo_pci_write_data *undo_pci_write_data;		\
-	undo_pci_write_data = malloc(sizeof(struct undo_pci_write_data)); \
+	undo_pci_write_data = malloc(sizeof(*undo_pci_write_data));	\
 	if (!undo_pci_write_data) {					\
 		msg_gerr("Out of memory!\n");				\
 		exit(1);						\
diff --git a/physmap.c b/physmap.c
index 72d5899..6c36814 100644
--- a/physmap.c
+++ b/physmap.c
@@ -292,7 +292,7 @@
 	}
 
 	if (autocleanup) {
-		struct undo_physmap_data *d = malloc(sizeof(struct undo_physmap_data));
+		struct undo_physmap_data *d = malloc(sizeof(*d));
 		if (d == NULL) {
 			msg_perr("%s: Out of memory!\n", __func__);
 			physunmap_unaligned(virt_addr, len);
diff --git a/sfdp.c b/sfdp.c
index a626127..b549417 100644
--- a/sfdp.c
+++ b/sfdp.c
@@ -296,7 +296,7 @@
 
 	/* Fetch all parameter headers, even if we don't use them all (yet). */
 	hbuf = malloc((nph + 1) * 8);
-	hdrs = malloc((nph + 1) * sizeof(struct sfdp_tbl_hdr));
+	hdrs = malloc((nph + 1) * sizeof(*hdrs));
 	if (hbuf == NULL || hdrs == NULL ) {
 		msg_gerr("Out of memory!\n");
 		goto cleanup_hdrs;