diff options
author | Nima Talebi <nima@autonomy.net.au> | 2009-05-24 00:26:23 +1000 |
---|---|---|
committer | Nima Talebi <nima@autonomy.net.au> | 2009-05-24 00:26:23 +1000 |
commit | af27ba4dd2ffdef8e4ee3abf187475c1b3303f71 (patch) | |
tree | e81421584332fb363e7b5ba22fecd585b083226e /src/util.c | |
parent | 6b1598c8b98699b115525155b43d19365e79dd08 (diff) | |
download | python-dmidecode-af27ba4dd2ffdef8e4ee3abf187475c1b3303f71.tar.gz python-dmidecode-af27ba4dd2ffdef8e4ee3abf187475c1b3303f71.tar.xz python-dmidecode-af27ba4dd2ffdef8e4ee3abf187475c1b3303f71.zip |
Completed preliminary reimplementation of type()
Updated test unit to match.
Throw an exception instead of returning None/False in some
functions.
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -190,11 +190,12 @@ int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, return -1; } -int is_int(const char *s) +long is_int(const char *s) { + long i = strtol(s, (char **)NULL, 10); char _s[3]; - snprintf(_s, 3, "%ld", strtol(s, (char **)NULL, 10)); - return !strcmp(s, _s); + snprintf(_s, 3, "%ld", i); + return strcmp(s, _s)==0 ? i : -1; } |