[kbd] [PATCH] Remove dependency on <linux/types.h> by writing out u_char and u_short

Felix Janda felix.janda at posteo.de
Wed May 6 22:37:57 MSK 2015


---
 src/dumpkeys.c             |  1 -
 src/kbd_mode.c             |  1 -
 src/libkeymap/dump.c       |  8 +++-----
 src/libkeymap/kmap.c       |  7 +++----
 src/libkeymap/summary.c    |  3 +--
 tests/dumpkeys.defkeymap.c | 33 ++++++++++++++++-----------------
 6 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/src/dumpkeys.c b/src/dumpkeys.c
index 736ca35..6762921 100644
--- a/src/dumpkeys.c
+++ b/src/dumpkeys.c
@@ -9,7 +9,6 @@
 #include <fcntl.h>
 #include <getopt.h>
 #include <unistd.h>
-#include <linux/types.h>
 #include <linux/kd.h>
 #include <linux/keyboard.h>
 #include <sys/ioctl.h>
diff --git a/src/kbd_mode.c b/src/kbd_mode.c
index b14e307..b45ffdf 100644
--- a/src/kbd_mode.c
+++ b/src/kbd_mode.c
@@ -11,7 +11,6 @@
 #include <errno.h>
 #include <unistd.h>
 #include <sys/ioctl.h>
-#include <linux/types.h>
 #include <linux/kd.h>
 #include "getfd.h"
 #include "nls.h"
diff --git a/src/libkeymap/dump.c b/src/libkeymap/dump.c
index 606931e..f1ecbc6 100644
--- a/src/libkeymap/dump.c
+++ b/src/libkeymap/dump.c
@@ -13,7 +13,6 @@
 #include <string.h>
 #include <ctype.h>
 #include <unistd.h>
-#include <sys/types.h>
 
 #include "keymap.h"
 
@@ -70,7 +69,7 @@ lk_dump_bkeymap(struct lk_ctx *ctx, FILE *fd)
 			continue;
 
 		for (j = 0; j < NR_KEYS / 2; j++) {
-			u_short v;
+			unsigned short v;
 			v = lk_get_key(ctx, i, j);
 
 			if (fwrite(&v, sizeof(v), 1, fd) != 1)
@@ -123,7 +122,6 @@ lk_dump_ctable(struct lk_ctx *ctx, FILE *fd)
 /* not to be translated... */
 		    "/* Do not edit this file! It was automatically generated by   */\n");
 	fprintf(fd, "/*    loadkeys --mktable defkeymap.map > defkeymap.c          */\n\n");
-	fprintf(fd, "#include <linux/types.h>\n");
 	fprintf(fd, "#include <linux/keyboard.h>\n");
 	fprintf(fd, "#include <linux/kd.h>\n\n");
 
@@ -131,7 +129,7 @@ lk_dump_ctable(struct lk_ctx *ctx, FILE *fd)
 		if (lk_map_exists(ctx, i)) {
 			if (i)
 				fprintf(fd, "static ");
-			fprintf(fd, "u_short %s_map[NR_KEYS] = {", mk_mapname(i));
+			fprintf(fd, "unsigned short %s_map[NR_KEYS] = {", mk_mapname(i));
 			for (j = 0; j < NR_KEYS; j++) {
 				if (!(j % 8))
 					fprintf(fd, "\n");
@@ -490,7 +488,7 @@ no_shorthands:
 
 		isasexpected = 0;
 		if (isletter) {
-			u_short defs[16];
+			unsigned short defs[16];
 			defs[0] = K(KT_LETTER, val);
 			defs[1] = K(KT_LETTER, val ^ 32);
 			defs[2] = defs[0];
diff --git a/src/libkeymap/kmap.c b/src/libkeymap/kmap.c
index e13498b..8b90654 100644
--- a/src/libkeymap/kmap.c
+++ b/src/libkeymap/kmap.c
@@ -1,6 +1,5 @@
 #include <stdlib.h>
 #include <string.h>
-#include <sys/types.h>
 
 #include "nls.h"
 #include "kbd.h"
@@ -174,7 +173,7 @@ lk_add_key(struct lk_ctx *ctx, unsigned int k_table, unsigned int k_index, int k
 }
 
 static int
-do_constant_key(struct lk_ctx *ctx, int i, u_short key)
+do_constant_key(struct lk_ctx *ctx, int i, unsigned short key)
 {
 	int typ, val;
 	unsigned int j;
@@ -184,7 +183,7 @@ do_constant_key(struct lk_ctx *ctx, int i, u_short key)
 
 	if ((typ == KT_LATIN || typ == KT_LETTER) &&
 	    ((val >= 'a' && val <= 'z') || (val >= 'A' && val <= 'Z'))) {
-		u_short defs[16];
+		unsigned short defs[16];
 		defs[0] = K(KT_LETTER, val);
 		defs[1] = K(KT_LETTER, val ^ 32);
 		defs[2] = defs[0];
@@ -236,7 +235,7 @@ lk_add_constants(struct lk_ctx *ctx)
 
 	for (i = 0; i < ctx->key_constant->total; i++) {
 		char *constant;
-		u_short key;
+		unsigned short key;
 
 		constant = lk_array_get(ctx->key_constant, i);
 		if (!constant || !(*constant))
diff --git a/src/libkeymap/summary.c b/src/libkeymap/summary.c
index 0912ae8..44d4e5f 100644
--- a/src/libkeymap/summary.c
+++ b/src/libkeymap/summary.c
@@ -9,7 +9,6 @@
 #include <string.h>
 #include <errno.h>
 #include <sys/ioctl.h>
-#include <sys/types.h>
 
 #include "keymap.h"
 
@@ -31,7 +30,7 @@ valid_type(int fd, int t)
 	return (ioctl(fd, KDSKBENT, (unsigned long) &ke) == 0);
 }
 
-static u_char
+static unsigned char
 maximum_val(int fd, int t)
 {
 	struct kbentry ke, ke0;
diff --git a/tests/dumpkeys.defkeymap.c b/tests/dumpkeys.defkeymap.c
index 58b340f..5d9a3aa 100644
--- a/tests/dumpkeys.defkeymap.c
+++ b/tests/dumpkeys.defkeymap.c
@@ -1,11 +1,10 @@
 /* Do not edit this file! It was automatically generated by   */
 /*    loadkeys --mktable defkeymap.map > defkeymap.c          */
 
-#include <linux/types.h>
 #include <linux/keyboard.h>
 #include <linux/kd.h>
 
-u_short plain_map[NR_KEYS] = {
+unsigned short plain_map[NR_KEYS] = {
 	0xf200,	0xf01b,	0xf031,	0xf032,	0xf033,	0xf034,	0xf035,	0xf036,
 	0xf037,	0xf038,	0xf039,	0xf030,	0xf02d,	0xf03d,	0xf07f,	0xf009,
 	0xfb71,	0xfb77,	0xfb65,	0xfb72,	0xfb74,	0xfb79,	0xfb75,	0xfb69,
@@ -40,7 +39,7 @@ u_short plain_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short shift_map[NR_KEYS] = {
+static unsigned short shift_map[NR_KEYS] = {
 	0xf200,	0xf01b,	0xf021,	0xf040,	0xf023,	0xf024,	0xf025,	0xf05e,
 	0xf026,	0xf02a,	0xf028,	0xf029,	0xf05f,	0xf02b,	0xf07f,	0xf809,
 	0xfb51,	0xfb57,	0xfb45,	0xfb52,	0xfb54,	0xfb59,	0xfb55,	0xfb49,
@@ -75,7 +74,7 @@ static u_short shift_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short altgr_map[NR_KEYS] = {
+static unsigned short altgr_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf040,	0xf200,	0xf024,	0xf200,	0xf200,
 	0xf07b,	0xf05b,	0xf05d,	0xf07d,	0xf05c,	0xf200,	0xf200,	0xf200,
 	0xfb71,	0xfb77,	0xfb65,	0xfb72,	0xfb74,	0xfb79,	0xfb75,	0xfb69,
@@ -110,7 +109,7 @@ static u_short altgr_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short shift_altgr_map[NR_KEYS] = {
+static unsigned short shift_altgr_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xfb51,	0xfb57,	0xfb45,	0xfb52,	0xfb54,	0xfb59,	0xfb55,	0xfb49,
@@ -145,7 +144,7 @@ static u_short shift_altgr_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short ctrl_map[NR_KEYS] = {
+static unsigned short ctrl_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf000,	0xf01b,	0xf01c,	0xf01d,	0xf01e,
 	0xf01f,	0xf07f,	0xf200,	0xf200,	0xf01f,	0xf200,	0xf008,	0xf200,
 	0xf011,	0xf017,	0xf005,	0xf012,	0xf014,	0xf019,	0xf015,	0xf009,
@@ -180,7 +179,7 @@ static u_short ctrl_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short shift_ctrl_map[NR_KEYS] = {
+static unsigned short shift_ctrl_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf000,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf01f,	0xf200,	0xf200,	0xf200,
 	0xf011,	0xf017,	0xf005,	0xf012,	0xf014,	0xf019,	0xf015,	0xf009,
@@ -215,7 +214,7 @@ static u_short shift_ctrl_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short altgr_ctrl_map[NR_KEYS] = {
+static unsigned short altgr_ctrl_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf011,	0xf017,	0xf005,	0xf012,	0xf014,	0xf019,	0xf015,	0xf009,
@@ -250,7 +249,7 @@ static u_short altgr_ctrl_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short shift_altgr_ctrl_map[NR_KEYS] = {
+static unsigned short shift_altgr_ctrl_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf011,	0xf017,	0xf005,	0xf012,	0xf014,	0xf019,	0xf015,	0xf009,
@@ -285,7 +284,7 @@ static u_short shift_altgr_ctrl_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short alt_map[NR_KEYS] = {
+static unsigned short alt_map[NR_KEYS] = {
 	0xf200,	0xf81b,	0xf831,	0xf832,	0xf833,	0xf834,	0xf835,	0xf836,
 	0xf837,	0xf838,	0xf839,	0xf830,	0xf82d,	0xf83d,	0xf87f,	0xf809,
 	0xf871,	0xf877,	0xf865,	0xf872,	0xf874,	0xf879,	0xf875,	0xf869,
@@ -320,7 +319,7 @@ static u_short alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short shift_alt_map[NR_KEYS] = {
+static unsigned short shift_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf821,	0xf840,	0xf823,	0xf824,	0xf825,	0xf85e,
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf851,	0xf857,	0xf845,	0xf852,	0xf854,	0xf859,	0xf855,	0xf849,
@@ -355,7 +354,7 @@ static u_short shift_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short altgr_alt_map[NR_KEYS] = {
+static unsigned short altgr_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf871,	0xf877,	0xf865,	0xf872,	0xf874,	0xf879,	0xf875,	0xf869,
@@ -390,7 +389,7 @@ static u_short altgr_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short shift_altgr_alt_map[NR_KEYS] = {
+static unsigned short shift_altgr_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf851,	0xf857,	0xf845,	0xf852,	0xf854,	0xf859,	0xf855,	0xf849,
@@ -425,7 +424,7 @@ static u_short shift_altgr_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short ctrl_alt_map[NR_KEYS] = {
+static unsigned short ctrl_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf811,	0xf817,	0xf805,	0xf812,	0xf814,	0xf819,	0xf815,	0xf809,
@@ -460,7 +459,7 @@ static u_short ctrl_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short shift_ctrl_alt_map[NR_KEYS] = {
+static unsigned short shift_ctrl_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf811,	0xf817,	0xf805,	0xf812,	0xf814,	0xf819,	0xf815,	0xf809,
@@ -495,7 +494,7 @@ static u_short shift_ctrl_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short altgr_ctrl_alt_map[NR_KEYS] = {
+static unsigned short altgr_ctrl_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf811,	0xf817,	0xf805,	0xf812,	0xf814,	0xf819,	0xf815,	0xf809,
@@ -530,7 +529,7 @@ static u_short altgr_ctrl_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 };
 
-static u_short shift_altgr_ctrl_alt_map[NR_KEYS] = {
+static unsigned short shift_altgr_ctrl_alt_map[NR_KEYS] = {
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,	0xf200,
 	0xf811,	0xf817,	0xf805,	0xf812,	0xf814,	0xf819,	0xf815,	0xf809,
-- 
2.3.6


More information about the kbd mailing list