Fix clang compiler warnings (revealed some bugs)

This commit is contained in:
Andrew Bettison 2013-04-12 17:16:50 +09:30
parent a9a1ffecde
commit a8b88a462f
7 changed files with 18 additions and 22 deletions

2
cli.h
View File

@ -46,7 +46,7 @@ struct cli_parsed {
unsigned labelc;
const char *const *args;
unsigned argc;
unsigned varargi;
int varargi; // -1 means no var args
};
void _debug_cli_parsed(struct __sourceloc __whence, const struct cli_parsed *parsed);

View File

@ -1927,7 +1927,7 @@ int app_count_peers(const struct cli_parsed *parsed, void *context)
bzero(&a, sizeof(overlay_mdp_frame));
a.packetTypeAndFlags=MDP_GETADDRS;
a.addrlist.mode = MDP_ADDRLIST_MODE_ROUTABLE_PEERS;
a.addrlist.first_sid=0x7fffffff;
a.addrlist.first_sid = OVERLAY_MDP_ADDRLIST_MAX_SID_COUNT;
if (overlay_mdp_send(&a,MDP_AWAITREPLY,5000)){
if (a.packetTypeAndFlags==MDP_ERROR)
return WHYF(" MDP Server error #%d: '%s'",a.error.error,a.error.message);

View File

@ -315,7 +315,7 @@ ATOM(uint32_t, uid, 0, uint32_nonzero,, "Allowed UID for mon
END_STRUCT
STRUCT(mdp_iftype)
ATOM(uint32_t, tick_ms, -1, uint32_nonzero,, "Tick interval for this interface type")
ATOM(int32_t, tick_ms, -1, int32_nonneg,, "Tick interval for this interface type")
ATOM(int32_t, packet_interval, -1, int32_nonneg,, "Minimum interval between packets in microseconds")
END_STRUCT

View File

@ -250,7 +250,7 @@ int overlay_mdp_bind(const sid_t *localaddr, int port)
return 0;
}
int overlay_mdp_getmyaddr(int index, sid_t *sid)
int overlay_mdp_getmyaddr(unsigned index, sid_t *sid)
{
overlay_mdp_frame a;
memset(&a, 0, sizeof(a));
@ -258,7 +258,7 @@ int overlay_mdp_getmyaddr(int index, sid_t *sid)
a.packetTypeAndFlags=MDP_GETADDRS;
a.addrlist.mode = MDP_ADDRLIST_MODE_SELF;
a.addrlist.first_sid=index;
a.addrlist.last_sid=0x7fffffff;
a.addrlist.last_sid=OVERLAY_MDP_ADDRLIST_MAX_SID_COUNT;
a.addrlist.frame_sid_count=MDP_MAX_SID_REQUEST;
int result=overlay_mdp_send(&a,MDP_AWAITREPLY,5000);
if (result) {

View File

@ -794,19 +794,13 @@ static int search_subscribers(struct subscriber *subscriber, void *context){
int overlay_mdp_address_list(overlay_mdp_addrlist *request, overlay_mdp_addrlist *response){
if (config.debug.mdprequests)
DEBUGF("MDP_GETADDRS first_sid=%u mode=%d",
request->first_sid,
request->mode
);
DEBUGF("MDP_GETADDRS first_sid=%u mode=%d", request->first_sid, request->mode);
/* Prepare reply packet */
response->mode = request->mode;
response->first_sid = request->first_sid;
response->frame_sid_count = 0;
/* ... and constrain list for sanity */
if (response->first_sid<0) response->first_sid=0;
/* Populate with SIDs */
enum_subscribers(NULL, search_subscribers, response);

View File

@ -112,13 +112,13 @@ int process_incoming_frame(time_ms_t now, struct overlay_interface *interface, s
// duplicate the frame and queue it
int overlay_forward_payload(struct overlay_frame *f){
IN();
if (f->ttl<=0)
if (f->ttl == 0)
RETURN(0);
if (config.debug.overlayframes)
DEBUGF("Forwarding payload for %s, ttl=%d",
DEBUGF("Forwarding payload for %s, ttl=%u",
(f->destination?alloca_tohex_sid(f->destination->sid):"broadcast"),
f->ttl);
(unsigned)f->ttl);
/* Queue frame for dispatch.
Don't forget to put packet in the correct queue based on type.
@ -212,17 +212,18 @@ int parseMdpPacketHeader(struct decode_context *context, struct overlay_frame *f
frame->ttl = ttl_qos & 0x1F;
frame->queue = (ttl_qos >> 5) & 3;
}
frame->ttl--;
if (frame->ttl<=0){
forward=0;
if (frame->ttl == 0){
forward = 0;
if (config.debug.overlayframes)
DEBUGF("Don't forward when TTL expired");
}
} else
--frame->ttl;
if (flags & PAYLOAD_FLAG_LEGACY_TYPE){
frame->type=ob_get(buffer);
if (frame->type<0)
int ftype = ob_get(buffer);
if (ftype == -1)
RETURN(WHY("Unable to read type"));
frame->type = ftype;
}else
frame->type=OF_TYPE_DATA;

View File

@ -622,6 +622,7 @@ typedef struct overlay_mdp_error {
typedef struct overlay_mdp_addrlist {
int mode;
#define OVERLAY_MDP_ADDRLIST_MAX_SID_COUNT (~(unsigned int)0)
unsigned int server_sid_count;
unsigned int first_sid;
unsigned int last_sid;
@ -693,7 +694,7 @@ void cli_put_long(int64_t value, const char *delim);
void cli_put_string(const char *value, const char *delim);
void cli_put_hexvalue(const unsigned char *value, int length, const char *delim);
int overlay_mdp_getmyaddr(int index, sid_t *sid);
int overlay_mdp_getmyaddr(unsigned index, sid_t *sid);
int overlay_mdp_bind(const sid_t *localaddr, int port) ;
int overlay_route_node_info(overlay_mdp_nodeinfo *node_info);
int overlay_interface_register(char *name,