libftdi Archives

Subject: Remove some code duplication

From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Mon, 20 Jun 2011 14:50:16 +0200
Remove some code duplication

-- 
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
>From b345304720bf322b022fdb2194f1365c1d786711 Mon Sep 17 00:00:00 2001
From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 20 Jun 2011 14:37:07 +0200
Subject: Don't duplicate ftdi_read_eeprom() as it is always done

---
 examples/eeprom.c |   20 +++++---------------
 1 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/examples/eeprom.c b/examples/eeprom.c
index e2c8052..8d74d2c 100644
--- a/examples/eeprom.c
+++ b/examples/eeprom.c
@@ -177,23 +177,13 @@ int main(int argc, char **argv)
                     f, ftdi_get_error_string(ftdi));
             exit(-1);
         }
-        f = ftdi_read_eeprom(ftdi);
-        if (f < 0)
-        {
-            fprintf(stderr, "ftdi_read_eeprom: %d (%s)\n",
-                    f, ftdi_get_error_string(ftdi));
-            exit(-1);
-        }
     }
-    else
+    f = ftdi_read_eeprom(ftdi);
+    if (f < 0)
     {
-        f = ftdi_read_eeprom(ftdi);
-        if (f < 0)
-        {
-            fprintf(stderr, "ftdi_read_eeprom: %d (%s)\n",
-                    f, ftdi_get_error_string(ftdi));
-            exit(-1);
-        }
+        fprintf(stderr, "ftdi_read_eeprom: %d (%s)\n",
+                f, ftdi_get_error_string(ftdi));
+        exit(-1);
     }
 
 
-- 
1.7.3.4


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread
  • Remove some code duplication, Uwe Bonnes <=