summaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
authorNima Talebi <nima@autonomy.net.au>2009-05-24 00:26:23 +1000
committerNima Talebi <nima@autonomy.net.au>2009-05-24 00:26:23 +1000
commitaf27ba4dd2ffdef8e4ee3abf187475c1b3303f71 (patch)
treee81421584332fb363e7b5ba22fecd585b083226e /src/util.c
parent6b1598c8b98699b115525155b43d19365e79dd08 (diff)
downloadpython-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.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/util.c b/src/util.c
index 58fd5ec..45bbd98 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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;
}