Merge changes from topic "static_analysis" into integration

* changes:
  io: io_stm32image: correct possible NULL pointer dereference
  plat/st: correctly check pwr-regulators node
  nand: stm32_fmc2_nand: correct xor_ecc.val assigned value
  plat/st: correct static analysis tool warning
  raw_nand: correct static analysis tool warning
  spi: stm32_qspi: correct static analysis issues
diff --git a/drivers/st/fmc/stm32_fmc2_nand.c b/drivers/st/fmc/stm32_fmc2_nand.c
index b694fff..d2d7e06 100644
--- a/drivers/st/fmc/stm32_fmc2_nand.c
+++ b/drivers/st/fmc/stm32_fmc2_nand.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, STMicroelectronics - All Rights Reserved
+ * Copyright (c) 2019-2020, STMicroelectronics - All Rights Reserved
  *
  * SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
  */
@@ -365,7 +365,7 @@
 	xor_ecc_2b = ecc[1] ^ eccbuffer[1];
 	xor_ecc_3b = ecc[2] ^ eccbuffer[2];
 
-	xor_ecc.val = 0L;
+	xor_ecc.val = 0U;
 	xor_ecc.bytes[2] = xor_ecc_3b;
 	xor_ecc.bytes[1] = xor_ecc_2b;
 	xor_ecc.bytes[0] = xor_ecc_1b;
diff --git a/drivers/st/io/io_stm32image.c b/drivers/st/io/io_stm32image.c
index 413521b..3e377cd 100644
--- a/drivers/st/io/io_stm32image.c
+++ b/drivers/st/io/io_stm32image.c
@@ -247,7 +247,7 @@
 				     size_t length, size_t *length_read)
 {
 	int result;
-	uint8_t *local_buffer = (uint8_t *)buffer;
+	uint8_t *local_buffer;
 	boot_api_image_header_t *header =
 		(boot_api_image_header_t *)first_lba_buffer;
 
@@ -255,6 +255,7 @@
 	assert(buffer != 0U);
 	assert(length_read != NULL);
 
+	local_buffer = (uint8_t *)buffer;
 	*length_read = 0U;
 
 	while (*length_read == 0U) {
diff --git a/drivers/st/spi/stm32_qspi.c b/drivers/st/spi/stm32_qspi.c
index 188d2ff..c5e4ea8 100644
--- a/drivers/st/spi/stm32_qspi.c
+++ b/drivers/st/spi/stm32_qspi.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, STMicroelectronics - All Rights Reserved
+ * Copyright (c) 2019-2020, STMicroelectronics - All Rights Reserved
  *
  * SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
  */
@@ -12,6 +12,7 @@
 #include <drivers/delay_timer.h>
 #include <drivers/spi_mem.h>
 #include <drivers/st/stm32_gpio.h>
+#include <drivers/st/stm32_qspi.h>
 #include <drivers/st/stm32mp_reset.h>
 #include <lib/mmio.h>
 #include <lib/utils_def.h>
@@ -172,9 +173,8 @@
 static int stm32_qspi_poll(const struct spi_mem_op *op)
 {
 	void (*fifo)(uint8_t *val, uintptr_t addr);
-	uint32_t len = op->data.nbytes;
+	uint32_t len;
 	uint8_t *buf;
-	uint64_t timeout;
 
 	if (op->data.dir == SPI_MEM_DATA_IN) {
 		fifo = stm32_qspi_read_fifo;
@@ -185,7 +185,8 @@
 	buf = (uint8_t *)op->data.buf;
 
 	for (len = op->data.nbytes; len != 0U; len--) {
-		timeout = timeout_init_us(QSPI_FIFO_TIMEOUT_US);
+		uint64_t timeout = timeout_init_us(QSPI_FIFO_TIMEOUT_US);
+
 		while ((mmio_read_32(qspi_base() + QSPI_SR) &
 			QSPI_SR_FTF) == 0U) {
 			if (timeout_elapsed(timeout)) {
diff --git a/include/drivers/raw_nand.h b/include/drivers/raw_nand.h
index 18e4b73..9018f02 100644
--- a/include/drivers/raw_nand.h
+++ b/include/drivers/raw_nand.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, STMicroelectronics - All Rights Reserved
+ * Copyright (c) 2019-2020, STMicroelectronics - All Rights Reserved
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -7,6 +7,7 @@
 #ifndef DRIVERS_RAW_NAND_H
 #define DRIVERS_RAW_NAND_H
 
+#include <cdefs.h>
 #include <stdint.h>
 
 #include <drivers/nand.h>
diff --git a/plat/st/common/stm32mp_dt.c b/plat/st/common/stm32mp_dt.c
index 4fa796f..acb323c 100644
--- a/plat/st/common/stm32mp_dt.c
+++ b/plat/st/common/stm32mp_dt.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2019, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2017-2020, ARM Limited and Contributors. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
@@ -92,6 +92,7 @@
 	return status;
 }
 
+#if ENABLE_ASSERTIONS
 /*******************************************************************************
  * This function returns the address cells from the node parent.
  * Returns:
@@ -100,7 +101,7 @@
  * - a default value if undefined #address-cells property as per libfdt
  *   implementation.
  ******************************************************************************/
-int fdt_get_node_parent_address_cells(int node)
+static int fdt_get_node_parent_address_cells(int node)
 {
 	int parent;
 
@@ -120,7 +121,7 @@
  * - a default value if undefined #size-cells property as per libfdt
  *   implementation.
  ******************************************************************************/
-int fdt_get_node_parent_size_cells(int node)
+static int fdt_get_node_parent_size_cells(int node)
 {
 	int parent;
 
@@ -131,6 +132,7 @@
 
 	return fdt_size_cells(fdt, parent);
 }
+#endif
 
 /*******************************************************************************
  * This function reads a value of a node property (generic use of fdt
@@ -467,7 +469,7 @@
 	}
 
 	pwr_regulators_node = fdt_subnode_offset(fdt, node, "pwr-regulators");
-	if (node < 0) {
+	if (pwr_regulators_node < 0) {
 		INFO("%s: Cannot read pwr-regulators node in DT\n", __func__);
 		return 0;
 	}