[Nut-upsuser] Setvar in bcmxcp
Arnaud Quette
aquette.dev at gmail.com
Tue Sep 13 12:17:09 UTC 2011
2011/9/13 Charles Lepple <clepple at gmail.com>
> 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.
>
my fault: the int16_t was a try to limit out-of-range before reaching this.
I also noticed it while working on the BB issues, so I'll revert it now.
thanks for pointing it.
Arnaud
--
Linux / Unix Expert R&D - Eaton - http://powerquality.eaton.com
Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/
Debian Developer - http://www.debian.org
Free Software Developer - http://arnaud.quette.free.fr/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20110913/21222186/attachment.html>
More information about the Nut-upsuser
mailing list