summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2013-10-04 11:38:03 +0200
committerDaniel Friesel <derf@finalrewind.org>2013-10-04 11:38:03 +0200
commit6e37676eeb19cfea01180dd6bd00fe888131a196 (patch)
treeccbf5dc0de4b95e4aed1b262b2ff8e8ae3485ebe
parenteaf81540a6b73d41c9862024f0f4507cdfbfc584 (diff)
i2cset: use strtol for all conversions
-rw-r--r--commandline/i2cset.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/commandline/i2cset.c b/commandline/i2cset.c
index c6333c5..5a3bc4b 100644
--- a/commandline/i2cset.c
+++ b/commandline/i2cset.c
@@ -6,7 +6,7 @@
int main(int argc, char **argv)
{
- int i, address, got_ack;
+ int i, address, cmdbuf, got_ack;
char *conv_err;
i2c_init();
@@ -27,7 +27,12 @@ int main(int argc, char **argv)
got_ack = i2c_tx_byte(address << 1);
for (i = 2; i < argc; i++) {
- i2c_tx_byte(atoi(argv[i]));
+ cmdbuf = strtol(argv[i], &conv_err, 0);
+ if (conv_err && *conv_err) {
+ fprintf(stderr, "write command: conversion error at '%s'", conv_err);
+ return 2;
+ }
+ i2c_tx_byte(cmdbuf);
}
i2c_stop();