diff options
author | Zach Brown <zab@redhat.com> | 2013-01-22 13:48:04 -0800 |
---|---|---|
committer | Zach Brown <zab@redhat.com> | 2013-02-05 16:09:39 -0800 |
commit | 7c9f323a7c9c7a0d7b516ed9974308bde4017ae2 (patch) | |
tree | 359efd9416e508df5b5baeb8798c43099def9334 | |
parent | 201238df269cfa8fa002b3be0ad327b48228e45c (diff) |
btrfs-progs: check for open failure, don't close
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>
-rw-r--r-- | cmds-device.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/cmds-device.c b/cmds-device.c index d4938f4e..7a0f7a40 100644 --- 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; } |