[PATCH 3/3] ipcrm: fix wrong subject in error messages for -m, -q, -s id options

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This makes error messages print 'id' instead of 'key' using id options.

Signed-off-by: Francesco Cosoleto <cosoleto@xxxxxxxxx>
---
 sys-utils/ipcrm.c |   23 ++++++++---------------
 1 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/sys-utils/ipcrm.c b/sys-utils/ipcrm.c
index f6482ab..6f74107 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;
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux