[PATCH] tcp.c: elimiate warining "format '%ld', but argument has type 'ssize_t'
Signed-off-by: Wang Tinggong <wangtinggong@gmail.com> --- src/lib/tcp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/lib/tcp.c b/src/lib/tcp.c index 2f0946b..4a691c1 100644 --- a/src/lib/tcp.c +++ b/src/lib/tcp.c @@ -323,7 +323,7 @@ int fr_tcp_read_packet(RADIUS_PACKET *packet, int flags) DEBUG("rad_recv: Packet from %s code=%d", buffer, packet->code); } - DEBUG(", id=%d, length=%ld\n", packet->id, packet->data_len); + DEBUG(", id=%d, length=%d\n", packet->id, packet->data_len); } return 1; /* done reading the packet */ -- 1.6.0.6
Wang Tinggong wrote:
- DEBUG(", id=%d, length=%ld\n", packet->id, packet->data_len); + DEBUG(", id=%d, length=%d\n", packet->id, packet->data_len);
This depends strongly on your local system. There's no need for the patch to fix a compiler warning. Alan DeKok.
On February 1, 2010 11:40:01 AM +0100 Alan DeKok <aland@deployingradius.com> wrote:
Wang Tinggong wrote:
- DEBUG(", id=%d, length=%ld\n", packet->id, packet->data_len); + DEBUG(", id=%d, length=%d\n", packet->id, packet->data_len);
This depends strongly on your local system. There's no need for the patch to fix a compiler warning.
Yup. If anything, the patch should use the inttypes.h specifiers (PRId32 et al), not changing from one platform-specific format to another. Well I'm assuming that packet->data_len is a fixed-size type like int32. If it is in fact a long than %ld is correct, ovbiously. -frank
Frank Cusack wrote:
Yup. If anything, the patch should use the inttypes.h specifiers (PRId32 et al), not changing from one platform-specific format to another. Well I'm assuming that packet->data_len is a fixed-size type like int32. If it is in fact a long than %ld is correct, ovbiously.
I took a look... it's size_t. Which is 0-4K for any RADIUS packet. The "portable" fix is to change %ld to %d, and to add an explicit cast: (int) packet->data_len. Casts are annoying, but safe here. Alan DeKok/
On February 1, 2010 8:39:25 PM +0100 Alan DeKok <aland@deployingradius.com> wrote:
Frank Cusack wrote:
Yup. If anything, the patch should use the inttypes.h specifiers (PRId32 et al), not changing from one platform-specific format to another. Well I'm assuming that packet->data_len is a fixed-size type like int32. If it is in fact a long than %ld is correct, ovbiously.
I took a look... it's size_t. Which is 0-4K for any RADIUS packet.
The "portable" fix is to change %ld to %d, and to add an explicit cast: (int) packet->data_len.
There is a size_t printf format specifier. %z I think. Barring that, since size_t is probably "at least" 32 bits and int is only guaranteed to be 16 bits, and also since size_t is unsigned, the more correct fix would be casting to unsigned long. But %z if that is correct is better. -frank
--On Monday, February 01, 2010 04:17:56 PM -0500 Frank Cusack <fcusack@fcusack.com> wrote:
I took a look... it's size_t. Which is 0-4K for any RADIUS packet.
The "portable" fix is to change %ld to %d, and to add an explicit cast: (int) packet->data_len.
There is a size_t printf format specifier. %z I think. Barring that, since size_t is probably "at least" 32 bits and int is only guaranteed to be 16 bits, and also since size_t is unsigned, the more correct fix would be casting to unsigned long. But %z if that is correct is better.
Yes, it's 'z', but it's a size modifier, not a conversion. So '%zd' will work to print a size_t value in decimal. If your printf conforms to C99, which may not be a constraint FreeRadius wishes to adopt. -- Jeff
participants (4)
-
Alan DeKok -
Frank Cusack -
Jeffrey Hutzelman -
Wang Tinggong