xlat: add XLAT_STYLE_FMT_O for octal output

* xlat.h (enum xlat_style): Add XLAT_STYLE_FMT_O.
* xlat.c (sprint_xlat_val): Handle XLAT_STYLE_FMT_O, reorder switch
branches in accordance with enum constant order.
This commit is contained in:
Eugene Syromyatnikov 2018-10-07 14:13:20 +02:00
parent 6a44f46c7c
commit 2a905d1b00
2 changed files with 9 additions and 4 deletions

12
xlat.c
View File

@ -48,16 +48,20 @@ sprint_xlat_val(uint64_t val, enum xlat_style style)
static char buf[sizeof(val) * 3];
switch (xlat_format(style)) {
case XLAT_STYLE_FMT_D:
xsprintf(buf, "%" PRId64, val);
case XLAT_STYLE_FMT_X:
xsprintf(buf, "%#" PRIx64, val);
break;
case XLAT_STYLE_FMT_U:
xsprintf(buf, "%" PRIu64, val);
break;
case XLAT_STYLE_FMT_X:
xsprintf(buf, "%#" PRIx64, val);
case XLAT_STYLE_FMT_D:
xsprintf(buf, "%" PRId64, val);
break;
case XLAT_STYLE_FMT_O:
xsprintf(buf, "%#" PRIo64, val);
break;
}

1
xlat.h
View File

@ -34,6 +34,7 @@ enum xlat_style {
XLAT_STYLE_FMT_X = 0 << XLAT_STYLE_FORMAT_SHIFT,
XLAT_STYLE_FMT_U = 1 << XLAT_STYLE_FORMAT_SHIFT,
XLAT_STYLE_FMT_D = 2 << XLAT_STYLE_FORMAT_SHIFT,
XLAT_STYLE_FMT_O = 3 << XLAT_STYLE_FORMAT_SHIFT,
#define XLAT_STYLE_FORMAT_MASK (3 << XLAT_STYLE_FORMAT_SHIFT)