summaryrefslogtreecommitdiffstats
path: root/sys-utils/ipcrm.c
diff options
context:
space:
mode:
authorFrancesco Cosoleto2011-09-28 16:25:31 +0200
committerKarel Zak2011-09-29 00:25:34 +0200
commitd916761f3e06fad1af40c3ffa738cdde0da65774 (patch)
treef85d3b1a2d50e47bbf0783bf454bb81b22562cd4 /sys-utils/ipcrm.c
parentipcrm: use ternary operator in "(key|id) failed" message (diff)
downloadkernel-qcow2-util-linux-d916761f3e06fad1af40c3ffa738cdde0da65774.tar.gz
kernel-qcow2-util-linux-d916761f3e06fad1af40c3ffa738cdde0da65774.tar.xz
kernel-qcow2-util-linux-d916761f3e06fad1af40c3ffa738cdde0da65774.zip
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 <cosoleto@gmail.com>
Diffstat (limited to 'sys-utils/ipcrm.c')
-rw-r--r--sys-utils/ipcrm.c23
1 files changed, 8 insertions, 15 deletions
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;