Fix implicit function declaration

Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
diff --git a/src/dumpkeys.c b/src/dumpkeys.c
index 50b3e9e..9ae8851 100644
--- a/src/dumpkeys.c
+++ b/src/dumpkeys.c
@@ -21,6 +21,7 @@
 #include "modifiers.h"
 #include "nls.h"
 #include "version.h"
+#include "kbd_error.h"
 
 static int fd;
 
diff --git a/src/loadkeys.c b/src/loadkeys.c
index ef504e7..8b4f3b5 100644
--- a/src/loadkeys.c
+++ b/src/loadkeys.c
@@ -22,6 +22,7 @@
 #include "kbd.h"
 #include "paths.h"
 #include "getfd.h"
+#include "kbd_error.h"
 
 #include "keymap.h"
 
@@ -101,7 +102,7 @@
 	lk_flags flags = 0;
 
 	int c, i, rc = -1;
-	int fd;
+	int fd = -1;
 	int kbd_mode;
 	int kd_mode;
 	char *console = NULL;
@@ -174,7 +175,7 @@
 
 	if (!(options & OPT_M) && !(options & OPT_B)) {
 		/* get console */
-		if ((fd = getfd(NULL)) < 0)
+		if ((fd = getfd(console)) < 0)
 			kbd_error(EXIT_FAILURE, 0, _("Couldn't get a file descriptor referring to the console"));
 
 		/* check whether the keyboard is in Unicode mode */
@@ -260,7 +261,9 @@
 fail:
 	lk_free(ctx);
 	lk_fpclose(&f);
-	close(fd);
+
+	if (fd >= 0)
+		close(fd);
 
 	if (rc < 0)
 		exit(EXIT_FAILURE);
diff --git a/src/loadunimap.c b/src/loadunimap.c
index 355f3b9..26e1742 100644
--- a/src/loadunimap.c
+++ b/src/loadunimap.c
@@ -25,6 +25,7 @@
 #include "utf8.h"
 #include "psf.h"
 #include "nls.h"
+#include "kbd_error.h"
 
 extern char *progname;
 extern int force;
diff --git a/src/mapscrn.c b/src/mapscrn.c
index a755477..e40eba7 100644
--- a/src/mapscrn.c
+++ b/src/mapscrn.c
@@ -18,6 +18,7 @@
 #include "kdmapop.h"
 #include "utf8.h"
 #include "nls.h"
+#include "kbd_error.h"
 
 /* the two exported functions */
 void saveoldmap(int fd, char *omfil);
diff --git a/src/setfont.c b/src/setfont.c
index e126c9b..d5a577d 100644
--- a/src/setfont.c
+++ b/src/setfont.c
@@ -34,6 +34,7 @@
 #include "xmalloc.h"
 #include "nls.h"
 #include "version.h"
+#include "kbd_error.h"
 
 static int position_codepage(int iunit);
 static void saveoldfont(int fd, char *ofil);