libftdi Archives

Subject: Fix GCC warnings

From: bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 31 Jul 2020 11:00:50 +0200
Hello,

when compiling ftdi.c in the context of blackmagic debug, more enabled
warnings and -Werror made me to add appended fixes.

Fixing the signedness of baudrate would probably be more logically by
making all baudrate and clk unsigned, but would need more code
change. I decides to make clk signed as a fix with minimal
impact. The FTDI chips are far away from 2 GHz clock rate...
-- 
Uwe Bonnes                bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 1623569 ------- Fax. 06151 1623305 ---------
>From 006505240623cf99efa9539fa2ff1d6a82d8d082 Mon Sep 17 00:00:00 2001
From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 31 Jul 2020 10:58:24 +0200
Subject: Fix GCC fall-through warnings.

---
 src/ftdi.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/ftdi.c b/src/ftdi.c
index f5b7018..987367c 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -3044,10 +3044,13 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
         case TYPE_2232H:
         case TYPE_4232H:
             i += 2;
+                       /* Fall through*/
         case TYPE_R:
             i += 2;
+                       /* Fall through*/
         case TYPE_2232C:
             i += 2;
+                       /* Fall through*/
         case TYPE_AM:
         case TYPE_BM:
             i += 0x94;
@@ -3438,15 +3441,20 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi)
     {
         case TYPE_230X:
             free_start += 2;
+                       /* Fall through*/
         case TYPE_232H:
             free_start += 6;
+                       /* Fall through*/
         case TYPE_2232H:
         case TYPE_4232H:
             free_start += 2;
+                       /* Fall through*/
         case TYPE_R:
             free_start += 2;
+                       /* Fall through*/
         case TYPE_2232C:
             free_start++;
+                       /* Fall through*/
         case TYPE_AM:
         case TYPE_BM:
             free_start += 0x14;
-- 
2.26.2

>From d74c7da8d35bea84f80d9f57b8a4432724353916 Mon Sep 17 00:00:00 2001
From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 31 Jul 2020 10:58:45 +0200
Subject: Fix baudrate vs clk signedness.

---
 src/ftdi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index 987367c..03d7b07 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -1328,7 +1328,7 @@ static int ftdi_to_clkbits_AM(int baudrate, unsigned long 
*encoded_divisor)
    AM Type chips have only four fractional subdivisors at value[15:14]
    for subdivisors 0, 0.5, 0.25, 0.125
 */
-static int ftdi_to_clkbits(int baudrate, unsigned int clk, int clk_div, 
unsigned long *encoded_divisor)
+static int ftdi_to_clkbits(int baudrate, int clk, int clk_div, unsigned long 
*encoded_divisor)
 {
     static const char frac_code[8] = {0, 3, 2, 4, 1, 5, 6, 7};
     int best_baud = 0;
-- 
2.26.2


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

Current Thread