Skip to content

Commit c7ff482

Browse files
andy-shevjankara
authored andcommitted
fs/udf: re-use hex_asc_upper_{hi,lo} macros
This patch cleans up udf_translate_to_linux() a bit by using globally defined macros instead of custom code. We can use sprintf(buf, "%04X", ...) there as well, but this one faster. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jan Kara <jack@suse.cz>
1 parent 2c15ac5 commit c7ff482

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎fs/udf/unicode.c‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName,
412412
int extIndex = 0, newExtIndex = 0, hasExt = 0;
413413
unsigned short valueCRC;
414414
uint8_t curr;
415-
const uint8_t hexChar[] = "0123456789ABCDEF";
416415

417416
if (udfName[0] == '.' &&
418417
(udfLen == 1 || (udfLen == 2 && udfName[1] == '.'))) {
@@ -477,10 +476,10 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName,
477476
newIndex = 250;
478477
newName[newIndex++] = CRC_MARK;
479478
valueCRC = crc_itu_t(0, fidName, fidNameLen);
480-
newName[newIndex++] = hexChar[(valueCRC & 0xf000) >> 12];
481-
newName[newIndex++] = hexChar[(valueCRC & 0x0f00) >> 8];
482-
newName[newIndex++] = hexChar[(valueCRC & 0x00f0) >> 4];
483-
newName[newIndex++] = hexChar[(valueCRC & 0x000f)];
479+
newName[newIndex++] = hex_asc_upper_hi(valueCRC >> 8);
480+
newName[newIndex++] = hex_asc_upper_lo(valueCRC >> 8);
481+
newName[newIndex++] = hex_asc_upper_hi(valueCRC);
482+
newName[newIndex++] = hex_asc_upper_lo(valueCRC);
484483

485484
if (hasExt) {
486485
newName[newIndex++] = EXT_MARK;

0 commit comments

Comments
 (0)