From b0d38be0d0db668b38c28830320f77797e7b6385 Mon Sep 17 00:00:00 2001 From: Stephan Kulow Date: Sun, 24 Feb 2008 15:21:16 +0000 Subject: [PATCH] exit if there is an error opening the old solv --- tools/rpmdb2solv.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/rpmdb2solv.c b/tools/rpmdb2solv.c index 44a537f..e818e11 100644 --- a/tools/rpmdb2solv.c +++ b/tools/rpmdb2solv.c @@ -34,22 +34,27 @@ main(int argc, char **argv) int g; const char *root = "/"; - while ((g = getopt (argc, argv, "-r:")) >= 0) + while ((g = getopt (argc, argv, "r:")) >= 0) switch (g) { case 'r': root = optarg; break; - case 1: - refpool = pool; - if ((fp = fopen(argv[1], "r")) == NULL) - { - perror(argv[1]); - exit(0); - } - ref = repo_create(refpool, "ref"); - repo_add_solv(ref, fp); - fclose(fp); + default: + exit(1); } + if (optind < argc) + { + refpool = pool; + if ((fp = fopen(argv[optind], "r")) == NULL) + { + perror(argv[optind]); + exit(1); + } + ref = repo_create(refpool, "ref"); + repo_add_solv(ref, fp); + fclose(fp); + } + repo = repo_create(pool, "installed"); repo_add_rpmdb(repo, ref, root); if (ref) -- 2.7.4