[Nut-upsdev] Small fixes needed for Riello driver
Charles Lepple
clepple at gmail.com
Tue Apr 9 12:37:51 UTC 2013
Elio,
1) The comment block in drivers/riello.h points to the Megatec protocol documentation. Are the links in drivers/riello.c correct? If so, we can change the .h file to match the .c file.
2) clang caught this bug:
drivers/riello.c:984:28: warning: argument to 'sizeof' in 'memset' call is the same expression as the destination; did you mean to provide an explicit length? [-Wsizeof-pointer-memaccess]
As a result, memset() will only clear the first 4 or 8 bytes of the buffer.
This is in Git master (12d6e76).
I would recommend creating a typedef for the buffer which includes the size (e.g. BYTE[128] rather than BYTE*), or using a #define and changing the sizeof() to reference that definition.
Also, is there a particular need for the BYTE/WORD/DWORD typedefs? It is useful to have consistency across all the drivers, and in this case, I would use the stdint.h definitions to make the size and signed-ness explicit (e.g. uint16_t instead of WORD).
--
Charles Lepple
clepple at gmail
More information about the Nut-upsdev
mailing list