X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=misc%2Fe4crypt.c;h=2ae6254a23cb57b0c16659d7820954484ed81617;hb=5a959732ebfd301b6f08ef3dba22cd3cd68d4755;hp=c1ec9ab9fe1b82c7a15505c8aa2e7d67eefb5662;hpb=75dd3c47c489bef2391bdc147a3f835f1a935fbf;p=tools%2Fe2fsprogs.git diff --git a/misc/e4crypt.c b/misc/e4crypt.c index c1ec9ab..2ae6254 100644 --- a/misc/e4crypt.c +++ b/misc/e4crypt.c @@ -566,7 +566,7 @@ static void insert_key_into_keyring(const char *keyring, struct salt *salt) return; } else if ((rc == -1) && (errno != ENOKEY)) { printf("keyctl_search failed: %s\n", strerror(errno)); - if (errno == -EINVAL) + if (errno == EINVAL) printf("Keyring [%s] is not available.\n", keyring); exit(1); } @@ -676,8 +676,10 @@ static void do_add_key(int argc, char **argv, const struct cmd_desc *cmd) options |= OPT_QUIET; break; default: - fprintf(stderr, "Unrecognized option: %c\n", opt); case '?': + if (opt != '?') + fprintf(stderr, "Unrecognized option: %c\n", + opt); fputs("USAGE:\n ", stderr); fputs(cmd->cmd_help, stderr); exit(1); @@ -758,7 +760,6 @@ static void do_set_policy(int argc, char **argv, const struct cmd_desc *cmd) static void do_get_policy(int argc, char **argv, const struct cmd_desc *cmd) { struct ext4_encryption_policy policy; - struct stat st; int i, j, fd, rc; if (argc < 2) { @@ -769,12 +770,7 @@ static void do_get_policy(int argc, char **argv, const struct cmd_desc *cmd) } for (i = 1; i < argc; i++) { - if (stat(argv[i], &st) < 0) { - perror(argv[i]); - continue; - } - fd = open(argv[i], - S_ISDIR(st.st_mode) ? O_DIRECTORY : O_RDONLY); + fd = open(argv[i], O_RDONLY); if (fd == -1) { perror(argv[i]); exit(1);