Commit 747e4221 authored by Sven Eckelmann's avatar Sven Eckelmann
Browse files

batman-adv: Add const type qualifier for pointers



batman-adv uses pointers which are marked as const and should not
violate that type qualifier by passing it to functions which force a
cast to the non-const version.

Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
parent 38e3c5f0
Loading
Loading
Loading
Loading
+11 −10
Original line number Diff line number Diff line
@@ -26,18 +26,18 @@
#include "hard-interface.h"

/* calculate the size of the tt information for a given packet */
static int tt_len(struct batman_packet *batman_packet)
static int tt_len(const struct batman_packet *batman_packet)
{
	return batman_packet->num_tt * ETH_ALEN;
}

/* return true if new_packet can be aggregated with forw_packet */
static bool can_aggregate_with(struct batman_packet *new_batman_packet,
static bool can_aggregate_with(const struct batman_packet *new_batman_packet,
			       int packet_len,
			       unsigned long send_time,
			       bool directlink,
			       struct hard_iface *if_incoming,
			       struct forw_packet *forw_packet)
			       const struct hard_iface *if_incoming,
			       const struct forw_packet *forw_packet)
{
	struct batman_packet *batman_packet =
		(struct batman_packet *)forw_packet->skb->data;
@@ -97,8 +97,9 @@ static bool can_aggregate_with(struct batman_packet *new_batman_packet,
}

/* create a new aggregated packet and add this packet to it */
static void new_aggregated_packet(unsigned char *packet_buff, int packet_len,
				  unsigned long send_time, bool direct_link,
static void new_aggregated_packet(const unsigned char *packet_buff,
				  int packet_len, unsigned long send_time,
				  bool direct_link,
				  struct hard_iface *if_incoming,
				  int own_packet)
{
@@ -176,8 +177,7 @@ out:

/* aggregate a new packet into the existing aggregation */
static void aggregate(struct forw_packet *forw_packet_aggr,
		      unsigned char *packet_buff,
		      int packet_len,
		      const unsigned char *packet_buff, int packet_len,
		      bool direct_link)
{
	unsigned char *skb_buff;
@@ -253,8 +253,9 @@ void add_bat_packet_to_list(struct bat_priv *bat_priv,
}

/* unpack the aggregated packets and process them one by one */
void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
			     int packet_len, struct hard_iface *if_incoming)
void receive_aggr_bat_packet(const struct ethhdr *ethhdr,
			     unsigned char *packet_buff, int packet_len,
			     struct hard_iface *if_incoming)
{
	struct batman_packet *batman_packet;
	int buff_pos = 0;
+3 −2
Original line number Diff line number Diff line
@@ -37,7 +37,8 @@ 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,
			    unsigned long send_time);
void receive_aggr_bat_packet(struct ethhdr *ethhdr, unsigned char *packet_buff,
			     int packet_len, struct hard_iface *if_incoming);
void receive_aggr_bat_packet(const struct ethhdr *ethhdr,
			     unsigned char *packet_buff, int packet_len,
			     struct hard_iface *if_incoming);

#endif /* _NET_BATMAN_ADV_AGGREGATION_H_ */
+2 −2
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ static void emit_log_char(struct debug_log *debug_log, char c)
}

__printf(2, 3)
static int fdebug_log(struct debug_log *debug_log, char *fmt, ...)
static int fdebug_log(struct debug_log *debug_log, const char *fmt, ...)
{
	va_list args;
	static char debug_log_buf[256];
@@ -75,7 +75,7 @@ static int fdebug_log(struct debug_log *debug_log, char *fmt, ...)
	return 0;
}

int debug_log(struct bat_priv *bat_priv, char *fmt, ...)
int debug_log(struct bat_priv *bat_priv, const char *fmt, ...)
{
	va_list args;
	char tmp_log_buf[256];
+7 −8
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ ssize_t show_##_name(struct kobject *kobj, struct attribute *attr, \

static int store_bool_attr(char *buff, size_t count,
			   struct net_device *net_dev,
			   char *attr_name, atomic_t *attr)
			   const char *attr_name, atomic_t *attr)
{
	int enabled = -1;

@@ -138,16 +138,15 @@ static inline ssize_t __store_bool_attr(char *buff, size_t count,
{
	int ret;

	ret = store_bool_attr(buff, count, net_dev, (char *)attr->name,
			      attr_store);
	ret = store_bool_attr(buff, count, net_dev, attr->name, attr_store);
	if (post_func && ret)
		post_func(net_dev);

	return ret;
}

static int store_uint_attr(char *buff, size_t count,
			   struct net_device *net_dev, char *attr_name,
static int store_uint_attr(const char *buff, size_t count,
			   struct net_device *net_dev, const char *attr_name,
			   unsigned int min, unsigned int max, atomic_t *attr)
{
	unsigned long uint_val;
@@ -183,15 +182,15 @@ static int store_uint_attr(char *buff, size_t count,
	return count;
}

static inline ssize_t __store_uint_attr(char *buff, size_t count,
static inline ssize_t __store_uint_attr(const char *buff, size_t count,
			int min, int max,
			void (*post_func)(struct net_device *),
			struct attribute *attr,
			const struct attribute *attr,
			atomic_t *attr_store, struct net_device *net_dev)
{
	int ret;

	ret = store_uint_attr(buff, count, net_dev, (char *)attr->name,
	ret = store_uint_attr(buff, count, net_dev, attr->name,
			      min, max, attr_store);
	if (post_func && ret)
		post_func(net_dev);
+2 −2
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@

/* returns true if the corresponding bit in the given seq_bits indicates true
 * and curr_seqno is within range of last_seqno */
uint8_t get_bit_status(unsigned long *seq_bits, uint32_t last_seqno,
uint8_t get_bit_status(const unsigned long *seq_bits, uint32_t last_seqno,
		       uint32_t curr_seqno)
{
	int32_t diff, word_offset, word_num;
@@ -190,7 +190,7 @@ char bit_get_packet(void *priv, unsigned long *seq_bits,
/* count the hamming weight, how many good packets did we receive? just count
 * the 1's.
 */
int bit_packet_count(unsigned long *seq_bits)
int bit_packet_count(const unsigned long *seq_bits)
{
	int i, hamming = 0;

Loading