Skip to contentSkip to conversation

compiler: remove unnecessary zero check on Length before zero'ing it

PATCH In review Colin King 2 participants 2 messages Jan 7, 2016 – Feb 17, 2016 ACPI component architecture (acpica)

lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 compiler: remove unnecessary zero check on Length before zero'ing it

From: Colin Ian King <colin.king(a)canonical.com>

Length is being checked to see if the contents is non-zero before setting it to zero. It would be simpler to just set this to zero without doing the non-zero check as it saves a load and a jmp (~14 bytes in x86 object code). This also fixes a static analysis warning in DtCompileIort:

CID 1298707 (#1 of 1): Uninitialized scalar variable (UNINIT).
uninit_use_in_call: Using uninitialized value PaddingLength when calling DtCompileGeneric.

..since the length is not being intitialized in this code before calling DtCompileGeneric.

Signed-off-by Colin Ian King <colin.king(a)canonical.com>
---
 source/compiler/dttable2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
source/compiler/dttable2.c +1 -1
index b281b5c..1add6f7 100644
@@ -1707,7 +1707,7 @@ DtCompileGeneric (
 
     /* Now we can actually compile the parse tree */
 
-    if (Length && *Length)
+    if (Length)
     {
         *Length = 0;
     }
Signature · 1 line
2.7.0.rc3
Acked-by Lv Zheng on v1 1/1
#1 lore raw

Hi,

Quoted 12 lines

From: Devel [mailto:devel-bounces(a)acpica.org] On Behalf Of Colin King
Subject: [Devel] [PATCH] compiler: remove unnecessary zero check on Length before zero'ing it

From: Colin Ian King <colin.king(a)canonical.com>

Length is being checked to see if the contents is non-zero before setting it to zero. It would be simpler to just set this to zero without doing the non-zero check as it saves a load and a jmp (~14 bytes in x86 object code). This also fixes a static analysis warning in DtCompileIort:

Quoted 8 lines

CID 1298707 (#1 of 1): Uninitialized scalar variable (UNINIT).
uninit_use_in_call: Using uninitialized value PaddingLength when calling DtCompileGeneric.

..since the length is not being intitialized in this code before calling DtCompileGeneric.

Signed-off-by Colin Ian King <colin.king(a)canonical.com>
Acked-by Lv Zheng <lv.zheng(a)intel.com>

Thanks
-Lv

Quoted 24 lines
---
 source/compiler/dttable2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
source/compiler/dttable2.c +1 -2
index b281b5c..1add6f7 100644
@@ -1707,7 +1707,7 @@ DtCompileGeneric (
 
     /* Now we can actually compile the parse tree */
 
-    if (Length && *Length)
+    if (Length)
     {
         *Length = 0;
     }
--

2.7.0.rc3

_______________________________________________
Devel mailing list
Devel(a)acpica.org
https://lists.acpica.org/mailman/listinfo/devel