Skip to content

Commit b4e1705

Browse files
committed
batman-adv: Reduce usage of char
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>
1 parent b2c44a5 commit b4e1705

11 files changed

Lines changed: 20 additions & 20 deletions

File tree

‎net/batman-adv/aggregation.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static void aggregate(struct forw_packet *forw_packet_aggr,
195195

196196
void add_bat_packet_to_list(struct bat_priv *bat_priv,
197197
unsigned char *packet_buff, int packet_len,
198-
struct hard_iface *if_incoming, char own_packet,
198+
struct hard_iface *if_incoming, int own_packet,
199199
unsigned long send_time)
200200
{
201201
/**

‎net/batman-adv/aggregation.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static inline int aggregated_packet(int buff_pos, int packet_len, int num_tt)
3535

3636
void add_bat_packet_to_list(struct bat_priv *bat_priv,
3737
unsigned char *packet_buff, int packet_len,
38-
struct hard_iface *if_incoming, char own_packet,
38+
struct hard_iface *if_incoming, int own_packet,
3939
unsigned long send_time);
4040
void receive_aggr_bat_packet(const struct ethhdr *ethhdr,
4141
unsigned char *packet_buff, int packet_len,

‎net/batman-adv/bitarray.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ static void bit_reset_window(unsigned long *seq_bits)
127127
* 1 if the window was moved (either new or very old)
128128
* 0 if the window was not moved/shifted.
129129
*/
130-
char bit_get_packet(void *priv, unsigned long *seq_bits,
131-
int32_t seq_num_diff, int8_t set_mark)
130+
int bit_get_packet(void *priv, unsigned long *seq_bits,
131+
int32_t seq_num_diff, int set_mark)
132132
{
133133
struct bat_priv *bat_priv = priv;
134134

‎net/batman-adv/bitarray.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ void bit_mark(unsigned long *seq_bits, int32_t n);
3535

3636
/* receive and process one packet, returns 1 if received seq_num is considered
3737
* new, 0 if old */
38-
char bit_get_packet(void *priv, unsigned long *seq_bits,
39-
int32_t seq_num_diff, int8_t set_mark);
38+
int bit_get_packet(void *priv, unsigned long *seq_bits,
39+
int32_t seq_num_diff, int set_mark);
4040

4141
/* count the hamming weight, how many good packets did we receive? */
4242
int bit_packet_count(const unsigned long *seq_bits);

‎net/batman-adv/gateway_client.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ void gw_node_purge(struct bat_priv *bat_priv)
360360
struct gw_node *gw_node, *curr_gw;
361361
struct hlist_node *node, *node_tmp;
362362
unsigned long timeout = 2 * PURGE_TIMEOUT * HZ;
363-
char do_deselect = 0;
363+
int do_deselect = 0;
364364

365365
curr_gw = gw_get_selected_gw_node(bat_priv);
366366

‎net/batman-adv/gateway_common.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ static void kbit_to_gw_bandwidth(int down, int up, long *gw_srv_class)
6161
/* returns the up and downspeeds in kbit, calculated from the class */
6262
void gw_bandwidth_to_kbit(uint8_t gw_srv_class, int *down, int *up)
6363
{
64-
char sbit = (gw_srv_class & 0x80) >> 7;
65-
char dpart = (gw_srv_class & 0x78) >> 3;
66-
char upart = (gw_srv_class & 0x07);
64+
int sbit = (gw_srv_class & 0x80) >> 7;
65+
int dpart = (gw_srv_class & 0x78) >> 3;
66+
int upart = (gw_srv_class & 0x07);
6767

6868
if (!gw_srv_class) {
6969
*down = 0;

‎net/batman-adv/main.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ int debug_log(struct bat_priv *bat_priv, const char *fmt, ...) __printf(2, 3);
151151
while (0)
152152
#else /* !CONFIG_BATMAN_ADV_DEBUG */
153153
__printf(3, 4)
154-
static inline void bat_dbg(char type __always_unused,
154+
static inline void bat_dbg(int type __always_unused,
155155
struct bat_priv *bat_priv __always_unused,
156156
const char *fmt __always_unused, ...)
157157
{

‎net/batman-adv/routing.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ static int is_bidirectional_neigh(struct orig_node *orig_node,
163163
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
164164
struct neigh_node *neigh_node = NULL, *tmp_neigh_node;
165165
struct hlist_node *node;
166-
unsigned char total_count;
166+
uint8_t total_count;
167167
uint8_t orig_eq_count, neigh_rq_count, tq_own;
168168
int tq_asym_penalty, ret = 0;
169169

@@ -602,9 +602,9 @@ void receive_bat_packet(const struct ethhdr *ethhdr,
602602
struct orig_node *orig_neigh_node, *orig_node;
603603
struct neigh_node *router = NULL, *router_router = NULL;
604604
struct neigh_node *orig_neigh_router = NULL;
605-
char has_directlink_flag;
606-
char is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0;
607-
char is_broadcast = 0, is_bidirectional, is_single_hop_neigh;
605+
int has_directlink_flag;
606+
int is_my_addr = 0, is_my_orig = 0, is_my_oldorig = 0;
607+
int is_broadcast = 0, is_bidirectional, is_single_hop_neigh;
608608
int is_duplicate;
609609
uint32_t if_incoming_seqno;
610610

‎net/batman-adv/send.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static void send_packet(struct forw_packet *forw_packet)
165165
struct bat_priv *bat_priv;
166166
struct batman_packet *batman_packet =
167167
(struct batman_packet *)(forw_packet->skb->data);
168-
unsigned char directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
168+
int directlink = (batman_packet->flags & DIRECTLINK ? 1 : 0);
169169

170170
if (!forw_packet->if_incoming) {
171171
pr_err("Error - can't forward packet: incoming iface not "
@@ -307,12 +307,12 @@ void schedule_own_packet(struct hard_iface *hard_iface)
307307
void schedule_forward_packet(struct orig_node *orig_node,
308308
const struct ethhdr *ethhdr,
309309
struct batman_packet *batman_packet,
310-
uint8_t directlink, int tt_buff_len,
310+
int directlink, int tt_buff_len,
311311
struct hard_iface *if_incoming)
312312
{
313313
struct bat_priv *bat_priv = netdev_priv(if_incoming->soft_iface);
314314
struct neigh_node *router;
315-
unsigned char in_tq, in_ttl, tq_avg = 0;
315+
uint8_t in_tq, in_ttl, tq_avg = 0;
316316
unsigned long send_time;
317317

318318
if (batman_packet->ttl <= 1) {

‎net/batman-adv/send.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void schedule_own_packet(struct hard_iface *hard_iface);
2828
void schedule_forward_packet(struct orig_node *orig_node,
2929
const struct ethhdr *ethhdr,
3030
struct batman_packet *batman_packet,
31-
uint8_t directlink, int tt_buff_len,
31+
int directlink, int tt_buff_len,
3232
struct hard_iface *if_outgoing);
3333
int add_bcast_packet_to_list(struct bat_priv *bat_priv,
3434
const struct sk_buff *skb);

0 commit comments

Comments
 (0)