[Nut-upsdev] [nut-commits] svn commit r1285 - in trunk: . common include

Arjen de Korte nut+devel at de-korte.org
Fri Feb 8 08:25:27 UTC 2008


> Author: adkorte-guest
> Date: Fri Feb  8 07:09:51 2008
> New Revision: 1285
>
> Log:
> Cleanup and change the arguments to the upsdebug_hex() function so that it
> no longer requires casting to an unsigned char.
>
> Modified:
>    trunk/ChangeLog
>    trunk/common/common.c
>    trunk/include/common.h
>
> Modified: trunk/ChangeLog

I would like to do something similar to the following ser_* functions:

	ser_send_buf
	ser_send_buf_pace
	ser_get_buf_len
	ser_get_line_alert
	ser_get_line

Many drivers currently 'suffer' from compiler signedness warnings. We
could do away with these by typecasting everything to the 'correct' type,
but I think this is unwanted (and sometimes even counter productive).
There is not much point in making explicit that *buf argument is a pointer
to a char or unsigned char (or any other element for that matter) if we
specify the size_t of the object anyway (so there can't be any doubt about
its size).

My proposal is to use 'void *buf', in the same way as the read() and
write() prototypes do:

	read(int fildes, void *buf, size_t nbyte);
	write(int fildes, const void *buf, size_t nbyte);

Where typecasting is unavoidable (for instance, if we need to read/write
the buffer one character at a time) this can be done in the respective
ser_* functions. Bottomline is, as long as you pass these functions the
length of the buffer, anything goes (without explicit typecasts).

Best regards, Arjen
-- 
Eindhoven - The Netherlands
Key fingerprint - 66 4E 03 2C 9D B5 CB 9B  7A FE 7E C1 EE 88 BC 57




More information about the Nut-upsdev mailing list