Use uint32_t instead of long int for connection options.
Options should have a fixed width anyway, but this also fixes a possible MinGW compiler bug where %lx tries to print a 64 bit value, even though a long int is only 32 bits.
This commit is contained in:
		
							parent
							
								
									468f393c4f
								
							
						
					
					
						commit
						5cbddc68ba
					
				
					 8 changed files with 12 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -120,7 +120,7 @@ void dump_connections(void) {
 | 
			
		|||
 | 
			
		||||
	for(node = connection_tree->head; node; node = node->next) {
 | 
			
		||||
		c = node->data;
 | 
			
		||||
		logger(LOG_DEBUG, " %s at %s options %lx socket %d status %04x outbuf %d/%d/%d",
 | 
			
		||||
		logger(LOG_DEBUG, " %s at %s options %x socket %d status %04x outbuf %d/%d/%d",
 | 
			
		||||
			   c->name, c->hostname, c->options, c->socket, bitfield_to_int(&c->status, sizeof c->status),
 | 
			
		||||
			   c->outbufsize, c->outbufstart, c->outbuflen);
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -56,7 +56,7 @@ typedef struct connection_t {
 | 
			
		|||
	int protocol_version;		/* used protocol */
 | 
			
		||||
 | 
			
		||||
	int socket;					/* socket used for this connection */
 | 
			
		||||
	long int options;			/* options for this connection */
 | 
			
		||||
	uint32_t options;			/* options for this connection */
 | 
			
		||||
	connection_status_t status;	/* status info */
 | 
			
		||||
	int estimated_weight;		/* estimation for the weight of the edge for this connection */
 | 
			
		||||
	struct timeval start;		/* time this connection was started, used for above estimation */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -118,7 +118,7 @@ void dump_edges(void) {
 | 
			
		|||
		for(node2 = n->edge_tree->head; node2; node2 = node2->next) {
 | 
			
		||||
			e = node2->data;
 | 
			
		||||
			address = sockaddr2hostname(&e->address);
 | 
			
		||||
			logger(LOG_DEBUG, " %s to %s at %s options %lx weight %d",
 | 
			
		||||
			logger(LOG_DEBUG, " %s to %s at %s options %x weight %d",
 | 
			
		||||
				   e->from->name, e->to->name, address, e->options, e->weight);
 | 
			
		||||
			free(address);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,7 +31,7 @@ typedef struct edge_t {
 | 
			
		|||
	struct node_t *to;
 | 
			
		||||
	sockaddr_t address;
 | 
			
		||||
 | 
			
		||||
	long int options;			/* options turned on for this edge */
 | 
			
		||||
	uint32_t options;			/* options turned on for this edge */
 | 
			
		||||
	int weight;					/* weight of this edge */
 | 
			
		||||
 | 
			
		||||
	struct connection_t *connection;	/* connection associated with this edge, if available */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -162,7 +162,7 @@ void dump_nodes(void) {
 | 
			
		|||
 | 
			
		||||
	for(node = node_tree->head; node; node = node->next) {
 | 
			
		||||
		n = node->data;
 | 
			
		||||
		logger(LOG_DEBUG, " %s at %s cipher %d digest %d maclength %d compression %d options %lx status %04x nexthop %s via %s pmtu %d (min %d max %d)",
 | 
			
		||||
		logger(LOG_DEBUG, " %s at %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s pmtu %d (min %d max %d)",
 | 
			
		||||
			   n->name, n->hostname, n->outcipher ? n->outcipher->nid : 0,
 | 
			
		||||
			   n->outdigest ? n->outdigest->type : 0, n->outmaclength, n->outcompression,
 | 
			
		||||
			   n->options, bitfield_to_int(&n->status, sizeof n->status), n->nexthop ? n->nexthop->name : "-",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,7 +39,7 @@ typedef struct node_status_t {
 | 
			
		|||
 | 
			
		||||
typedef struct node_t {
 | 
			
		||||
	char *name;				/* name of this node */
 | 
			
		||||
	long int options;			/* options turned on for this node */
 | 
			
		||||
	uint32_t options;			/* options turned on for this node */
 | 
			
		||||
 | 
			
		||||
	sockaddr_t address;			/* his real (internet) ip to send UDP packets to */
 | 
			
		||||
	char *hostname;				/* the hostname of its real ip */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -455,7 +455,7 @@ bool send_ack(connection_t *c) {
 | 
			
		|||
 | 
			
		||||
	get_config_int(lookup_config(c->config_tree, "Weight"), &c->estimated_weight);
 | 
			
		||||
 | 
			
		||||
	return send_request(c, "%d %s %d %lx", ACK, myport, c->estimated_weight, c->options);
 | 
			
		||||
	return send_request(c, "%d %s %d %x", ACK, myport, c->estimated_weight, c->options);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void send_everything(connection_t *c) {
 | 
			
		||||
| 
						 | 
				
			
			@ -494,10 +494,10 @@ bool ack_h(connection_t *c) {
 | 
			
		|||
	char hisport[MAX_STRING_SIZE];
 | 
			
		||||
	char *hisaddress, *dummy;
 | 
			
		||||
	int weight, mtu;
 | 
			
		||||
	long int options;
 | 
			
		||||
	uint32_t options;
 | 
			
		||||
	node_t *n;
 | 
			
		||||
 | 
			
		||||
	if(sscanf(c->buffer, "%*d " MAX_STRING " %d %lx", hisport, &weight, &options) != 3) {
 | 
			
		||||
	if(sscanf(c->buffer, "%*d " MAX_STRING " %d %x", hisport, &weight, &options) != 3) {
 | 
			
		||||
		logger(LOG_ERR, "Got bad %s from %s (%s)", "ACK", c->name,
 | 
			
		||||
			   c->hostname);
 | 
			
		||||
		return false;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -41,7 +41,7 @@ bool send_add_edge(connection_t *c, const edge_t *e) {
 | 
			
		|||
 | 
			
		||||
	sockaddr2str(&e->address, &address, &port);
 | 
			
		||||
 | 
			
		||||
	x = send_request(c, "%d %x %s %s %s %s %lx %d", ADD_EDGE, rand(),
 | 
			
		||||
	x = send_request(c, "%d %x %s %s %s %s %x %d", ADD_EDGE, rand(),
 | 
			
		||||
					 e->from->name, e->to->name, address, port,
 | 
			
		||||
					 e->options, e->weight);
 | 
			
		||||
	free(address);
 | 
			
		||||
| 
						 | 
				
			
			@ -58,10 +58,10 @@ bool add_edge_h(connection_t *c) {
 | 
			
		|||
	char to_address[MAX_STRING_SIZE];
 | 
			
		||||
	char to_port[MAX_STRING_SIZE];
 | 
			
		||||
	sockaddr_t address;
 | 
			
		||||
	long int options;
 | 
			
		||||
	uint32_t options;
 | 
			
		||||
	int weight;
 | 
			
		||||
 | 
			
		||||
	if(sscanf(c->buffer, "%*d %*x "MAX_STRING" "MAX_STRING" "MAX_STRING" "MAX_STRING" %lx %d",
 | 
			
		||||
	if(sscanf(c->buffer, "%*d %*x "MAX_STRING" "MAX_STRING" "MAX_STRING" "MAX_STRING" %x %d",
 | 
			
		||||
			  from_name, to_name, to_address, to_port, &options, &weight) != 6) {
 | 
			
		||||
		logger(LOG_ERR, "Got bad %s from %s (%s)", "ADD_EDGE", c->name,
 | 
			
		||||
			   c->hostname);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue