Commit 6d4e751e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

tty: consolemap.c: move assignment out of if () block



We should not be doing assignments within an if () block
so fix up the code to not do this.

change was created using Coccinelle.

CC: Jiri Slaby <jslaby@suse.cz>
CC: Takashi Iwai <tiwai@suse.de>
CC: Imre Deak <imre.deak@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2eeaf0bb
Loading
Loading
Loading
Loading
+37 −23
Original line number Diff line number Diff line
@@ -261,7 +261,9 @@ u16 inverse_translate(struct vc_data *conp, int glyph, int use_unicode)
	int m;
	if (glyph < 0 || glyph >= MAX_GLYPH)
		return 0;
	else if (!(p = *conp->vc_uni_pagedir_loc))
	else {
		p = *conp->vc_uni_pagedir_loc;
		if (!p)
			return glyph;
		else if (use_unicode) {
			if (!p->inverse_trans_unicode)
@@ -276,6 +278,7 @@ u16 inverse_translate(struct vc_data *conp, int glyph, int use_unicode)
				return p->inverse_translations[m][glyph];
			}
	}
}
EXPORT_SYMBOL_GPL(inverse_translate);

static void update_user_maps(void)
@@ -397,7 +400,8 @@ static void con_release_unimap(struct uni_pagedir *p)

	if (p == dflt) dflt = NULL;  
	for (i = 0; i < 32; i++) {
		if ((p1 = p->uni_pgdir[i]) != NULL) {
		p1 = p->uni_pgdir[i];
		if (p1 != NULL) {
			for (j = 0; j < 32; j++)
				kfree(p1[j]);
			kfree(p1);
@@ -473,14 +477,16 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos)
	int i, n;
	u16 **p1, *p2;

	if (!(p1 = p->uni_pgdir[n = unicode >> 11])) {
	p1 = p->uni_pgdir[n = unicode >> 11];
	if (!p1) {
		p1 = p->uni_pgdir[n] = kmalloc(32*sizeof(u16 *), GFP_KERNEL);
		if (!p1) return -ENOMEM;
		for (i = 0; i < 32; i++)
			p1[i] = NULL;
	}

	if (!(p2 = p1[n = (unicode >> 6) & 0x1f])) {
	p2 = p1[n = (unicode >> 6) & 0x1f];
	if (!p2) {
		p2 = p1[n] = kmalloc(64*sizeof(u16), GFP_KERNEL);
		if (!p2) return -ENOMEM;
		memset(p2, 0xff, 64*sizeof(u16)); /* No glyphs for the characters (yet) */
@@ -569,10 +575,12 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
		 * entries from "p" (old) to "q" (new).
		 */
		l = 0;		/* unicode value */
		for (i = 0; i < 32; i++)
		if ((p1 = p->uni_pgdir[i]))
			for (j = 0; j < 32; j++)
			if ((p2 = p1[j])) {
		for (i = 0; i < 32; i++) {
		p1 = p->uni_pgdir[i];
		if (p1)
			for (j = 0; j < 32; j++) {
			p2 = p1[j];
			if (p2) {
				for (k = 0; k < 64; k++, l++)
				if (p2[k] != 0xffff) {
					/*
@@ -593,9 +601,11 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list)
				/* Account for row of 64 empty entries */
				l += 64;
			}
		}
		else
			/* Account for empty table */
			l += 32 * 64;
		}

		/*
		 * Finished copying font table, set vc_uni_pagedir to new table
@@ -735,10 +745,12 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni
	ect = 0;
	if (*vc->vc_uni_pagedir_loc) {
		p = *vc->vc_uni_pagedir_loc;
		for (i = 0; i < 32; i++)
		if ((p1 = p->uni_pgdir[i]))
			for (j = 0; j < 32; j++)
			if ((p2 = *(p1++)))
		for (i = 0; i < 32; i++) {
		p1 = p->uni_pgdir[i];
		if (p1)
			for (j = 0; j < 32; j++) {
			p2 = *(p1++);
			if (p2)
				for (k = 0; k < 64; k++) {
					if (*p2 < MAX_GLYPH && ect++ < ct) {
						__put_user((u_short)((i<<11)+(j<<6)+k),
@@ -750,6 +762,8 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct, struct uni
					p2++;
				}
			}
		}
	}
	__put_user(ect, uct);
	console_unlock();
	return ((ect <= ct) ? 0 : -ENOMEM);