gpm related crash fix



Hello! 

Some days ago I put my linux in pretty weird state, similar to single 
user mode. In this mode gpmd dies.. 
The error was in some rc.d level 6 script, which didn't handle `reboot' 
properly, so returned to login prompt (single user). 

When I tried to run mc, it crashed. gdb said gpm_fd was -2, and mc only 
checks for -1. 

Attached key.c.diff changes checking for == -1 to  < 0, which is more 
general case. 

view.c.diff fixes warning. 

WBR,
Dmitry
--- key.c.orig	2003-11-08 02:50:19 +0300
+++ key.c	2003-12-19 10:50:21 +0300
@@ -938,14 +938,15 @@
 
 #ifdef HAVE_LIBGPM
 	if (use_mouse_p == MOUSE_GPM) {
-	    if (gpm_fd == -1) {
+	    if (gpm_fd < 0) {
 		/* Connection to gpm broken, possibly gpm has died */
 		mouse_enabled = 0;
 		use_mouse_p = MOUSE_NONE;
 		break;
+	    } else {
+		FD_SET (gpm_fd, &select_set);
+    		maxfdp = max (maxfdp, gpm_fd);
 	    }
-	    FD_SET (gpm_fd, &select_set);
-	    maxfdp = max (maxfdp, gpm_fd);
 	}
 #endif
 
@@ -999,7 +1000,7 @@
 	if (FD_ISSET (input_fd, &select_set))
 	    break;
 #ifdef HAVE_LIBGPM
-	if (use_mouse_p == MOUSE_GPM && FD_ISSET (gpm_fd, &select_set)) {
+	if (use_mouse_p == MOUSE_GPM &&gpm_fd > 0 && FD_ISSET (gpm_fd, &select_set)) {
 	    Gpm_GetEvent (&ev);
 	    Gpm_FitEvent (&ev);
 	    *event = ev;
@@ -1166,7 +1167,7 @@
     FD_SET (input_fd, &select_set);
     maxfdp = input_fd;
 #ifdef HAVE_LIBGPM
-    if (use_mouse_p == MOUSE_GPM && mouse_enabled && gpm_fd != -1) {
+    if (use_mouse_p == MOUSE_GPM && mouse_enabled && gpm_fd > 0) {
 	FD_SET (gpm_fd, &select_set);
 	maxfdp = max (maxfdp, gpm_fd);
     }
--- view.c.orig	2003-11-21 09:27:14 +0300
+++ view.c	2003-12-03 19:52:29 +0300
@@ -787,7 +787,7 @@
 	if (w > 46) {
 	    widget_move (view, view->have_frame, 24 + view->have_frame);
 	    if (view->hex_mode)
-		printw (_("Offset 0x%08x"), view->edit_cursor);
+		printw (_("Offset 0x%08lx"), view->edit_cursor);
 	    else
 		printw (_("Col %d"), -view->start_col);
 	}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]