Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command 'zpool list -H' returns error code when there are no pools created #1605

Closed
anushz opened this issue Jul 22, 2013 · 2 comments
Closed
Milestone

Comments

@anushz
Copy link

anushz commented Jul 22, 2013

The code is different every time:

root@host1 opt]# zpool list -H
[root@host1 opt]# echo $?
163
[root@host1 opt]# zpool list -H
[root@host1 opt]# echo $?
238
[root@host1 opt]# zpool list -H
[root@host1 opt]# echo $?
188
[root@host1 opt]# zpool list -H
[root@host1 opt]# echo $?
114

With no '-H' option everything works fine:

[root@host1 opt]# zpool list
no pools available
[root@host1 opt]# echo $?
0

As I can see from code the problem seems to be in 'zpool_do_list' function inside 'zfs/cmd/zpool/zpool_main.c'

OS: CentOS 6.4 x86_64
zfs version: 0.6.1

@behlendorf
Copy link
Contributor

Looks like an uninitialized variable, can you version the following trivial patch fixes it.

diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index 9d4d128..b96fbe4 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -3059,7 +3059,7 @@ int
 zpool_do_list(int argc, char **argv)
 {
        int c;
-       int ret;
+       int ret = 0;
        list_cbdata_t cb = { 0 };
        static char default_props[] =
            "name,size,allocated,free,capacity,dedupratio,"

@anushz
Copy link
Author

anushz commented Jul 22, 2013

Thanks! The patch fixes the issue.

[root@host1 zepostor]# zpool list -H
[root@host1 zepostor]# echo $?
0

unya pushed a commit to unya/zfs that referenced this issue Dec 13, 2013
Due to an uninitialized variable it was possible for the command
'zpool list -H' to return a non-zero error when there are no pools.

Signed-off-by: Brian Behlendorf <[email protected]>
Closes openzfs#1605
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants