mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Anton Vorontsov <anton.vorontsov@linaro.org>
To: Jason Wessel <jason.wessel@windriver.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	John Stultz <john.stultz@linaro.org>,
	arve@android.com, linux-kernel@vger.kernel.org,
	linaro-kernel@lists.linaro.org, patches@linaro.org,
	kernel-team@android.com, kgdb-bugreport@lists.sourceforge.net
Subject: [PATCH 4/7] kdb: Use KDB_REPEAT_* values as flags
Date: Thu, 26 Jul 2012 07:26:28 -0700	[thread overview]
Message-ID: <1343312791-9138-4-git-send-email-anton.vorontsov@linaro.org> (raw)
In-Reply-To: <20120726142514.GA32158@lizard>

The actual values of KDB_REPEAT_* enum values and overall logic stayed
the same, but we now treat the values as flags.

This makes it possible to add other flags and combine them, plus makes
the code a lot simpler and shorter. But functionality-wise, there should
be no changes.

Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
---
 include/linux/kdb.h         |    4 ++--
 kernel/debug/kdb/kdb_main.c |   21 +++++++--------------
 2 files changed, 9 insertions(+), 16 deletions(-)

diff --git a/include/linux/kdb.h b/include/linux/kdb.h
index 4ab0936..0a047f9 100644
--- a/include/linux/kdb.h
+++ b/include/linux/kdb.h
@@ -34,8 +34,8 @@ extern atomic_t kdb_event;
 
 typedef enum {
 	KDB_REPEAT_NONE = 0,	/* Do not repeat this command */
-	KDB_REPEAT_NO_ARGS,	/* Repeat the command without arguments */
-	KDB_REPEAT_WITH_ARGS,	/* Repeat the command including its arguments */
+	KDB_REPEAT_NO_ARGS	= 0x1, /* Repeat the command w/o arguments */
+	KDB_REPEAT_WITH_ARGS	= 0x2, /* Repeat the command w/ its arguments */
 } kdb_cmdflags_t;
 
 typedef int (*kdb_func_t)(int, const char **);
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
index e9e33c1..c7d023a 100644
--- a/kernel/debug/kdb/kdb_main.c
+++ b/kernel/debug/kdb/kdb_main.c
@@ -991,20 +991,13 @@ int kdb_parse(const char *cmdstr)
 		if (result && ignore_errors && result > KDB_CMD_GO)
 			result = 0;
 		KDB_STATE_CLEAR(CMD);
-		switch (tp->cmd_flags) {
-		case KDB_REPEAT_NONE:
-			argc = 0;
-			if (argv[0])
-				*(argv[0]) = '\0';
-			break;
-		case KDB_REPEAT_NO_ARGS:
-			argc = 1;
-			if (argv[1])
-				*(argv[1]) = '\0';
-			break;
-		case KDB_REPEAT_WITH_ARGS:
-			break;
-		}
+
+		if (tp->cmd_flags & KDB_REPEAT_WITH_ARGS)
+			return result;
+
+		argc = tp->cmd_flags & KDB_REPEAT_NO_ARGS ? 1 : 0;
+		if (argv[argc])
+			*(argv[argc]) = '\0';
 		return result;
 	}
 
-- 
1.7.10.4


  parent reply	other threads:[~2012-07-26 14:28 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-26 14:25 [PATCH 0/7] KDB: Kiosk (reduced capabilities) mode Anton Vorontsov
2012-07-26 14:26 ` [PATCH 1/7] kdb: Remove currently unused kdbtab_t->cmd_flags Anton Vorontsov
2012-07-26 14:26 ` [PATCH 2/7] kdb: Rename kdb_repeat_t to kdb_cmdflags_t, cmd_repeat to cmd_flags Anton Vorontsov
2012-07-26 14:26 ` [PATCH 3/7] kdb: Rename kdb_register_repeat() to kdb_register_flags() Anton Vorontsov
2012-07-26 14:26 ` Anton Vorontsov [this message]
2012-07-26 14:26 ` [PATCH 5/7] kdb: Remove KDB_REPEAT_NONE flag Anton Vorontsov
2012-07-26 14:26 ` [PATCH 6/7] kdb: Mark safe commands as KDB_SAFE and KDB_SAFE_NO_ARGS Anton Vorontsov
2012-07-26 17:07   ` Alan Cox
2012-07-26 17:39     ` Anton Vorontsov
2012-07-30 12:04       ` [PATCH v2 " Anton Vorontsov
2012-07-26 14:26 ` [PATCH 7/7] kdb: Add kiosk mode Anton Vorontsov
2012-07-27 19:30 ` [PATCH 0/7] KDB: Kiosk (reduced capabilities) mode Colin Cross
2012-07-28  1:26   ` Anton Vorontsov
2012-07-28  1:49     ` John Stultz
2012-07-28  1:53     ` Colin Cross
2012-10-16  1:17 Anton Vorontsov
2012-10-16  1:18 ` [PATCH 4/7] kdb: Use KDB_REPEAT_* values as flags Anton Vorontsov
2012-11-23  0:53 [PATCH resend 0/7] KDB: Kiosk (reduced capabilities) mode Anton Vorontsov
2012-11-23  0:53 ` [PATCH 4/7] kdb: Use KDB_REPEAT_* values as flags Anton Vorontsov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1343312791-9138-4-git-send-email-anton.vorontsov@linaro.org \
    --to=anton.vorontsov@linaro.org \
    --cc=akpm@linux-foundation.org \
    --cc=arve@android.com \
    --cc=jason.wessel@windriver.com \
    --cc=john.stultz@linaro.org \
    --cc=kernel-team@android.com \
    --cc=kgdb-bugreport@lists.sourceforge.net \
    --cc=linaro-kernel@lists.linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@linaro.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome