Current-Users archive

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

rasops15 byte order bug



Anyone using a 15/16 bit rasops console without issues?  I think there is
a byte order error in rasops15.c .

This patch worked for me, wondering if anyone else can confirm the error
and/or verify this fix.

Thanks

Summary of changes:  (A/? = New, R/D = Removed, M = Modified)
=============================================================
M rasops15.c

Apply patch with "cd .../src/sys/dev/rasops ; patch -s -p0 < .../patchfile"

Index: rasops15.c
===================================================================
RCS file: /cvsroot/src/sys/dev/rasops/rasops15.c,v
retrieving revision 1.20
diff -b -u -r1.20 rasops15.c
--- rasops15.c	17 Apr 2012 12:06:25 -0000	1.20
+++ rasops15.c	14 Sep 2016 20:31:52 -0000
@@ -217,17 +217,26 @@
 	bg = ri->ri_devcmap[((u_int)attr >> 16) & 0xf] & 0xffff;
 	stamp_attr = attr;
 
+	/*
+	 * XXX - someone should sanity check but think this was doing
+	 *   stamp[i] = 8|16, stamp[i+1] = 2|4 (little endian)
+	 *   stamp[i] = 4|2, stamp[i+1] = 16|8 (big endian)
+	 * where should be
+	 *   stamp[i] = 2|4, stamp[i+1] = 8|16 (little endian)
+	 *   stamp[i] = 16|8, stamp[i+1] = 4|2 (big endian)
+	 */
 	for (i = 0; i < 32; i += 2) {
 #if BYTE_ORDER == LITTLE_ENDIAN
-		stamp[i] = (i & 16 ? fg : bg);
-		stamp[i] |= ((i & 8 ? fg : bg) << 16);
-		stamp[i + 1] = (i & 4 ? fg : bg);
-		stamp[i + 1] |= ((i & 2 ? fg : bg) << 16);
+            stamp[i] = (i & 4 ? fg : bg);
+            stamp[i] |= ((i & 2 ? fg : bg) << 16);
+            stamp[i + 1] = (i & 16 ? fg : bg);
+            stamp[i + 1] |= ((i & 8 ? fg : bg) << 16);
+
 #else
-		stamp[i] = (i & 2 ? fg : bg);
-		stamp[i] |= ((i & 4 ? fg : bg) << 16);
-		stamp[i + 1] = (i & 8 ? fg : bg);
-		stamp[i + 1] |= ((i & 16 ? fg : bg) << 16);
+            stamp[i] = (i & 8 ? fg : bg);
+            stamp[i] |= ((i & 16 ? fg : bg) << 16);
+            stamp[i + 1] = (i & 2 ? fg : bg);
+            stamp[i + 1] |= ((i & 4 ? fg : bg) << 16);
 #endif
 	}
 }


Home | Main Index | Thread Index | Old Index