batman-adv: Reduce usage of char
authorSven Eckelmann <sven@narfation.org>
Wed, 15 Jun 2011 07:41:37 +0000 (09:41 +0200)
committerSven Eckelmann <sven@narfation.org>
Mon, 20 Jun 2011 09:37:18 +0000 (11:37 +0200)
char was used in different places to store information without really
using the characteristics of that data type or by ignoring the fact that
char has not a well defined signedness.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
net/batman-adv/aggregation.c
net/batman-adv/aggregation.h
net/batman-adv/bitarray.c
net/batman-adv/bitarray.h
net/batman-adv/gateway_client.c
net/batman-adv/gateway_common.c
net/batman-adv/main.h
net/batman-adv/routing.c
net/batman-adv/send.c
net/batman-adv/send.h
net/batman-adv/soft-interface.c

index 4080970ade7de8adf3806966cc680bb14b4a939d..29c67405347b5abcc8a730dd205346ac65b815f7 100644 (file)
@@ -195,7 +195,7 @@ static void aggregate(struct forw_packet *forw_packet_aggr,
 
 void add_bat_packet_to_list(struct bat_priv *bat_priv,
                            unsigned char *packet_buff, int packet_len,
-                           struct hard_iface *if_incoming, char own_packet,
+                           struct hard_iface *if_incoming, int own_packet,
                            unsigned long send_time)
 {
        /**
index fedeb8d0e13fe52d2742c2df7938b757be0ece21..0547fd8ea3b988b6a7572a9725d315d5c4a52339 100644 (file)
@@ -35,7 +35,7 @@ static inline int aggregated_packet(int buff_pos, int packet_len, int num_tt)
 
 void add_bat_packet_to_list(struct bat_priv *bat_priv,
                            unsigned char *packet_buff, int packet_len,
-                           struct hard_iface *if_incoming, char own_packet,
+                           struct hard_iface *if_incoming, int own_packet,
                            unsigned long send_time);
 void receive_aggr_bat_packet(const struct ethhdr *ethhdr,
                             unsigned char *packet_buff, int packet_len,
index 3659a258ef49b2c2288f39608a4f91b267cf743d..c1f4bfc09cc3449051e2e1937dcda3ee44279ea0 100644 (file)
@@ -127,8 +127,8 @@ static void bit_reset_window(unsigned long *seq_bits)
  *  1 if the window was moved (either new or very old)
  *  0 if the window was not moved/shifted.
  */
-char bit_get_packet(void *priv, unsigned long *seq_bits,
-                   int32_t seq_num_diff, int8_t set_mark)
+int bit_get_packet(void *priv, unsigned long *seq_bits,
+                   int32_t seq_num_diff, int set_mark)
 {
        struct bat_priv *bat_priv = priv;
 
index 277c037456e9a5c3d920e4a378ed096f4204bf26..9c04422aeb07ded0614fc5936a1dd001d0f40b5a 100644 (file)
@@ -35,8 +35,8 @@ void bit_mark(unsigned long *seq_bits, int32_t n);
 
 /* receive and process one packet, returns 1 if received seq_num is considered
  * new, 0 if old  */
-char bit_get_packet(void *priv, unsigned long *seq_bits,
-                   int32_t seq_num_diff, int8_t set_mark);
+int bit_get_packet(void *priv, unsigned long *seq_bits,
+                  int32_t seq_num_diff, int set_mark);
 
 /* count the hamming weight, how many good packets did we receive? */
 int bit_packet_count(const unsigned long *seq_bits);
index 24aee561f3d8749c07530e7b256907c5d7704d76..7248de2e66dc3a9775fed73a3997e521c2a36ddf 100644 (file)
@@ -360,7 +360,7 @@ void gw_node_purge(struct bat_priv *bat_priv)
        struct gw_node *gw_node, *curr_gw;
        struct hlist_node *node, *node_tmp;
        unsigned long timeout = 2 * PURGE_TIMEOUT * HZ;
-       char do_deselect = 0;
+       int do_deselect = 0;
 
        curr_gw = gw_get_selected_gw_node(bat_priv);
 
index e74307be8e0c31c2c066aac7afedd93d87170d8a..18661af0bc3becbe4cc57ae8e2b9ec8a92d482e0 100644 (file)
@@ -61,9 +61,9 @@ static void kbit_to_gw_bandwidth(int down, int up, long *gw_srv_class)
 /* returns the up and downspeeds in kbit, calculated from the class */
 void gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up)
 {
-       char sbit = (gw_srv_class & 0x80) >> 7;
-       char dpart = (gw_srv_class & 0x78) >> 3;
-       char upart = (gw_srv_class & 0x07);
+       int sbit = (gw_srv_class & 0x80) >> 7;
+       int dpart = (gw_srv_class & 0x78) >> 3;
+       int upart = (gw_srv_class & 0x07);
 
        if (!gw_srv_class) {
                *down = 0;
index ed488cbae80f985dd11fddb5a65228e9733f2ffb..714a2414d913eb6961d62bb0a20db5b0cdf26cd7 100644 (file)
@@ -151,7 +151,7 @@ int debug_log(struct bat_priv *bat_priv, const char *fmt, ...) __printf(2, 3);
        while (0)
 #else /* !CONFIG_BATMAN_ADV_DEBUG */
 __printf(3, 4)
-static inline void bat_dbg(char type __always_unused,
+static inline void bat_dbg(int type __always_unused,
                           struct bat_priv *bat_priv __always_unused,
                           const char *fmt __always_unused, ...)
 {
index d5ce644f872085abe04675db0256052dac811ac8..eb6fb7d2d368453d788bf98618c41c6d00634bb8 100644 (file)
@@ -163,7 +163,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
        struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
        struct neigh_node *neigh_node = NULL, *tmp_neigh_node;
        struct hlist_node *node;
-       unsigned char total_count;
+       uint8_t total_count;
        uint8_t orig_eq_count, neigh_rq_count, tq_own;
        int tq_asym_penalty, ret = 0;
 
@@ -602,9 +602,9 @@ void receive_bat_packet(const struct ethhdr *ethhdr,
        struct orig_node *orig_neigh_node, *orig_node;
        struct neigh_node *router = NULL, *router_router = NULL;
        struct neigh_node *orig_neigh_router = NULL;
-       char has_directlink_flag;
-       char is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0;
-       char is_broadcast = 0, is_bidirectional, is_single_hop_neigh;
+       int has_directlink_flag;
+       int is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0;
+       int is_broadcast = 0, is_bidirectional, is_single_hop_neigh;
        int is_duplicate;
        uint32_t if_incoming_seqno;
 
index a1b8c3173a3f6f64c98cf4ecbf9ee378fa49bfe7..be0d581a62a912a2d924824ef8a169ffe060a571 100644 (file)
@@ -165,7 +165,7 @@ static void send_packet(struct forw_packet *forw_packet)
        struct bat_priv *bat_priv;
        struct batman_packet *batman_packet =
                (struct batman_packet *)(forw_packet->skb->data);
-       unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
+       int directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
 
        if (!forw_packet->if_incoming) {
                pr_err("Error - can't forward packet: incoming iface not "
@@ -307,12 +307,12 @@ void schedule_own_packet(struct hard_iface *hard_iface)
 void schedule_forward_packet(struct orig_node *orig_node,
                             const struct ethhdr *ethhdr,
                             struct batman_packet *batman_packet,
-                            uint8_t directlink, int tt_buff_len,
+                            int directlink, int tt_buff_len,
                             struct hard_iface *if_incoming)
 {
        struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
        struct neigh_node *router;
-       unsigned char in_tq, in_ttl, tq_avg = 0;
+       uint8_t in_tq, in_ttl, tq_avg = 0;
        unsigned long send_time;
 
        if (batman_packet->ttl <= 1) {
index eceab870024d200ef6ac449d23d2d0e823ecf4d2..6d9c14d759772350c0ac4efea88310faeb293776 100644 (file)
@@ -28,7 +28,7 @@ void schedule_own_packet(struct hard_iface *hard_iface);
 void schedule_forward_packet(struct orig_node *orig_node,
                             const struct ethhdr *ethhdr,
                             struct batman_packet *batman_packet,
-                            uint8_t directlink, int tt_buff_len,
+                            int directlink, int tt_buff_len,
                             struct hard_iface *if_outgoing);
 int add_bcast_packet_to_list(struct bat_priv *bat_priv,
                             const struct sk_buff *skb);
index 0fc997e132518428d2343bc3840af65c9b12e0c9..69c002279e633059bb7a002670027ee9b138c889 100644 (file)
@@ -380,7 +380,7 @@ void softif_neigh_purge(struct bat_priv *bat_priv)
        struct softif_neigh *softif_neigh, *curr_softif_neigh;
        struct softif_neigh_vid *softif_neigh_vid;
        struct hlist_node *node, *node_tmp, *node_tmp2;
-       char do_deselect;
+       int do_deselect;
 
        rcu_read_lock();
        hlist_for_each_entry_rcu(softif_neigh_vid, node,