[BUILD] Fix build warnings
authorAlexey Gladkov <legion@altlinux.org>
Mon, 12 Feb 2007 08:32:21 +0000 (11:32 +0300)
committerAlexey Gladkov <legion@altlinux.org>
Mon, 12 Feb 2007 08:32:21 +0000 (11:32 +0300)
Add missing headers and check return codes to avoid warnings at the build time.

Signed-off-by: Alexey Gladkov <legion@altlinux.org>
src/kbdrate.c
src/spawn_console.c
src/spawn_login.c

index 9a612b2..e76bdf9 100644 (file)
@@ -202,7 +202,7 @@ KIOCSRATE_ioctl_ok(double rate, int delay, int silent) {
 #endif /* KIOCSRATE */
 }
 
-void
+static void
 sigalrmhandler( int sig ) {
        fprintf( stderr, "kbdrate: Failed waiting for kbd controller!\n" );
        raise( SIGINT );
@@ -289,23 +289,35 @@ main( int argc, char **argv ) {
 
        do {
                lseek( fd, 0x64, 0 );
-               read( fd, &data, 1 );
+               if (read( fd, &data, 1 ) == -1) {
+                       perror( "read" );
+                       exit( 1 );
+               }
        } while ((data & 2) == 2 );  /* wait */
 
        lseek( fd, 0x60, 0 );
        data = 0xf3;                 /* set typematic rate */
-       write( fd, &data, 1 );
+       if (write( fd, &data, 1 ) == -1) {
+               perror( "write" );
+               exit( 1 );
+       }
 
        do {
                lseek( fd, 0x64, 0 );
-               read( fd, &data, 1 );
+               if (read( fd, &data, 1 ) == -1) {
+                       perror( "read" );
+                       exit( 1 );
+               }
        } while ((data & 2) == 2 );  /* wait */
 
        alarm( 0 );
 
        lseek( fd, 0x60, 0 );
        sleep( 1 );
-       write( fd, &value, 1 );
+       if (write( fd, &value, 1 ) == -1) {
+               perror( "write" );
+               exit( 1 );
+       }
 
        close( fd );
 
index 97bee45..0904ef9 100644 (file)
@@ -12,6 +12,7 @@
 #include <signal.h>
 #include <errno.h>
 #include <linux/kd.h>
+#include <stdio.h>
 #include <stdlib.h>    /* system */
 #include <fcntl.h>     /* open */
 #include <sys/ioctl.h> /* ioctl */
 
 void
 sighup(){
-    system("openvt -s -l bash");
+    if (system("openvt -s -l bash") == -1) {
+      perror("system");
+      exit(1);
+    }
     signal(SIGHUP, sighup);
 }
 
-main(){
+int
+main(void) {
     int fd;
 
     fd = open("/dev/tty0", 0);
index 0cbb1dd..1cbf8f4 100644 (file)
@@ -4,17 +4,26 @@
  * aeb - 941025
  *
  */
+#include <stdio.h>
+#include <stdlib.h>
 #include <signal.h>
 #include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
 #include <linux/kd.h>
 
 void
-sighup(){
-    system("openvt -s -l -- login -h spawn");
+sighup() {
+    if (system("openvt -s -l -- login -h spawn") == -1) {
+       perror("system");
+       exit(1);
+    }
     signal(SIGHUP, sighup);
 }
 
-main(){
+int
+main(void) {
     int fd;
 
     fd = open("/dev/tty0", 0);