aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2006-05-01 15:16:00 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-05-01 21:17:44 -0400
commit2ace87b9502d922397cabaf07d73e0b60c480ecf (patch)
treeb354425542c4b2cff20dc20cd65d0e8eeec2c7c4 /arch/um
parent347b3dc2faf34d63a96b41e3244b743cc72a2aa0 (diff)
[PATCH] uml: error handling fixes
Blairsorblade noticed some confusion between our use of a system call's return value and errno. This patch fixes a number of related bugs - using errno instead of a return value using a return value instead of errno forgetting to negate a error return to get a positive error code Signed-off-by: Jeff Dike <jdike@addtoit.com> Cc: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/os-Linux/file.c2
-rw-r--r--arch/um/os-Linux/skas/process.c6
-rw-r--r--arch/um/os-Linux/sys-i386/registers.c4
-rw-r--r--arch/um/os-Linux/sys-x86_64/registers.c4
-rw-r--r--arch/um/os-Linux/umid.c4
5 files changed, 10 insertions, 10 deletions
diff --git a/arch/um/os-Linux/file.c b/arch/um/os-Linux/file.c
index 3bd10deea280..09251338d99e 100644
--- a/arch/um/os-Linux/file.c
+++ b/arch/um/os-Linux/file.c
@@ -171,7 +171,7 @@ int os_sigio_async(int master, int slave)
171 171
172 flags = fcntl(master, F_GETFL); 172 flags = fcntl(master, F_GETFL);
173 if(flags < 0) 173 if(flags < 0)
174 return errno; 174 return -errno;
175 175
176 if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) || 176 if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
177 (fcntl(master, F_SETOWN, os_getpid()) < 0)) 177 (fcntl(master, F_SETOWN, os_getpid()) < 0))
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 0776bc18ca85..bd89c6b99d5d 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -344,12 +344,12 @@ int copy_context_skas0(unsigned long new_stack, int pid)
344 err = ptrace_setregs(pid, regs); 344 err = ptrace_setregs(pid, regs);
345 if(err < 0) 345 if(err < 0)
346 panic("copy_context_skas0 : PTRACE_SETREGS failed, " 346 panic("copy_context_skas0 : PTRACE_SETREGS failed, "
347 "pid = %d, errno = %d\n", pid, errno); 347 "pid = %d, errno = %d\n", pid, -err);
348 348
349 err = ptrace_setfpregs(pid, fp_regs); 349 err = ptrace_setfpregs(pid, fp_regs);
350 if(err < 0) 350 if(err < 0)
351 panic("copy_context_skas0 : PTRACE_SETFPREGS failed, " 351 panic("copy_context_skas0 : PTRACE_SETFPREGS failed, "
352 "pid = %d, errno = %d\n", pid, errno); 352 "pid = %d, errno = %d\n", pid, -err);
353 353
354 /* set a well known return code for detection of child write failure */ 354 /* set a well known return code for detection of child write failure */
355 child_data->err = 12345678; 355 child_data->err = 12345678;
@@ -362,7 +362,7 @@ int copy_context_skas0(unsigned long new_stack, int pid)
362 pid = data->err; 362 pid = data->err;
363 if(pid < 0) 363 if(pid < 0)
364 panic("copy_context_skas0 - stub-parent reports error %d\n", 364 panic("copy_context_skas0 - stub-parent reports error %d\n",
365 pid); 365 -pid);
366 366
367 /* Wait, until child has finished too: read child's result from 367 /* Wait, until child has finished too: read child's result from
368 * child's stack and check it. 368 * child's stack and check it.
diff --git a/arch/um/os-Linux/sys-i386/registers.c b/arch/um/os-Linux/sys-i386/registers.c
index 7a6f6b99ceff..516f66dd87e3 100644
--- a/arch/um/os-Linux/sys-i386/registers.c
+++ b/arch/um/os-Linux/sys-i386/registers.c
@@ -104,7 +104,7 @@ void init_registers(int pid)
104 err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs); 104 err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs);
105 if(err) 105 if(err)
106 panic("check_ptrace : PTRACE_GETREGS failed, errno = %d", 106 panic("check_ptrace : PTRACE_GETREGS failed, errno = %d",
107 err); 107 errno);
108 108
109 errno = 0; 109 errno = 0;
110 err = ptrace(PTRACE_GETFPXREGS, pid, 0, exec_fpx_regs); 110 err = ptrace(PTRACE_GETFPXREGS, pid, 0, exec_fpx_regs);
@@ -119,7 +119,7 @@ void init_registers(int pid)
119 err = ptrace(PTRACE_GETFPREGS, pid, 0, exec_fp_regs); 119 err = ptrace(PTRACE_GETFPREGS, pid, 0, exec_fp_regs);
120 if(err) 120 if(err)
121 panic("check_ptrace : PTRACE_GETFPREGS failed, errno = %d", 121 panic("check_ptrace : PTRACE_GETFPREGS failed, errno = %d",
122 err); 122 errno);
123} 123}
124 124
125void get_safe_registers(unsigned long *regs, unsigned long *fp_regs) 125void get_safe_registers(unsigned long *regs, unsigned long *fp_regs)
diff --git a/arch/um/os-Linux/sys-x86_64/registers.c b/arch/um/os-Linux/sys-x86_64/registers.c
index 001941fa1a1e..becd898d9398 100644
--- a/arch/um/os-Linux/sys-x86_64/registers.c
+++ b/arch/um/os-Linux/sys-x86_64/registers.c
@@ -62,12 +62,12 @@ void init_registers(int pid)
62 err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs); 62 err = ptrace(PTRACE_GETREGS, pid, 0, exec_regs);
63 if(err) 63 if(err)
64 panic("check_ptrace : PTRACE_GETREGS failed, errno = %d", 64 panic("check_ptrace : PTRACE_GETREGS failed, errno = %d",
65 err); 65 errno);
66 66
67 err = ptrace(PTRACE_GETFPREGS, pid, 0, exec_fp_regs); 67 err = ptrace(PTRACE_GETFPREGS, pid, 0, exec_fp_regs);
68 if(err) 68 if(err)
69 panic("check_ptrace : PTRACE_GETFPREGS failed, errno = %d", 69 panic("check_ptrace : PTRACE_GETFPREGS failed, errno = %d",
70 err); 70 errno);
71} 71}
72 72
73void get_safe_registers(unsigned long *regs, unsigned long *fp_regs) 73void get_safe_registers(unsigned long *regs, unsigned long *fp_regs)
diff --git a/arch/um/os-Linux/umid.c b/arch/um/os-Linux/umid.c
index 34bfc1bb9e38..362db059fe30 100644
--- a/arch/um/os-Linux/umid.c
+++ b/arch/um/os-Linux/umid.c
@@ -178,14 +178,14 @@ static void __init create_pid_file(void)
178 fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644); 178 fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0644);
179 if(fd < 0){ 179 if(fd < 0){
180 printk("Open of machine pid file \"%s\" failed: %s\n", 180 printk("Open of machine pid file \"%s\" failed: %s\n",
181 file, strerror(-fd)); 181 file, strerror(errno));
182 return; 182 return;
183 } 183 }
184 184
185 snprintf(pid, sizeof(pid), "%d\n", getpid()); 185 snprintf(pid, sizeof(pid), "%d\n", getpid());
186 n = write(fd, pid, strlen(pid)); 186 n = write(fd, pid, strlen(pid));
187 if(n != strlen(pid)) 187 if(n != strlen(pid))
188 printk("Write of pid file failed - err = %d\n", -n); 188 printk("Write of pid file failed - err = %d\n", errno);
189 189
190 close(fd); 190 close(fd);
191} 191}