projects
/
platform
/
upstream
/
btrfs-progs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
201238d
)
btrfs-progs: check for open failure, don't close
author
Zach Brown
<zab@redhat.com>
Tue, 22 Jan 2013 21:48:04 +0000
(13:48 -0800)
committer
Zach Brown
<zab@redhat.com>
Wed, 6 Feb 2013 00:09:39 +0000
(16:09 -0800)
Check for failure by testing for a negative file descriptor, not a
descriptor of 0. And if it failed we have nothing to close().
Signed-off-by: Zach Brown <zab@redhat.com>
cmds-device.c
patch
|
blob
|
history
diff --git
a/cmds-device.c
b/cmds-device.c
index
d4938f4
..
7a0f7a4
100644
(file)
--- a/
cmds-device.c
+++ b/
cmds-device.c
@@
-87,9
+87,8
@@
static int cmd_add_dev(int argc, char **argv)
}
devfd = open(argv[i], O_RDWR);
- if (
!devfd
) {
+ if (
devfd < 0
) {
fprintf(stderr, "ERROR: Unable to open device '%s'\n", argv[i]);
- close(devfd);
ret++;
continue;
}