From d916761f3e06fad1af40c3ffa738cdde0da65774 Mon Sep 17 00:00:00 2001 From: Francesco Cosoleto Date: Wed, 28 Sep 2011 16:25:31 +0200 Subject: ipcrm: fix wrong subject in error messages for -m, -q, -s id options This makes error messages print 'id' instead of 'key' using id options. Signed-off-by: Francesco Cosoleto --- sys-utils/ipcrm.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'sys-utils/ipcrm.c') diff --git a/sys-utils/ipcrm.c b/sys-utils/ipcrm.c index f6482abc1..6f741073d 100644 --- a/sys-utils/ipcrm.c +++ b/sys-utils/ipcrm.c @@ -323,52 +323,45 @@ int main(int argc, char **argv) return EXIT_SUCCESS; /* process new syntax to conform with SYSV ipcrm */ - for (id = -1; - (c = getopt_long(argc, argv, "q:m:s:Q:M:S:a::vhV", longopts, NULL)) != -1; - id = -1) { + while((c = getopt_long(argc, argv, "q:m:s:Q:M:S:a::vhV", longopts, NULL)) != -1) { + iskey = 0; switch (c) { case 'M': - iskey = 0; + iskey = 1; id = key_to_id(SHM, optarg); if (id < 0) { ret++; break; } case 'm': - if (id < 0) { - iskey = 1; + if (!iskey) id = strtoll_or_err(optarg, _("failed to parse argument")); - } if (remove_id(SHM, iskey, id)) ret++; break; case 'Q': - iskey = 0; + iskey = 1; id = key_to_id(MSG, optarg); if (id < 0) { ret++; break; } case 'q': - if (id < 0) { - iskey = 1; + if (!iskey) id = strtoll_or_err(optarg, _("failed to parse argument")); - } if (remove_id(MSG, iskey, id)) ret++; break; case 'S': - iskey = 0; + iskey = 1; id = key_to_id(SEM, optarg); if (id < 0) { ret++; break; } case 's': - if (id < 0) { - iskey = 1; + if (!iskey) id = strtoll_or_err(optarg, _("failed to parse argument")); - } if (remove_id(SEM, iskey, id)) ret++; break; -- cgit v1.2.3-55-g7522