[1/2] batman-adv: Fix style changes reported by cppcheck

Message ID 1319988980-3548-1-git-send-email-siwu@hrz.tu-chemnitz.de (mailing list archive)
State Rejected, archived
Headers

Commit Message

Simon Wunderlich Oct. 30, 2011, 3:36 p.m. UTC
  cppcheck reported some style issues this patch fixes.

Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
---
 bat_iv_ogm.c     |    2 +-
 routing.c        |    2 +-
 soft-interface.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
  

Comments

Marek Lindner Oct. 30, 2011, 8:24 p.m. UTC | #1
On Sunday, October 30, 2011 16:36:20 Simon Wunderlich wrote:
> cppcheck reported some style issues this patch fixes.
> 
> Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
> ---
>  bat_iv_ogm.c     |    2 +-
>  routing.c        |    2 +-
>  soft-interface.c |    2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)

Do you mind saying what cppcheck reported ?
What happened to patch 2/2 ?

Regards,
Marek
  
Simon Wunderlich Oct. 30, 2011, 8:58 p.m. UTC | #2
Hey,

Patch 2/2 was created accidently due to my lack of git skills, please
assume [PATCH]. :)

The output of cppcheck (before the applying the patch): 

$ cppcheck -q --enable=all .
[bat_iv_ogm.c:993]: (style) The scope of the variable 'offset' can be reduced
[routing.c:980]: (style) The scope of the variable 'ret' can be reduced
[soft-interface.c:695]: (style) The scope of the variable 'ret' can be reduced

Note that reduced scope may be a matter of taste, I could not really find
anything about that in the CodingStyle.

Cheers
	Simon


On Sun, Oct 30, 2011 at 09:24:31PM +0100, Marek Lindner wrote:
> On Sunday, October 30, 2011 16:36:20 Simon Wunderlich wrote:
> > cppcheck reported some style issues this patch fixes.
> > 
> > Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
> > ---
> >  bat_iv_ogm.c     |    2 +-
> >  routing.c        |    2 +-
> >  soft-interface.c |    2 +-
> >  3 files changed, 3 insertions(+), 3 deletions(-)
> 
> Do you mind saying what cppcheck reported ?
> What happened to patch 2/2 ?
> 
> Regards,
> Marek
>
  

Patch

diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 3512e25..17b6dfa 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -990,7 +990,6 @@  static void bat_ogm_process(const struct ethhdr *ethhdr,
 
 	if (is_my_orig) {
 		unsigned long *word;
-		int offset;
 
 		orig_neigh_node = get_orig_node(bat_priv, ethhdr->h_source);
 		if (!orig_neigh_node)
@@ -1002,6 +1001,7 @@  static void bat_ogm_process(const struct ethhdr *ethhdr,
 		if (has_directlink_flag &&
 		    compare_eth(if_incoming->net_dev->dev_addr,
 				batman_ogm_packet->orig)) {
+			int offset;
 			offset = if_incoming->if_num * NUM_WORDS;
 
 			spin_lock_bh(&orig_neigh_node->ogm_cnt_lock);
diff --git a/routing.c b/routing.c
index ef24a72..3e97c2c 100644
--- a/routing.c
+++ b/routing.c
@@ -977,7 +977,6 @@  int recv_ucast_frag_packet(struct sk_buff *skb, struct hard_iface *recv_if)
 	struct unicast_frag_packet *unicast_packet;
 	int hdr_size = sizeof(*unicast_packet);
 	struct sk_buff *new_skb = NULL;
-	int ret;
 
 	if (check_unicast_packet(skb, hdr_size) < 0)
 		return NET_RX_DROP;
@@ -989,6 +988,7 @@  int recv_ucast_frag_packet(struct sk_buff *skb, struct hard_iface *recv_if)
 
 	/* packet for me */
 	if (is_my_mac(unicast_packet->dest)) {
+		int ret;
 
 		ret = frag_reassemble_skb(skb, bat_priv, &new_skb);
 
diff --git a/soft-interface.c b/soft-interface.c
index 45297c8..3ed6781 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -692,7 +692,6 @@  void interface_rx(struct net_device *soft_iface,
 	struct vlan_ethhdr *vhdr;
 	struct softif_neigh *curr_softif_neigh = NULL;
 	short vid = -1;
-	int ret;
 
 	/* check if enough space is available for pulling, and pull */
 	if (!pskb_may_pull(skb, hdr_size))
@@ -722,6 +721,7 @@  void interface_rx(struct net_device *soft_iface,
 	 */
 	curr_softif_neigh = softif_neigh_vid_get_selected(bat_priv, vid);
 	if (curr_softif_neigh) {
+		int ret;
 		skb_push(skb, hdr_size);
 		unicast_packet = (struct unicast_packet *)skb->data;