[PATCH] um: fix errno usage
authorPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Thu, 8 Mar 2007 04:41:14 +0000 (20:41 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 8 Mar 2007 15:38:21 +0000 (07:38 -0800)
Avoid reusing userspace errno twice - it can be cleared by libc code
everywhere (in particular printk() does clear it in my setup).

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Acked-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/um/drivers/daemon_user.c

index 310af0f1e49e4a7fa2b78609ed5e46c200cba721..021b82c7a759b94eb212b90abaceb5f7618f4b31 100644 (file)
@@ -56,30 +56,31 @@ static int connect_to_switch(struct daemon_data *pri)
 
        pri->control = socket(AF_UNIX, SOCK_STREAM, 0);
        if(pri->control < 0){
+               err = -errno;
                printk("daemon_open : control socket failed, errno = %d\n", 
-                      errno);          
-               return(-errno);
+                      -err);
+               return err;
        }
 
        if(connect(pri->control, (struct sockaddr *) ctl_addr, 
                   sizeof(*ctl_addr)) < 0){
-               printk("daemon_open : control connect failed, errno = %d\n",
-                      errno);
                err = -errno;
+               printk("daemon_open : control connect failed, errno = %d\n",
+                      -err);
                goto out;
        }
 
        fd = socket(AF_UNIX, SOCK_DGRAM, 0);
        if(fd < 0){
-               printk("daemon_open : data socket failed, errno = %d\n", 
-                      errno);
                err = -errno;
+               printk("daemon_open : data socket failed, errno = %d\n",
+                      -err);
                goto out;
        }
        if(bind(fd, (struct sockaddr *) local_addr, sizeof(*local_addr)) < 0){
-               printk("daemon_open : data bind failed, errno = %d\n", 
-                      errno);
                err = -errno;
+               printk("daemon_open : data bind failed, errno = %d\n",
+                      -err);
                goto out_close;
        }