sanitizer_common: declare vars more locally in VSNPrintf

No point in declaring variables separately before use.

Depends on D107979.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D108015
This commit is contained in:
Dmitry Vyukov 2021-08-13 07:36:56 +02:00
parent 2a63edd64f
commit ef6e1945af
1 changed files with 6 additions and 8 deletions

View File

@ -162,17 +162,15 @@ int VSNPrintf(char *buff, int buff_length,
cur += have_z; cur += have_z;
bool have_ll = !have_z && (cur[0] == 'l' && cur[1] == 'l'); bool have_ll = !have_z && (cur[0] == 'l' && cur[1] == 'l');
cur += have_ll * 2; cur += have_ll * 2;
s64 dval;
u64 uval;
const bool have_length = have_z || have_ll; const bool have_length = have_z || have_ll;
const bool have_flags = have_width || have_length; const bool have_flags = have_width || have_length;
// At the moment only %s supports precision and left-justification. // At the moment only %s supports precision and left-justification.
CHECK(!((precision >= 0 || left_justified) && *cur != 's')); CHECK(!((precision >= 0 || left_justified) && *cur != 's'));
switch (*cur) { switch (*cur) {
case 'd': { case 'd': {
dval = have_ll ? va_arg(args, s64) s64 dval = have_ll ? va_arg(args, s64)
: have_z ? va_arg(args, sptr) : have_z ? va_arg(args, sptr)
: va_arg(args, int); : va_arg(args, int);
result += AppendSignedDecimal(&buff, buff_end, dval, width, result += AppendSignedDecimal(&buff, buff_end, dval, width,
pad_with_zero); pad_with_zero);
break; break;
@ -180,9 +178,9 @@ int VSNPrintf(char *buff, int buff_length,
case 'u': case 'u':
case 'x': case 'x':
case 'X': { case 'X': {
uval = have_ll ? va_arg(args, u64) u64 uval = have_ll ? va_arg(args, u64)
: have_z ? va_arg(args, uptr) : have_z ? va_arg(args, uptr)
: va_arg(args, unsigned); : va_arg(args, unsigned);
bool uppercase = (*cur == 'X'); bool uppercase = (*cur == 'X');
result += AppendUnsigned(&buff, buff_end, uval, (*cur == 'u') ? 10 : 16, result += AppendUnsigned(&buff, buff_end, uval, (*cur == 'u') ? 10 : 16,
width, pad_with_zero, uppercase); width, pad_with_zero, uppercase);