Patchwork mtd-utils: common.h: simple_strtoll type usage

login
register
mail settings
Submitter Brian Norris
Date Feb. 16, 2011, 1:47 a.m.
Message ID <1297820878-2582-1-git-send-email-computersforpeace@gmail.com>
Download mbox | patch
Permalink /patch/83323/
State New
Headers show

Comments

Brian Norris - Feb. 16, 2011, 1:47 a.m.
We must use "long long" and "unsigned long long" types when
implementing the functions "simple_strtoll()" and "simple_strtoull()",
respectively. This prevents casting/truncation errors on systems where
"long" is not the same size as "long long" (that is, on most systems).

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 include/common.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
Mike Frysinger - Feb. 16, 2011, 2:48 a.m.
On Tue, Feb 15, 2011 at 20:47, Brian Norris wrote:
> We must use "long long" and "unsigned long long" types when
> implementing the functions "simple_strtoll()" and "simple_strtoull()",
> respectively. This prevents casting/truncation errors on systems where
> "long" is not the same size as "long long" (that is, on most systems).

Acked-by: Mike Frysinger <vapier@gentoo.org>
-mike
Artem Bityutskiy - Feb. 25, 2011, 8:49 a.m.
On Tue, 2011-02-15 at 17:47 -0800, Brian Norris wrote:
> We must use "long long" and "unsigned long long" types when
> implementing the functions "simple_strtoll()" and "simple_strtoull()",
> respectively. This prevents casting/truncation errors on systems where
> "long" is not the same size as "long long" (that is, on most systems).
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>

Pushed, thank you!

Patch

diff --git a/include/common.h b/include/common.h
index eb8d5fc..2e5c2a0 100644
--- a/include/common.h
+++ b/include/common.h
@@ -108,9 +108,9 @@  static inline type simple_##func(const char *snum, int *error) \
 	return ret; \
 }
 simple_strtoX(strtol, long int)
-simple_strtoX(strtoll, long int)
+simple_strtoX(strtoll, long long int)
 simple_strtoX(strtoul, unsigned long int)
-simple_strtoX(strtoull, unsigned long int)
+simple_strtoX(strtoull, unsigned long long int)
 
 #include "xalloc.h"