Skip to content

Commit

Permalink
ctdb-ipalloc: Fix signed/unsigned comparisons by declaring as unsigned
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Schwenke <[email protected]>
Reviewed-by: Amitay Isaacs <[email protected]>
  • Loading branch information
martin-schwenke authored and Amitay Isaacs committed Jun 5, 2019
1 parent 18b4a3a commit 86666d6
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
8 changes: 4 additions & 4 deletions ctdb/server/ipalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static int getips_count_callback(void *param, void *data)
static struct public_ip_list *
create_merged_ip_list(struct ipalloc_state *ipalloc_state)
{
int i, j;
unsigned int i, j;
struct public_ip_list *ip_list;
struct ctdb_public_ip_list *public_ips;
struct trbt_tree *ip_tree;
Expand Down Expand Up @@ -147,7 +147,7 @@ create_merged_ip_list(struct ipalloc_state *ipalloc_state)
static bool populate_bitmap(struct ipalloc_state *ipalloc_state)
{
struct public_ip_list *ip = NULL;
int i, j;
unsigned int i, j;

for (ip = ipalloc_state->all_ips; ip != NULL; ip = ip->next) {

Expand Down Expand Up @@ -210,14 +210,14 @@ void ipalloc_set_public_ips(struct ipalloc_state *ipalloc_state,
* right now... */
bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state)
{
int i;
unsigned int i;
bool have_ips = false;

for (i=0; i < ipalloc_state->num; i++) {
struct ctdb_public_ip_list *ips =
ipalloc_state->known_public_ips;
if (ips[i].num != 0) {
int j;
unsigned int j;
have_ips = true;
/* Succeed if an address is hosted on node i */
for (j=0; j < ips[i].num; j++) {
Expand Down
7 changes: 4 additions & 3 deletions ctdb/server/ipalloc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
/* Given a physical node, return the number of
public addresses that is currently assigned to this node.
*/
int node_ip_coverage(int32_t pnn, struct public_ip_list *ips)
int node_ip_coverage(uint32_t pnn, struct public_ip_list *ips)
{
int num=0;

Expand Down Expand Up @@ -82,8 +82,9 @@ bool can_node_takeover_ip(struct ipalloc_state *ipalloc_state,
int find_takeover_node(struct ipalloc_state *ipalloc_state,
struct public_ip_list *ip)
{
int pnn, min=0, num;
int i, numnodes;
unsigned int pnn;
int min=0, num;
unsigned int i, numnodes;

numnodes = ipalloc_state->num;
pnn = -1;
Expand Down
17 changes: 9 additions & 8 deletions ctdb/server/ipalloc_lcp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ static uint32_t ip_distance(ctdb_sock_addr *ip1, ctdb_sock_addr *ip2)
*/
static uint32_t ip_distance_2_sum(ctdb_sock_addr *ip,
struct public_ip_list *ips,
int pnn)
unsigned int pnn)
{
struct public_ip_list *t;
uint32_t d;
Expand Down Expand Up @@ -109,7 +109,8 @@ static uint32_t ip_distance_2_sum(ctdb_sock_addr *ip,
/* Return the LCP2 imbalance metric for addresses currently assigned
to the given node.
*/
static uint32_t lcp2_imbalance(struct public_ip_list * all_ips, int pnn)
static uint32_t lcp2_imbalance(struct public_ip_list * all_ips,
unsigned int pnn)
{
struct public_ip_list *t;

Expand All @@ -132,7 +133,7 @@ static bool lcp2_init(struct ipalloc_state *ipalloc_state,
uint32_t **lcp2_imbalances,
bool **rebalance_candidates)
{
int i, numnodes;
unsigned int i, numnodes;
struct public_ip_list *t;

numnodes = ipalloc_state->num;
Expand Down Expand Up @@ -198,9 +199,9 @@ static void lcp2_allocate_unassigned(struct ipalloc_state *ipalloc_state,
uint32_t *lcp2_imbalances)
{
struct public_ip_list *t;
int dstnode, numnodes;
unsigned int dstnode, numnodes;

int minnode;
unsigned int minnode;
uint32_t mindsum, dstdsum, dstimbl;
uint32_t minimbl = 0;
struct public_ip_list *minip;
Expand Down Expand Up @@ -302,11 +303,11 @@ static void lcp2_allocate_unassigned(struct ipalloc_state *ipalloc_state,
* combination to move from the source node.
*/
static bool lcp2_failback_candidate(struct ipalloc_state *ipalloc_state,
int srcnode,
unsigned int srcnode,
uint32_t *lcp2_imbalances,
bool *rebalance_candidates)
{
int dstnode, mindstnode, numnodes;
unsigned int dstnode, mindstnode, numnodes;
uint32_t srcimbl, srcdsum, dstimbl, dstdsum;
uint32_t minsrcimbl, mindstimbl;
struct public_ip_list *minip;
Expand Down Expand Up @@ -402,7 +403,7 @@ static bool lcp2_failback_candidate(struct ipalloc_state *ipalloc_state,

struct lcp2_imbalance_pnn {
uint32_t imbalance;
int pnn;
unsigned int pnn;
};

static int lcp2_cmp_imbalance_pnn(const void * a, const void * b)
Expand Down
4 changes: 2 additions & 2 deletions ctdb/server/ipalloc_nondeterministic.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
static void basic_failback(struct ipalloc_state *ipalloc_state,
int num_ips)
{
int i, numnodes;
int maxnode, maxnum, minnode, minnum, num, retries;
unsigned int i, numnodes, maxnode, minnode;
int maxnum, minnum, num, retries;
struct public_ip_list *t;

numnodes = ipalloc_state->num;
Expand Down
2 changes: 1 addition & 1 deletion ctdb/server/ipalloc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct ipalloc_state {
bool can_node_takeover_ip(struct ipalloc_state *ipalloc_state,
int32_t pnn,
struct public_ip_list *ip);
int node_ip_coverage(int32_t pnn, struct public_ip_list *ips);
int node_ip_coverage(uint32_t pnn, struct public_ip_list *ips);
int find_takeover_node(struct ipalloc_state *ipalloc_state,
struct public_ip_list *ip);

Expand Down

0 comments on commit 86666d6

Please sign in to comment.