[tor-commits] [trunnel/master] Stop emitting needless loops over fixed arrays of uint8_t

nickm at torproject.org nickm at torproject.org
Fri Sep 26 13:06:13 UTC 2014


commit e4be3b4e1acd223f63add4b02d0072852cd620e7
Author: Nick Mathewson <nickm at torproject.org>
Date:   Fri Sep 26 08:59:05 2014 -0400

    Stop emitting needless loops over fixed arrays of uint8_t
    
    Coverity says this code is stupid:
    
          for (idx = 0; idx < 32; ++idx)
            obj->hmac[idx] = (obj->hmac[idx]);
    
    And it's right!  So let's stop generating it.
    
    Should fix Tor CID 1241499
---
 lib/trunnel/CodeGen.py |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/trunnel/CodeGen.py b/lib/trunnel/CodeGen.py
index 9d91394..392783b 100644
--- a/lib/trunnel/CodeGen.py
+++ b/lib/trunnel/CodeGen.py
@@ -2468,7 +2468,7 @@ class ParseFnGenerator(CodeGenerator):
                         memcpy(obj->{c_name}, ptr, {multiplier}{width});
                         """, c_name=sfa.c_name, multiplier=multiplier,
                         width=sfa.width, truncated=self.truncatedLabel)
-            if type(sfa.basetype) == trunnel.Grammar.IntType:
+            if type(sfa.basetype) == trunnel.Grammar.IntType and sfa.basetype.width > 8:
                 self.format("""
                          {{
                            unsigned idx;



More information about the tor-commits mailing list