[Nut-upsdev] drivers/bcmxcp.c portability issue

Charles Lepple clepple at gmail.com
Tue Dec 15 13:55:43 UTC 2009


On Tue, Dec 15, 2009 at 2:27 AM, Kjell Claesson
<kjell.claesson at epost.tidanet.se> wrote:

> So setting the length of the answer from the ID_block. So from 0 - 20 at the moment.
> It would be possible to hardcode this len, and leave some space for 4 outlet.
>
> Would be 2+6+6+6+6 = 26

If you do hardcode it, be sure to use something like fatalx() to
indicate whether there are more outlets than the code can handle. This
sounds unlikely, but it could happen if there is an error parsing
something earlier on.

Otherwise, as Arjen suggested, you could allocate it dynamically. The
xmalloc() function in common/common.c does out-of-memory checking for
you.

-- 
- Charles Lepple



More information about the Nut-upsdev mailing list