Fix Coverity #343008, Side affect in assertion
authorJustin Chadwell <justin.chadwell@arm.com>
Tue, 23 Jul 2019 08:48:38 +0000 (09:48 +0100)
committerJustin Chadwell <justin.chadwell@arm.com>
Tue, 6 Aug 2019 12:06:03 +0000 (13:06 +0100)
This patch simply splits off the increment of next_xlat into a separate
statement to ensure consistent behaviour if the assert was to ever be
removed.

Change-Id: I827f601ccea55f4da9442048419c9b8cc0c5d22e
Signed-off-by: Justin Chadwell <justin.chadwell@arm.com>
lib/xlat_tables/aarch32/nonlpae_tables.c

index e31f9d8404cf11b5c9ee4e0b468e496c0bf94a50..bd6b152ef4e184506bad748702fdaf75a026d3d7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
- * Copyright (c) 2014-2017, Arm Limited. All rights reserved.
+ * Copyright (c) 2014-2019, Arm Limited. All rights reserved.
  * Copyright (c) 2014, STMicroelectronics International N.V.
  * All rights reserved.
  *
@@ -445,7 +445,8 @@ static mmap_region_t *init_xlation_table_inner(mmap_region_t *mm,
                        } else {
                                xlat_table = (unsigned long)mmu_l2_base +
                                        next_xlat * MMU32B_L2_TABLE_SIZE;
-                               assert(++next_xlat <= MAX_XLAT_TABLES);
+                               next_xlat++;
+                               assert(next_xlat <= MAX_XLAT_TABLES);
                                memset((char *)xlat_table, 0,
                                        MMU32B_L2_TABLE_SIZE);