The tls_key function is using a STREAM object and closes it when leaving
the context. Update it to use the helper.
Signed-off-by: Daniel Wagner <dwagner@suse.de>
const char *import = "Import all keys into the keyring.";
const char *export = "Export all keys from the keyring.";
- FILE *fd;
+ _cleanup_file_ FILE *fd = NULL;
int err = 0;
struct config {
if (cfg.export && cfg.import) {
nvme_show_error("Cannot specify both --import and --export");
- err = -EINVAL;
+ return -EINVAL;
} else if (cfg.export) {
nvme_scan_tls_keys(cfg.keyring, __scan_tls_key, fd);
} else if (cfg.import) {
keyring_id = nvme_lookup_keyring(cfg.keyring);
if (!keyring_id) {
nvme_show_error("Invalid keyring '%s'", cfg.keyring);
- err = -ENOKEY;
- goto out;
+ return -ENOKEY;
}
while (fgets(tls_str, 512, fd)) {
err = -EINVAL;
}
-out:
- if (cfg.keyfile)
- fclose(fd);
-
return err;
}