[2/2] batman-adv: Fix signedness problem in parse_gw_bandwidth

Message ID 1307184038-32426-2-git-send-email-sven@narfation.org (mailing list archive)
State Superseded, archived
Headers

Commit Message

Sven Eckelmann June 4, 2011, 10:40 a.m. UTC
  strict_strtoul as used in parse_gw_bandwidth is defined for unsigned
long and strict_strtol should be used instead for long.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 gateway_common.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
  

Comments

Marek Lindner June 4, 2011, 11:44 a.m. UTC | #1
On Saturday 04 June 2011 12:40:38 Sven Eckelmann wrote:
> strict_strtoul as used in parse_gw_bandwidth is defined for unsigned
> long and strict_strtol should be used instead for long.

Don't we need a strict_strtol macro in compat.h next to the strict_strtoul 
that we have now ?

Cheers,
Marek
  
Sven Eckelmann June 4, 2011, 11:59 a.m. UTC | #2
Marek Lindner wrote:
> On Saturday 04 June 2011 12:40:38 Sven Eckelmann wrote:
> > strict_strtoul as used in parse_gw_bandwidth is defined for unsigned
> > long and strict_strtol should be used instead for long.
> 
> Don't we need a strict_strtol macro in compat.h next to the strict_strtoul
> that we have now ?

Yes, forgot to add that change to the patch.

Kind regards,
	Sven
  

Patch

diff --git a/gateway_common.c b/gateway_common.c
index ed3bd36..e74307b 100644
--- a/gateway_common.c
+++ b/gateway_common.c
@@ -97,7 +97,7 @@  static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
 			*tmp_ptr = '\0';
 	}
 
-	ret = strict_strtoul(buff, 10, &ldown);
+	ret = strict_strtol(buff, 10, &ldown);
 	if (ret) {
 		bat_err(net_dev,
 			"Download speed of gateway mode invalid: %s\n",
@@ -122,7 +122,7 @@  static bool parse_gw_bandwidth(struct net_device *net_dev, char *buff,
 				*tmp_ptr = '\0';
 		}
 
-		ret = strict_strtoul(slash_ptr + 1, 10, &lup);
+		ret = strict_strtol(slash_ptr + 1, 10, &lup);
 		if (ret) {
 			bat_err(net_dev,
 				"Upload speed of gateway mode invalid: "