netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 1/2] utils: add s32 parser
@ 2011-11-24 17:40 Hagen Paul Pfeifer
  2011-11-24 17:40 ` [PATCH iproute2 2/2] tc: netem ratelatency and cell extension Hagen Paul Pfeifer
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Hagen Paul Pfeifer @ 2011-11-24 17:40 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger, Hagen Paul Pfeifer

Signed-off-by: Hagen Paul Pfeifer <hagen@jauu.net>
---
 include/utils.h |    1 +
 lib/utils.c     |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/include/utils.h b/include/utils.h
index 47f8e07..496db68 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -85,6 +85,7 @@ extern int get_time_rtt(unsigned *val, const char *arg, int *raw);
 #define get_short get_s16
 extern int get_u64(__u64 *val, const char *arg, int base);
 extern int get_u32(__u32 *val, const char *arg, int base);
+extern int get_s32(__s32 *val, const char *arg, int base);
 extern int get_u16(__u16 *val, const char *arg, int base);
 extern int get_s16(__s16 *val, const char *arg, int base);
 extern int get_u8(__u8 *val, const char *arg, int base);
diff --git a/lib/utils.c b/lib/utils.c
index efaf377..6788dd9 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -198,6 +198,20 @@ int get_u8(__u8 *val, const char *arg, int base)
 	return 0;
 }
 
+int get_s32(__s32 *val, const char *arg, int base)
+{
+	long res;
+	char *ptr;
+
+	if (!arg || !*arg)
+		return -1;
+	res = strtoul(arg, &ptr, base);
+	if (!ptr || ptr == arg || *ptr || res > INT32_MAX || res < INT32_MIN)
+		return -1;
+	*val = res;
+	return 0;
+}
+
 int get_s16(__s16 *val, const char *arg, int base)
 {
 	long res;
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-01-19 22:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-24 17:40 [PATCH iproute2 1/2] utils: add s32 parser Hagen Paul Pfeifer
2011-11-24 17:40 ` [PATCH iproute2 2/2] tc: netem ratelatency and cell extension Hagen Paul Pfeifer
2011-11-25  9:46 ` [PATCH iproute2 1/2] utils: add s32 parser David Laight
2011-11-25 11:13   ` Hagen Paul Pfeifer
2011-11-25 17:24   ` Stephen Hemminger
2011-11-25 17:34     ` David Laight
2011-11-25 17:47       ` Hagen Paul Pfeifer
2011-11-25 23:00         ` [PATCH iproute2] " Hagen Paul Pfeifer
2011-11-26  0:50           ` Stephen Hemminger
2011-11-26 10:54             ` Hagen Paul Pfeifer
2012-01-19 22:41 ` [PATCH iproute2 1/2] " Stephen Hemminger
2012-01-19 22:48   ` Hagen Paul Pfeifer

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).