Re: [PATCH v3 02/10] fs/ntfs3: Add initialization of super block

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Konstantin!

On Friday 28 August 2020 07:39:30 Konstantin Komarov wrote:
> +	if (nls_name[0]) {
> +		sbi->nls = load_nls(nls_name);
> +		if (!sbi->nls) {
> +			ntfs_printk(sb, KERN_ERR "failed to load \"%s\"",
> +				    nls_name);
> +			return -EINVAL;
> +		}
> +	} else {
> +		sbi->nls = load_nls_default();
> +		if (!sbi->nls) {
> +			ntfs_printk(sb, KERN_ERR "failed to load default nls");
> +			return -EINVAL;
> +		}
> +	}
> +
> +	if (!strcmp(sbi->nls->charset, "utf8")) {
> +		/*use utf16s_to_utf8s/utf8s_to_utf16s instead of nls*/
> +		unload_nls(sbi->nls);
> +		sbi->nls = NULL;
> +	}

You can slightly simplify this code to omit calling load_nls() for UTF-8. E.g.:

    if (strcmp(nls_name[0] ? nls_name : CONFIG_NLS_DEFAULT, "utf8") == 0) {
        /* For UTF-8 use utf16s_to_utf8s/utf8s_to_utf16s instead of nls */
        sbi->nls = NULL;
    } else if (nls_name) {
        sbi->nls = load_nls(nls_name);
        if (!sbi->nls) {
            /* handle error */
        }
    } else {
        sbi->nls = load_nls_default();
        if (!sbi->nls) {
            /* handle error */
        }
    }



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux