Subject: Bug#516: [X2Go-Dev] Bug#516: [PATCH 3/5] Error reporting logic in keyboard section.

From: Mihai Moldovan <[email-masked]>
Date: Sat, 21 Jun 2014 05:23:40 +0200

Don't print out nonsensical information, if there really was no error when
creating the keyboard file or the other way around.

Also add the reason when failing to create the keyboard file.

Lastly, only print an error message if SessionPath *really* is not defined.
diff --git a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
index dfafe1e..3826d80 100644
--- a/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
+++ b/nx-X11/programs/Xserver/hw/nxagent/Keyboard.c
@@ -73,6 +73,8 @@ is" without express or implied warranty.
 
 #include "Xatom.h"
 
+#include <errno.h>
+
 static int nxagentXkbGetNames(char **rules, char **model, char **layout,
                                   char **variant, char **options);
 
@@ -1816,11 +1859,17 @@ void nxagentKeycodeConversionSetup(void)
         if ( doptions != NULL )
           fprintf(keyboard_file, "options=%s\n", doptions);
         fclose(keyboard_file);
+        fprintf(stderr, "keyboard file created\n");
+      }
+      else {
+        int save_err = errno;
+        fprintf(stderr, "keyboard file not created: %s\n", strerror(save_err));
       }
       free(keyboard_file_path);
-      fprintf(stderr, "keyboard file created\n");
     }
-    fprintf(stderr, "SessionPath not defined\n");
+    else {
+      fprintf(stderr, "SessionPath not defined\n");
+    }
   }
   else
   {