Base64 decode: simplify local variables (n)
n was used for two different purposes. Give it a different name the second
time. This does not seem to change the generated code when compiling with
optimization for size or performance.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/library/base64.c b/library/base64.c
index edab35e..b7c2d16 100644
--- a/library/base64.c
+++ b/library/base64.c
@@ -202,6 +202,7 @@
size_t i; /* index in source */
size_t n; /* number of digits or trailing = in source */
uint32_t x; /* value accumulator */
+ unsigned accumulated_digits = 0;
unsigned equals = 0;
int spaces_present = 0;
unsigned char *p;
@@ -270,7 +271,7 @@
}
equals = 0;
- for( n = x = 0, p = dst; i > 0; i--, src++ )
+ for( x = 0, p = dst; i > 0; i--, src++ )
{
if( *src == '\r' || *src == '\n' || *src == ' ' )
continue;
@@ -281,9 +282,9 @@
else
x |= dec_value( *src );
- if( ++n == 4 )
+ if( ++accumulated_digits == 4 )
{
- n = 0;
+ accumulated_digits = 0;
*p++ = (unsigned char)( x >> 16 );
if( equals <= 1 ) *p++ = (unsigned char)( x >> 8 );
if( equals <= 0 ) *p++ = (unsigned char)( x );