[Nut-upsuser] Setvar in bcmxcp

Charles Lepple clepple at gmail.com
Tue Sep 13 11:56:28 UTC 2011


Rich,

Thanks for submitting this patch.

One small thing I noticed on the Solaris buildbot:

../../drivers/bcmxcp.c: In function `setvar':
../../drivers/bcmxcp.c:1733: warning: comparison is always false due  
to limited range of data type
The code:
int setvar (const char *varname, const char *val)
{
[...]
       int16_t sec;    /* limit the size of the timer, to avoid  
overflow */
[...]
         sec = atoi(val);
         /* Check value:
          *      0-32767 are valid values
          *      -1 means no Automatic off or restart
          * for Auto Off Delay:
          *      0-30 are valid but ill-advised */
         if (sec < -1 || sec > 0x7FFF) {
                 return STAT_SET_INVALID;
         }

I think the value of atoi() should probably be assigned to a larger  
int variable, and leave the conditional there to guard against out-of- 
range values.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20110913/133d9ec8/attachment-0001.html>


More information about the Nut-upsuser mailing list