mirror of
https://github.com/espressif/mbedtls.git
synced 2025-05-09 19:31:18 +08:00
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>
This commit is contained in:
parent
66884e6dae
commit
67468e81a6
@ -171,6 +171,7 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen,
|
|||||||
size_t i; /* index in source */
|
size_t i; /* index in source */
|
||||||
size_t n; /* number of digits or trailing = in source */
|
size_t n; /* number of digits or trailing = in source */
|
||||||
uint32_t x; /* value accumulator */
|
uint32_t x; /* value accumulator */
|
||||||
|
unsigned accumulated_digits = 0;
|
||||||
unsigned equals = 0;
|
unsigned equals = 0;
|
||||||
int spaces_present = 0;
|
int spaces_present = 0;
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
@ -239,7 +240,7 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen,
|
|||||||
}
|
}
|
||||||
|
|
||||||
equals = 0;
|
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 == ' ' )
|
if( *src == '\r' || *src == '\n' || *src == ' ' )
|
||||||
continue;
|
continue;
|
||||||
@ -250,9 +251,9 @@ int mbedtls_base64_decode( unsigned char *dst, size_t dlen, size_t *olen,
|
|||||||
else
|
else
|
||||||
x |= dec_value( *src );
|
x |= dec_value( *src );
|
||||||
|
|
||||||
if( ++n == 4 )
|
if( ++accumulated_digits == 4 )
|
||||||
{
|
{
|
||||||
n = 0;
|
accumulated_digits = 0;
|
||||||
*p++ = MBEDTLS_BYTE_2( x );
|
*p++ = MBEDTLS_BYTE_2( x );
|
||||||
if( equals <= 1 ) *p++ = MBEDTLS_BYTE_1( x );
|
if( equals <= 1 ) *p++ = MBEDTLS_BYTE_1( x );
|
||||||
if( equals <= 0 ) *p++ = MBEDTLS_BYTE_0( x );
|
if( equals <= 0 ) *p++ = MBEDTLS_BYTE_0( x );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user