fs/udf: re-use hex_asc_upper_{hi,lo} macros
PATCH 1/1 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 <[email protected]>
--- fs/udf/unicode.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
fs/udf/unicode.c +4 -5
@@ -412,7 +412,6 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName,int extIndex =0 , newExtIndex =0 , hasExt =0 ;unsigned short valueCRC;uint8_t curr; -const uint8_t hexChar[] ="0123456789ABCDEF" ;if (udfName[0 ] =='.' && (udfLen ==1 || (udfLen ==2 && udfName[1 ] =='.' ))) {
@@ -477,10 +476,10 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, newIndex =250 ; newName[newIndex++] =CRC_MARK ; valueCRC =crc_itu_t (0 , fidName, fidNameLen); - newName[newIndex++] = hexChar[(valueCRC &0xf000 ) >>12 ]; - newName[newIndex++] = hexChar[(valueCRC &0x0f00 ) >>8 ]; - newName[newIndex++] = hexChar[(valueCRC &0x00f0 ) >>4 ]; - newName[newIndex++] = hexChar[(valueCRC &0x000f )]; + newName[newIndex++] =hex_asc_upper_hi (valueCRC >>8 ); + newName[newIndex++] =hex_asc_upper_lo (valueCRC >>8 ); + newName[newIndex++] =hex_asc_upper_hi (valueCRC); + newName[newIndex++] =hex_asc_upper_lo (valueCRC);if (hasExt) { newName[newIndex++] =EXT_MARK ;
Signature · 1 line
2.0.1
Quoted 6 lines · Andy Shevchenko
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 <[email protected]>
Thanks. I've merged the patch.
Honza
Quoted 34 lines
--- fs/udf/unicode.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)fs/udf/unicode.c +4
-5@@ -412,7 +412,6 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName,int extIndex =0 , newExtIndex =0 , hasExt =0 ;unsigned short valueCRC;uint8_t curr; -const uint8_t hexChar[] ="0123456789ABCDEF" ;if (udfName[0 ] =='.' && (udfLen ==1 || (udfLen ==2 && udfName[1 ] =='.' ))) {@@ -477,10 +476,10 @@ static int udf_translate_to_linux(uint8_t *newName, uint8_t *udfName, newIndex =250 ; newName[newIndex++] =CRC_MARK ; valueCRC =crc_itu_t (0 , fidName, fidNameLen); - newName[newIndex++] = hexChar[(valueCRC &0xf000 ) >>12 ]; - newName[newIndex++] = hexChar[(valueCRC &0x0f00 ) >>8 ]; - newName[newIndex++] = hexChar[(valueCRC &0x00f0 ) >>4 ]; - newName[newIndex++] = hexChar[(valueCRC &0x000f )]; + newName[newIndex++] =hex_asc_upper_hi (valueCRC >>8 ); + newName[newIndex++] =hex_asc_upper_lo (valueCRC >>8 ); + newName[newIndex++] =hex_asc_upper_hi (valueCRC); + newName[newIndex++] =hex_asc_upper_lo (valueCRC);if (hasExt) { newName[newIndex++] =EXT_MARK ;Signature · 1 line
2.0.1
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR