Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#3692 closed defect (duplicate)

Fix compiler warnings in master

Reported by: karsten Owned by:
Priority: Low Milestone: Tor: 0.2.3.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: tor-client
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

When compiling current master with --enable-gcc-warnings set, I get the following errors:

connection_edge.c: In function ‘connection_edge_process_inbuf’:
connection_edge.c:160: error: format ‘%ld’ expects type ‘long int’, but argument 7 has type ‘size_t’
connection_edge.c: In function ‘connection_ap_handshake_send_begin’:
connection_edge.c:2444: error: format ‘%ld’ expects type ‘long int’, but argument 5 has type ‘size_t’
connection_edge.c:2444: error: format ‘%ld’ expects type ‘long int’, but argument 6 has type ‘size_t’

I changed %ld into %d in those lines in my sources which made the warnings go away. But I'm not sure if that's the right fix, which is why I didn't attach a patch.

Child Tickets

Change History (4)

comment:1 Changed 8 years ago by nickm

Unfortunately, It's not the right fix. You actually need to get the types to match between format strings and printf args.

%ld takes a long int; %d takes an int; size_t is neither.

Now, if we could assume full c99 support, we could say "%zu" here, but instead, if this is just for log messages, I think we're better off leaving the format as %ld, and casting the arguments to long.

comment:2 Changed 8 years ago by Sebastian

Resolution: duplicate
Status: newclosed

oh, I hadn't seen this bug when filing #3703 and writing the patch. 3703 has the fix for this bug too. I'm closing this as duplicate because the other bug has more information

comment:3 Changed 7 years ago by nickm

Keywords: tor-client added

comment:4 Changed 7 years ago by nickm

Component: Tor ClientTor
Note: See TracTickets for help on using tickets.