Build: Major warnings cleanup

This is a major type-mismatch cleanup and warnings elimination.

The IAR toolchain runs with more warnings enabled than ARMCLANG or
GNUARM, which has resulted in this effort.

This should make it easier to enable "pedantic" mode also for GNUARM.

There are still a few warnings about jumping past variable
initialization and falling off the end of non-void functions, but there
are comments in some of these parts that implies that this is done to
catch programming errors, like having case labels for all possible enum
values.

Reordered initializer in tfm_attestation_req_mngr.c to eliminate CI
warning.

Disabled "Pe940" warnings in CommonConfig.cmake to suppress warnings
about inline assembly functions declared to return value that doesn't
declare a return value in the __ASM() statement.

Disabled "Pe546" warnings to supress warnings about jumping over
unused initializers.

Fixed what appears to be a copy/paste bug in tfm_ss_core_test.c.

Removed unused variable "ret" in Driver_PPC.c for AN519 and AN521, to
make it similar to AN524.

Signed-off-by: TTornblom <thomas.tornblom@iar.com>
Change-Id: I2b729c73e4b004cff6b0530cc1350fcf900e4272
diff --git a/bl2/ext/mcuboot/bootutil/src/loader.c b/bl2/ext/mcuboot/bootutil/src/loader.c
index 2807d0b..6aecfce 100644
--- a/bl2/ext/mcuboot/bootutil/src/loader.c
+++ b/bl2/ext/mcuboot/bootutil/src/loader.c
@@ -55,7 +55,8 @@
 #define IMAGES_ITER(x)
 #endif
 
-#if !defined(MCUBOOT_NO_SWAP) && !defined(MCUBOOT_RAM_LOADING)
+#if !defined(MCUBOOT_NO_SWAP) && !defined(MCUBOOT_RAM_LOADING) && !defined(MCUBOOT_OVERWRITE_ONLY)
+
 
 #if defined(MCUBOOT_VALIDATE_PRIMARY_SLOT) && !defined(MCUBOOT_OVERWRITE_ONLY)
 static int boot_status_fails = 0;
@@ -159,7 +160,7 @@
                  (state)->swap_type,                                \
                  (state)->copy_done,                                \
                  (state)->image_ok)
-#endif /* !MCUBOOT_NO_SWAP && !MCUBOOT_RAM_LOADING */
+#endif /* !MCUBOOT_NO_SWAP && !MCUBOOT_RAM_LOADING && !defined(MCUBOOT_OVERWRITE_ONLY) */
 
 /*
  * \brief Verifies the image header: magic value, flags, integer overflow.
@@ -599,7 +600,8 @@
 }
 #endif /* !MCUBOOT_NO_SWAP && !MCUBOOT_OVERWRITE_ONLY */
 
-#if !defined(MCUBOOT_NO_SWAP) && !defined(MCUBOOT_RAM_LOADING)
+#if !defined(MCUBOOT_NO_SWAP) && !defined(MCUBOOT_RAM_LOADING) && !defined(MCUBOOT_OVERWRITE_ONLY)
+
 /**
  * Determines where in flash the most recent boot status is stored. The boot
  * status is necessary for completing a swap that was interrupted by a boot
@@ -860,13 +862,6 @@
 static int
 boot_read_status(struct boot_loader_state *state, struct boot_status *bs)
 {
-    const struct flash_area *fap;
-    uint32_t off;
-    uint8_t swap_info;
-    int status_loc;
-    int area_id;
-    int rc;
-
     memset(bs, 0, sizeof *bs);
     bs->idx = BOOT_STATUS_IDX_0;
     bs->state = BOOT_STATUS_STATE_0;
@@ -875,7 +870,13 @@
 #ifdef MCUBOOT_OVERWRITE_ONLY
     /* Overwrite-only doesn't make use of the swap status area. */
     return 0;
-#endif
+#else
+    const struct flash_area *fap;
+    uint32_t off;
+    uint8_t swap_info;
+    int status_loc;
+    int area_id;
+    int rc;
 
     status_loc = boot_status_source(state);
     switch (status_loc) {
@@ -916,6 +917,7 @@
     flash_area_close(fap);
 
     return rc;
+#endif
 }
 
 /**