svn commit: r333463 - head/sys/dev/vt/colors

Jean-Sébastien Pédron dumbbell at FreeBSD.org
Thu May 10 16:41:48 UTC 2018


Author: dumbbell
Date: Thu May 10 16:41:47 2018
New Revision: 333463
URL: https://svnweb.freebsd.org/changeset/base/333463

Log:
  vt(4): Put for() loop outside switch() in vt_generate_cons_palette()
  
  This makes it more logical:
   1. It checks the requested color format
   2. It fills the palette accordingly
  
  Also vt_palette_init() is only called when needed (i.e. when the format
  is `COLOR_FORMAT_RGB`).

Modified:
  head/sys/dev/vt/colors/vt_termcolors.c

Modified: head/sys/dev/vt/colors/vt_termcolors.c
==============================================================================
--- head/sys/dev/vt/colors/vt_termcolors.c	Thu May 10 16:19:41 2018	(r333462)
+++ head/sys/dev/vt/colors/vt_termcolors.c	Thu May 10 16:41:47 2018	(r333463)
@@ -171,21 +171,21 @@ vt_generate_cons_palette(uint32_t *palette, int format
 {
 	int i;
 
-	vt_palette_init();
-
-#define	CF(_f, _i) ((_f ## max * color_def[(_i)]._f / 100) << _f ## offset)
-	for (i = 0; i < NCOLORS; i++) {
-		switch (format) {
-		case COLOR_FORMAT_VGA:
+	switch (format) {
+	case COLOR_FORMAT_VGA:
+		for (i = 0; i < NCOLORS; i++)
 			palette[i] = cons_to_vga_colors[i];
-			break;
-		case COLOR_FORMAT_RGB:
+		break;
+	case COLOR_FORMAT_RGB:
+		vt_palette_init();
+#define	CF(_f, _i) ((_f ## max * color_def[(_i)]._f / 100) << _f ## offset)
+		for (i = 0; i < NCOLORS; i++)
 			palette[i] = CF(r, i) | CF(g, i) | CF(b, i);
-			break;
-		default:
-			return (ENODEV);
-		}
-	}
 #undef	CF
+		break;
+	default:
+		return (ENODEV);
+	}
+
 	return (0);
 }


More information about the svn-src-head mailing list