Skip to contentSkip to conversation

mtd-utils: common.h: simple_strtoll type usage

PATCH In review Brian Norris 3 participants 3 messages Feb 16, 2011 – Feb 25, 2011 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd-utils: common.h: simple_strtoll type usage

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

---
 include/common.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/common.h +2 -2
index eb8d5fc..2e5c2a0 100644
@@ -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"
 
Signature · 1 line
1.7.0.4
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Brian Norris

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

-mike

#2 lore raw
In reply to Brian Norris
Quoted 6 lines · Brian Norris

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

Pushed, thank you!

Signature · 2 lines
Best Regards,
Artem Bityutskiy (Артём Битюцкий)