Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fat: clean up xlate_to_uni()

xlate_to_uni() is called by vfat_build_slots() with sbi->nls_io as the
final argument. nls_io can never be null at this point because the
check is already being done in fat_fill_super() wherein the mount fails
if it is null.

Signed-off-by: Namjae Jeon <linkinjeon@gmail.com>
Signed-off-by: Ravishankar N <cyberax82@gmail.com>
Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Namjae Jeon and committed by
Linus Torvalds
41f0c02e 9eab0a78

+36 -47
+36 -47
fs/fat/namei_vfat.c
··· 521 521 522 522 op = &outname[*outlen * sizeof(wchar_t)]; 523 523 } else { 524 - if (nls) { 525 - for (i = 0, ip = name, op = outname, *outlen = 0; 526 - i < len && *outlen <= FAT_LFN_LEN; 527 - *outlen += 1) 528 - { 529 - if (escape && (*ip == ':')) { 530 - if (i > len - 5) 531 - return -EINVAL; 532 - ec = 0; 533 - for (k = 1; k < 5; k++) { 534 - nc = ip[k]; 535 - ec <<= 4; 536 - if (nc >= '0' && nc <= '9') { 537 - ec |= nc - '0'; 538 - continue; 539 - } 540 - if (nc >= 'a' && nc <= 'f') { 541 - ec |= nc - ('a' - 10); 542 - continue; 543 - } 544 - if (nc >= 'A' && nc <= 'F') { 545 - ec |= nc - ('A' - 10); 546 - continue; 547 - } 548 - return -EINVAL; 524 + for (i = 0, ip = name, op = outname, *outlen = 0; 525 + i < len && *outlen <= FAT_LFN_LEN; 526 + *outlen += 1) { 527 + if (escape && (*ip == ':')) { 528 + if (i > len - 5) 529 + return -EINVAL; 530 + ec = 0; 531 + for (k = 1; k < 5; k++) { 532 + nc = ip[k]; 533 + ec <<= 4; 534 + if (nc >= '0' && nc <= '9') { 535 + ec |= nc - '0'; 536 + continue; 549 537 } 550 - *op++ = ec & 0xFF; 551 - *op++ = ec >> 8; 552 - ip += 5; 553 - i += 5; 554 - } else { 555 - if ((charlen = nls->char2uni(ip, len - i, (wchar_t *)op)) < 0) 556 - return -EINVAL; 557 - ip += charlen; 558 - i += charlen; 559 - op += 2; 538 + if (nc >= 'a' && nc <= 'f') { 539 + ec |= nc - ('a' - 10); 540 + continue; 541 + } 542 + if (nc >= 'A' && nc <= 'F') { 543 + ec |= nc - ('A' - 10); 544 + continue; 545 + } 546 + return -EINVAL; 560 547 } 548 + *op++ = ec & 0xFF; 549 + *op++ = ec >> 8; 550 + ip += 5; 551 + i += 5; 552 + } else { 553 + charlen = nls->char2uni(ip, len - i, 554 + (wchar_t *)op); 555 + if (charlen < 0) 556 + return -EINVAL; 557 + ip += charlen; 558 + i += charlen; 559 + op += 2; 561 560 } 562 - if (i < len) 563 - return -ENAMETOOLONG; 564 - } else { 565 - for (i = 0, ip = name, op = outname, *outlen = 0; 566 - i < len && *outlen <= FAT_LFN_LEN; 567 - i++, *outlen += 1) 568 - { 569 - *op++ = *ip++; 570 - *op++ = 0; 571 - } 572 - if (i < len) 573 - return -ENAMETOOLONG; 574 561 } 562 + if (i < len) 563 + return -ENAMETOOLONG; 575 564 } 576 565 577 566 *longlen = *outlen;