[Nut-upsuser] "no longer stale" when disconnected with 2.0.5

Peter Selinger selinger at mathstat.dal.ca
Tue Jan 30 03:45:19 CET 2007


Hi Arjen,

yes, you are right. The calls to dstate_dataok() in
usbhid_ups.c:hid_ups_walk() are somewhat random. I am worried about
this:

         if ( (retcode == -EPERM) || (retcode == -EPIPE)
            || (retcode == -ENODEV) || (retcode == -EACCES)
            || (retcode == -EIO) || (retcode == -ENOENT) )
            break;
         else
         {
            /* atomic call */
            dstate_dataok();
         }

In my opinion, it should be 

         if (retcode < 0) {  /* any device error */
	    break;
	 } else {            /* retcode == 0 */
	    /* do nothing */
         }

But that function is spaghetti code anyway. It is a perfect example of
how not to use structured programming - I think a function with 30
goto's would be easier to read than this particular pile of nested
if-then-else's, nested loops, 'break' statements, variable assignments
hidden inside "if" conditions, and other assorted mischief. It is on
my list of things to rewrite soon.

-- Peter

Arjen de Korte wrote:
> 
> [...]
> 
> > I hope this small part of the log helps.
> 
> Maybe someone with more experience with the 'usbhid-ups' driver is able t=
> o
> decipher what is going on. I'm still waiting for someone to send me a
> USB-HID UPS so that I can debug things like this myself.
> 
> Best regards, Arjen
> 
> 
> _______________________________________________
> Nut-upsuser mailing list
> Nut-upsuser at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/nut-upsuser
> 




More information about the Nut-upsuser mailing list