提交 d84a19ce 编写于 作者: P Paolo 'Blaisorblade' Giarrusso 提交者: Linus Torvalds

[PATCH] uml: fix failure path after conversion

Little fix for error paths in this code.

- Some bug come from conversion to os-Linux (open() doesn't follow the
  kernel -errno return convention, while the old code called os_open_file()
  which followed it).  This caused the wrong return code to be printed.

- Then be more precise about what happened and do some whitespace fixes.
Signed-off-by: NPaolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 b1c332c9
...@@ -120,7 +120,8 @@ static int not_dead_yet(char *dir) ...@@ -120,7 +120,8 @@ static int not_dead_yet(char *dir)
dead = 0; dead = 0;
fd = open(file, O_RDONLY); fd = open(file, O_RDONLY);
if(fd < 0){ if(fd < 0) {
fd = -errno;
if(fd != -ENOENT){ if(fd != -ENOENT){
printk("not_dead_yet : couldn't open pid file '%s', " printk("not_dead_yet : couldn't open pid file '%s', "
"err = %d\n", file, -fd); "err = %d\n", file, -fd);
...@@ -130,9 +131,13 @@ static int not_dead_yet(char *dir) ...@@ -130,9 +131,13 @@ static int not_dead_yet(char *dir)
err = 0; err = 0;
n = read(fd, pid, sizeof(pid)); n = read(fd, pid, sizeof(pid));
if(n <= 0){ if(n < 0){
printk("not_dead_yet : couldn't read pid file '%s', "
"err = %d\n", file, errno);
goto out_close;
} else if(n == 0){
printk("not_dead_yet : couldn't read pid file '%s', " printk("not_dead_yet : couldn't read pid file '%s', "
"err = %d\n", file, -n); "0-byte read\n", file);
goto out_close; goto out_close;
} }
...@@ -155,9 +160,9 @@ static int not_dead_yet(char *dir) ...@@ -155,9 +160,9 @@ static int not_dead_yet(char *dir)
return err; return err;
out_close: out_close:
close(fd); close(fd);
out: out:
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册