Fix MISRA C issues in BL1/BL2/BL31

Attempts to address MISRA compliance issues in BL1, BL2, and BL31 code.
Mainly issues like not using boolean expressions in conditionals,
conflicting variable names, ignoring return values without (void), adding
explicit casts, etc.

Change-Id: If1fa18ab621b9c374db73fa6eaa6f6e5e55c146a
Signed-off-by: John Powell <john.powell@arm.com>
diff --git a/bl1/bl1_main.c b/bl1/bl1_main.c
index e11ead6..1479a96 100644
--- a/bl1/bl1_main.c
+++ b/bl1/bl1_main.c
@@ -90,8 +90,7 @@
 	NOTICE("BL1: %s\n", version_string);
 	NOTICE("BL1: %s\n", build_message);
 
-	INFO("BL1: RAM %p - %p\n", (void *)BL1_RAM_BASE,
-					(void *)BL1_RAM_LIMIT);
+	INFO("BL1: RAM %p - %p\n", (void *)BL1_RAM_BASE, (void *)BL1_RAM_LIMIT);
 
 	print_errata_status();
 
@@ -105,9 +104,9 @@
 #else
 	val = read_sctlr();
 #endif
-	assert(val & SCTLR_M_BIT);
-	assert(val & SCTLR_C_BIT);
-	assert(val & SCTLR_I_BIT);
+	assert((val & SCTLR_M_BIT) != 0);
+	assert((val & SCTLR_C_BIT) != 0);
+	assert((val & SCTLR_I_BIT) != 0);
 	/*
 	 * Check that Cache Writeback Granule (CWG) in CTR_EL0 matches the
 	 * provided platform value
@@ -166,33 +165,33 @@
  ******************************************************************************/
 static void bl1_load_bl2(void)
 {
-	image_desc_t *image_desc;
-	image_info_t *image_info;
+	image_desc_t *desc;
+	image_info_t *info;
 	int err;
 
 	/* Get the image descriptor */
-	image_desc = bl1_plat_get_image_desc(BL2_IMAGE_ID);
-	assert(image_desc != NULL);
+	desc = bl1_plat_get_image_desc(BL2_IMAGE_ID);
+	assert(desc != NULL);
 
 	/* Get the image info */
-	image_info = &image_desc->image_info;
+	info = &desc->image_info;
 	INFO("BL1: Loading BL2\n");
 
 	err = bl1_plat_handle_pre_image_load(BL2_IMAGE_ID);
-	if (err) {
+	if (err != 0) {
 		ERROR("Failure in pre image load handling of BL2 (%d)\n", err);
 		plat_error_handler(err);
 	}
 
-	err = load_auth_image(BL2_IMAGE_ID, image_info);
-	if (err) {
+	err = load_auth_image(BL2_IMAGE_ID, info);
+	if (err != 0) {
 		ERROR("Failed to load BL2 firmware.\n");
 		plat_error_handler(err);
 	}
 
 	/* Allow platform to handle image information. */
 	err = bl1_plat_handle_post_image_load(BL2_IMAGE_ID);
-	if (err) {
+	if (err != 0) {
 		ERROR("Failure in post image load handling of BL2 (%d)\n", err);
 		plat_error_handler(err);
 	}
@@ -258,11 +257,9 @@
 		SMC_RET1(handle, BL1_SMC_MAJOR_VER | BL1_SMC_MINOR_VER);
 
 	default:
-		break;
+		WARN("Unimplemented BL1 SMC Call: 0x%x\n", smc_fid);
+		SMC_RET1(handle, SMC_UNK);
 	}
-
-	WARN("Unimplemented BL1 SMC Call: 0x%x \n", smc_fid);
-	SMC_RET1(handle, SMC_UNK);
 }
 
 /*******************************************************************************