linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Christopher Li <sparse@chrisli.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 3/5] add helper handle_simple_switch()
Date: Wed, 12 Apr 2017 10:37:01 +0200	[thread overview]
Message-ID: <20170412083703.11552-4-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20170412083703.11552-1-luc.vanoostenryck@gmail.com>

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 lib.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/lib.c b/lib.c
index 8c9c36bd5..1d21a2fb7 100644
--- a/lib.c
+++ b/lib.c
@@ -454,6 +454,25 @@ static void handle_arch_finalize(void)
 }
 
 
+static int handle_simple_switch(const char *arg, const char *name, int *flag)
+{
+	int val = 1;
+
+	// Prefixe "no-" mean to turn flag off.
+	if (strncmp(arg, "no-", 3) == 0) {
+		arg += 3;
+		val = 0;
+	}
+
+	if (strcmp(arg, name) == 0) {
+		*flag = val;
+		return 1;
+	}
+
+	// not handled
+	return 0;
+}
+
 static char **handle_switch_o(char *arg, char **next)
 {
 	if (!strcmp (arg, "o")) {       // "-o foo"
-- 
2.12.0


  parent reply	other threads:[~2017-04-12  8:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-12  8:36 [PATCH 0/5] report allocation stats Luc Van Oostenryck
2017-04-12  8:36 ` [PATCH 1/5] add get_<allocator>_stats() Luc Van Oostenryck
2017-04-12  8:37 ` [PATCH 2/5] add show_allocation_stats() Luc Van Oostenryck
2017-04-12  8:37 ` Luc Van Oostenryck [this message]
2017-06-01  6:15   ` [PATCH 3/5] add helper handle_simple_switch() Christopher Li
2017-06-01 14:30     ` Luc Van Oostenryck
2017-04-12  8:37 ` [PATCH 4/5] teach sparse how to handle '-fmem-report' Luc Van Oostenryck
2017-04-12  8:37 ` [PATCH 5/5] use -fmem-report to report allocation stats Luc Van Oostenryck

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=20170412083703.11552-4-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.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;
as well as URLs for NNTP newsgroup(s).