lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1402996306-6811-2-git-send-email-andriy.shevchenko@linux.intel.com>
Date:	Tue, 17 Jun 2014 12:11:45 +0300
From:	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:	Josh Triplett <josh@...htriplett.org>,
	linux-kernel@...r.kernel.org, linux-sparse@...r.kernel.org
Cc:	Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Subject: [PATCH v2 1/2] lib.c: introduce split_value_from_arg helper

The function tries to split a key / value from the given argument where
delimiter can be either ' ' (space) or '=' (equal sign).

It will be useful later as well.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
---
 lib.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/lib.c b/lib.c
index bf3e91c..4e5a846 100644
--- a/lib.c
+++ b/lib.c
@@ -275,14 +275,8 @@ void add_pre_buffer(const char *fmt, ...)
 	pre_buffer_end = end;
 }
 
-static char **handle_switch_D(char *arg, char **next)
+static const char *split_value_from_arg(char *arg, const char *def)
 {
-	const char *name = arg + 1;
-	const char *value = "1";
-
-	if (!*name || isspace(*name))
-		die("argument to `-D' is missing");
-
 	for (;;) {
 		char c;
 		c = *++arg;
@@ -290,10 +284,21 @@ static char **handle_switch_D(char *arg, char **next)
 			break;
 		if (isspace((unsigned char)c) || c == '=') {
 			*arg = '\0';
-			value = arg + 1;
-			break;
+			return arg + 1;
 		}
 	}
+	return def;
+}
+
+static char **handle_switch_D(char *arg, char **next)
+{
+	const char *name = arg + 1;
+	const char *value = "1";
+
+	if (!*name || isspace(*name))
+		die("argument to `-D' is missing");
+
+	value = split_value_from_arg(arg, value);
 	add_pre_buffer("#define %s %s\n", name, value);
 	return next;
 }
-- 
2.0.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ