From 6e37676eeb19cfea01180dd6bd00fe888131a196 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Fri, 4 Oct 2013 11:38:03 +0200 Subject: i2cset: use strtol for all conversions --- commandline/i2cset.c | 9 +++++++-- 1 file 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(); -- cgit v1.2.3