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

Arjen de Korte nut+devel at de-korte.org
Tue Dec 15 08:19:36 UTC 2009

Citeren Kjell Claesson <kjell.claesson op epost.tidanet.se>:

>> I ran into a portability issue with drivers/bcmxcp.c in nut-2.4.1 on
>> my UnixWare 7.1.4 machine. The error I get is
>> .....
>> UX:acomp: ERROR: "/opt/src/utils/nut-2.4.1/drivers/bcmxcp.c", line 835:
>>  integral constant expression expected .....
>> Looking at the code we see
>> .....
>> int init_outlet(unsigned char len)
>> {
>>         unsigned char answer[len];
>> .....

I agree with Tim, the above indeed isn't portable.

>> Although gcc can handle it, it's not portable C code.
>> What size should the answer array be?
> It depends on the ups.

If the size of the answer isn't known at compile time, you should  
either allocate it dynamically with malloc() or calloc() (at runtime)  
or hardcode the size so big that any reply should fit in it.

Best regards, Arjen
Please keep list traffic on the list

More information about the Nut-upsdev mailing list