[Nut-upsdev] Changes to usbhid-ups driver

Peter Selinger selinger at mathstat.dal.ca
Thu Sep 6 02:32:35 UTC 2007


Arjen de Korte wrote:
> 
> [...]
> 
> >> Are these in HIDDumpTree maybe? It's a real simple addition to the
> >> subdriver (see r1087) and having the actual productname instead of just
> >> 'unknown' would be nice.
> >
> > I'm unable to compile r1088. I get lots of undefined references in
> > libhid.c, see below. It seems that the global variables pDesc and
> > reportbuf are declared in libhid.h, but not defined.
> 
> That is weird, they are indeed declared in libhid.h:
> 
> 85 	extern HIDDesc_t        *pDesc; /* parsed Report Descriptor */
> 95 	extern reportbuf_t      *reportbuf;     /* buffer for most recent
> reports */
> 
> But the definition is in usbhid-ups.c, so that should be resolved at link
> time:
> 
> 98 	/* global variables */
> 99 	HIDDesc_t       *pDesc = NULL;          /* parsed Report Descriptor */
> 100 	reportbuf_t     *reportbuf = NULL;      /* buffer for most recent
> reports */
> 
> Why your linker (assume that is complaining) fails to see these, is beyond
> me.

I see. The linker fails to see these because it is linking
tripplite_usb at the time the error occurs, and not usbhid-ups. That
driver uses libhid.o, but not usbhid-ups.o.

It seems that variables used in libhid.c should be defined in
libhid.c, not usbhid-ups.c. Yet one more reason to eliminate global
variables!

-- Peter



More information about the Nut-upsdev mailing list