Re: LLVM warning in dev/ic/uhci.c

2013-12-05 Thread Brad Smith
On Wed, Dec 04, 2013 at 05:04:13PM +0100, Mark Kettenis wrote:
  Date: Wed, 4 Dec 2013 12:53:20 +0100
  From: Joerg Sonnenberger jo...@britannica.bec.de
  
  On Wed, Dec 04, 2013 at 12:24:50PM +0100, Mark Kettenis wrote:
   Sorry, but I disagree with LLVM here.  It shouldn't complain about
   static inline functions.
  
  Then mark them as unused, just like you would with a static variable you
  insist on keeping.
 
 Thanks Joerg, that might work.
 
 Brad, does LLVM like the diff below?  Note this changes ohci.c not
 uhci.c since I happened to have some uncommtted changes in the latter
 that I didn't want to touch.
 
 
 Index: ohci.c
 ===
 RCS file: /cvs/src/sys/dev/usb/ohci.c,v
 retrieving revision 1.116
 diff -u -p -r1.116 ohci.c
 --- ohci.c9 Nov 2013 08:46:05 -   1.116
 +++ ohci.c4 Dec 2013 16:01:42 -
 @@ -189,21 +189,21 @@ voidohci_dump_itds(struct ohci_soft_it
  #define OWRITE4(sc, r, x) \
   do { OBARR(sc); bus_space_write_4((sc)-iot, (sc)-ioh, (r), (x)); } while 
 (0)
  
 -static __inline u_int8_t
 +__unused static __inline u_int8_t
  OREAD1(struct ohci_softc *sc, bus_size_t r)
  {
   OBARR(sc);
   return bus_space_read_1(sc-iot, sc-ioh, r);
  }
  
 -static __inline u_int16_t
 +__unused static __inline u_int16_t
  OREAD2(struct ohci_softc *sc, bus_size_t r)
  {
   OBARR(sc);
   return bus_space_read_2(sc-iot, sc-ioh, r);
  }
  
 -static __inline u_int32_t
 +__unused static __inline u_int32_t
  OREAD4(struct ohci_softc *sc, bus_size_t r)
  {
   OBARR(sc);
 

Yes, this does indeed silence the warning. So you want something like the 
following?


Index: ohci.c
===
RCS file: /home/cvs/src/sys/dev/usb/ohci.c,v
retrieving revision 1.116
diff -u -p -r1.116 ohci.c
--- ohci.c  9 Nov 2013 08:46:05 -   1.116
+++ ohci.c  5 Dec 2013 20:41:53 -
@@ -189,21 +189,21 @@ void  ohci_dump_itds(struct ohci_soft_it
 #define OWRITE4(sc, r, x) \
  do { OBARR(sc); bus_space_write_4((sc)-iot, (sc)-ioh, (r), (x)); } while (0)
 
-static __inline u_int8_t
+__unused static __inline u_int8_t
 OREAD1(struct ohci_softc *sc, bus_size_t r)
 {
OBARR(sc);
return bus_space_read_1(sc-iot, sc-ioh, r);
 }
 
-static __inline u_int16_t
+__unused static __inline u_int16_t
 OREAD2(struct ohci_softc *sc, bus_size_t r)
 {
OBARR(sc);
return bus_space_read_2(sc-iot, sc-ioh, r);
 }
 
-static __inline u_int32_t
+__unused static __inline u_int32_t
 OREAD4(struct ohci_softc *sc, bus_size_t r)
 {
OBARR(sc);
Index: uhci.c
===
RCS file: /home/cvs/src/sys/dev/usb/uhci.c,v
retrieving revision 1.104
diff -u -p -r1.104 uhci.c
--- uhci.c  9 Nov 2013 08:46:05 -   1.104
+++ uhci.c  5 Dec 2013 20:42:24 -
@@ -238,21 +238,21 @@ void  uhci_dump(void);
  do { UBARR(sc); bus_space_write_4((sc)-iot, (sc)-ioh, (r), (x)); \
  } while (/*CONSTCOND*/0)
 
-static __inline u_int8_t
+__unused static __inline u_int8_t
 UREAD1(struct uhci_softc *sc, bus_size_t r)
 {
UBARR(sc);
return bus_space_read_1(sc-iot, sc-ioh, r);
 }
 
-static __inline u_int16_t
+__unused static __inline u_int16_t
 UREAD2(struct uhci_softc *sc, bus_size_t r)
 {
UBARR(sc);
return bus_space_read_2(sc-iot, sc-ioh, r);
 }
 
-static __inline u_int32_t
+__unused static __inline u_int32_t
 UREAD4(struct uhci_softc *sc, bus_size_t r)
 {
UBARR(sc);

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.



Re: LLVM warning in dev/ic/uhci.c

2013-12-04 Thread Mark Kettenis
 Date: Tue, 3 Dec 2013 17:55:00 -0500
 From: Brad Smith b...@comstyle.com
 
 Put UREAD4 under #ifdef UHCI_DEBUG as it is only used by a function
 for debugging which is also under UHCI_DEBUG.
 
 uhci.c:256:1: error: unused function 'UREAD4' [-Werror,-Wunused-function]
 
 OK?

Sorry, but I disagree with LLVM here.  It shouldn't complain about
static inline functions.  I think it makes sense to have a complete
set of access APIs.  And #ifdef'ing the unused ones out will
ultimately cause bitrot that we don't want.

I suspect the root cause of the problems is the GNU/ISO inline fuckup,
which means nobody can remember exactly what the semantics of
inline/static inline/extern inline is.  Perhaps we need to look at it
again now that we don't have gcc2 in the tree anymore.

For the same reasone I don't like similar changes like the ohci.c and
if_wpi.c ones.

 Index: uhci.c
 ===
 RCS file: /home/cvs/src/sys/dev/usb/uhci.c,v
 retrieving revision 1.104
 diff -u -p -r1.104 uhci.c
 --- uhci.c9 Nov 2013 08:46:05 -   1.104
 +++ uhci.c3 Dec 2013 22:50:28 -
 @@ -252,12 +252,14 @@ UREAD2(struct uhci_softc *sc, bus_size_t
   return bus_space_read_2(sc-iot, sc-ioh, r);
  }
  
 +#ifdef UHCI_DEBUG
  static __inline u_int32_t
  UREAD4(struct uhci_softc *sc, bus_size_t r)
  {
   UBARR(sc);
   return bus_space_read_4(sc-iot, sc-ioh, r);
  }
 +#endif
  
  #define UHCICMD(sc, cmd) UWRITE2(sc, UHCI_CMD, cmd)
  #define UHCISTS(sc) UREAD2(sc, UHCI_STS)



Re: LLVM warning in dev/ic/uhci.c

2013-12-04 Thread Joerg Sonnenberger
On Wed, Dec 04, 2013 at 12:24:50PM +0100, Mark Kettenis wrote:
 Sorry, but I disagree with LLVM here.  It shouldn't complain about
 static inline functions.

Then mark them as unused, just like you would with a static variable you
insist on keeping.

Joerg



Re: LLVM warning in dev/ic/uhci.c

2013-12-04 Thread Mark Kettenis
 Date: Wed, 4 Dec 2013 12:53:20 +0100
 From: Joerg Sonnenberger jo...@britannica.bec.de
 
 On Wed, Dec 04, 2013 at 12:24:50PM +0100, Mark Kettenis wrote:
  Sorry, but I disagree with LLVM here.  It shouldn't complain about
  static inline functions.
 
 Then mark them as unused, just like you would with a static variable you
 insist on keeping.

Thanks Joerg, that might work.

Brad, does LLVM like the diff below?  Note this changes ohci.c not
uhci.c since I happened to have some uncommtted changes in the latter
that I didn't want to touch.


Index: ohci.c
===
RCS file: /cvs/src/sys/dev/usb/ohci.c,v
retrieving revision 1.116
diff -u -p -r1.116 ohci.c
--- ohci.c  9 Nov 2013 08:46:05 -   1.116
+++ ohci.c  4 Dec 2013 16:01:42 -
@@ -189,21 +189,21 @@ void  ohci_dump_itds(struct ohci_soft_it
 #define OWRITE4(sc, r, x) \
  do { OBARR(sc); bus_space_write_4((sc)-iot, (sc)-ioh, (r), (x)); } while (0)
 
-static __inline u_int8_t
+__unused static __inline u_int8_t
 OREAD1(struct ohci_softc *sc, bus_size_t r)
 {
OBARR(sc);
return bus_space_read_1(sc-iot, sc-ioh, r);
 }
 
-static __inline u_int16_t
+__unused static __inline u_int16_t
 OREAD2(struct ohci_softc *sc, bus_size_t r)
 {
OBARR(sc);
return bus_space_read_2(sc-iot, sc-ioh, r);
 }
 
-static __inline u_int32_t
+__unused static __inline u_int32_t
 OREAD4(struct ohci_softc *sc, bus_size_t r)
 {
OBARR(sc);



LLVM warning in dev/ic/uhci.c

2013-12-03 Thread Brad Smith
Put UREAD4 under #ifdef UHCI_DEBUG as it is only used by a function
for debugging which is also under UHCI_DEBUG.

uhci.c:256:1: error: unused function 'UREAD4' [-Werror,-Wunused-function]

OK?


Index: uhci.c
===
RCS file: /home/cvs/src/sys/dev/usb/uhci.c,v
retrieving revision 1.104
diff -u -p -r1.104 uhci.c
--- uhci.c  9 Nov 2013 08:46:05 -   1.104
+++ uhci.c  3 Dec 2013 22:50:28 -
@@ -252,12 +252,14 @@ UREAD2(struct uhci_softc *sc, bus_size_t
return bus_space_read_2(sc-iot, sc-ioh, r);
 }
 
+#ifdef UHCI_DEBUG
 static __inline u_int32_t
 UREAD4(struct uhci_softc *sc, bus_size_t r)
 {
UBARR(sc);
return bus_space_read_4(sc-iot, sc-ioh, r);
 }
+#endif
 
 #define UHCICMD(sc, cmd) UWRITE2(sc, UHCI_CMD, cmd)
 #define UHCISTS(sc) UREAD2(sc, UHCI_STS)

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.