Re: [PATCH 5/5] hfsplus: assignments inside `if' condition clean-up

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

 



On 2010-12-16, at 09:08, Anton Salikhmetov wrote:
> Make assignments outside `if' conditions for unicode.c module
> where the checkpatch.pl script reported this coding style error.

Patches to do _only_ style cleanups are generally frowned upon.  However, assignments in conditionals are potentially bug-inducing (either now, or if the code is modified in the future when the developer sees "==" when it actually has "="), so this patch is probably worthwhile.

> Signed-off-by: Anton Salikhmetov <alexo@xxxxxxxxxx>
> ---
> fs/hfsplus/unicode.c |   35 +++++++++++++++++++++++++++--------
> 1 files changed, 27 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/hfsplus/unicode.c b/fs/hfsplus/unicode.c
> index 7dd90a5..225837a 100644
> --- a/fs/hfsplus/unicode.c
> +++ b/fs/hfsplus/unicode.c
> @@ -142,7 +142,11 @@ int hfsplus_uni2asc(struct super_block *sb,
> 		/* search for single decomposed char */
> 		if (likely(compose))
> 			ce1 = hfsplus_compose_lookup(hfsplus_compose_table, c0);
> -		if (ce1 && (cc = ce1[0])) {
> +		if (ce1)
> +			cc = ce1[0];
> +		else
> +			cc = 0;
> +		if (cc) {
> 			/* start of a possibly decomposed Hangul char */
> 			if (cc != 0xffff)
> 				goto done;
> @@ -209,7 +213,8 @@ int hfsplus_uni2asc(struct super_block *sb,
> 				i++;
> 				ce2 = ce1;
> 			}
> -			if ((cc = ce2[0])) {
> +			cc = ce2[0];
> +			if (cc) {
> 				ip += i;
> 				ustrlen -= i;
> 				goto done;
> @@ -301,7 +306,11 @@ int hfsplus_asc2uni(struct super_block *sb, struct hfsplus_unistr *ustr,
> 	while (outlen < HFSPLUS_MAX_STRLEN && len > 0) {
> 		size = asc2unichar(sb, astr, len, &c);
> 
> -		if (decompose && (dstr = decompose_unichar(c, &dsize))) {
> +		if (decompose)
> +			dstr = decompose_unichar(c, &dsize);
> +		else
> +			dstr = NULL;
> +		if (dstr) {
> 			if (outlen + dsize > HFSPLUS_MAX_STRLEN)
> 				break;
> 			do {
> @@ -345,15 +354,23 @@ int hfsplus_hash_dentry(struct dentry *dentry, struct qstr *str)
> 		astr += size;
> 		len -= size;
> 
> -		if (decompose && (dstr = decompose_unichar(c, &dsize))) {
> +		if (decompose)
> +			dstr = decompose_unichar(c, &dsize);
> +		else
> +			dstr = NULL;
> +		if (dstr) {
> 			do {
> 				c2 = *dstr++;
> -				if (!casefold || (c2 = case_fold(c2)))
> +				if (casefold)
> +					c2 = case_fold(c2);
> +				if (!casefold || c2)
> 					hash = partial_name_hash(c2, hash);
> 			} while (--dsize > 0);
> 		} else {
> 			c2 = c;
> -			if (!casefold || (c2 = case_fold(c2)))
> +			if (casefold)
> +				c2 = case_fold(c2);
> +			if (!casefold || c2)
> 				hash = partial_name_hash(c2, hash);
> 		}
> 	}
> @@ -419,12 +436,14 @@ int hfsplus_compare_dentry(struct dentry *dentry,
> 		c1 = *dstr1;
> 		c2 = *dstr2;
> 		if (casefold) {
> -			if  (!(c1 = case_fold(c1))) {
> +			c1 = case_fold(c1);
> +			if (!c1) {
> 				dstr1++;
> 				dsize1--;
> 				continue;
> 			}
> -			if (!(c2 = case_fold(c2))) {
> +			c2 = case_fold(c2);
> +			if (!c2) {
> 				dstr2++;
> 				dsize2--;
> 				continue;
> -- 
> 1.7.2.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


Cheers, Andreas





--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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