The other implementations just show Xs for the missing data and carry on.
---
 toys/other/i2ctools.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
From 65667bc633f4eb8079e380dfa4bdc3273bd82df5 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Mon, 6 Sep 2021 18:19:29 -0700
Subject: [PATCH] i2cdump: fix behavior on read failure.

The other implementations just show Xs for the missing data and carry on.
---
 toys/other/i2ctools.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/toys/other/i2ctools.c b/toys/other/i2ctools.c
index bac891a5..18341591 100644
--- a/toys/other/i2ctools.c
+++ b/toys/other/i2ctools.c
@@ -247,8 +247,11 @@ void i2cdump_main(void)
   for (row = 0; row<=0xf0; row += 16) {
     xprintf("%02x:", row & 0xf0);
     for (addr = row; addr<row+16; ++addr) {
-      if (i2c_read_byte(fd, addr, &byte)==-1) perror_exit("i2c_read_byte");
-      printf(" %02x", byte);
+      if (!i2c_read_byte(fd, addr, &byte)) printf(" %02x", byte);
+      else {
+        printf(" XX");
+        byte = 'X';
+      }
       toybuf[addr-row] = isprint(byte) ? byte : (byte ? '?' : '.');
     }
     printf("    %16.16s\n", toybuf);
-- 
2.33.0.153.gba50c8fa24-goog

_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to