Skip to contentSkip to conversation

Staging: hv: netvsc: Cleanup the name and type of link_stat variable

PATCH In review K. Y. Srinivasan 2 participants 3 messages Sep 13, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: hv: netvsc: Cleanup the name and type of link_stat variable

Consistently name the variable tracking the link status. Use a consistent type for this variable and get rid of some unnecessary parentheses as well.

---
 drivers/staging/hv/rndis_filter.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/rndis_filter.c +4 -4
index 963582a..696d2c5 100644
@@ -41,7 +41,7 @@ struct rndis_device {
 	struct netvsc_device *net_dev;
 
 	enum rndis_device_state state;
-	u32 link_stat;
+	bool link_state;
 	atomic_t new_req_id;
 
 	spinlock_t request_lock;
@@ -514,7 +514,7 @@ static int rndis_filter_query_device_link_status(struct rndis_device *dev)
 
 	return rndis_filter_query_device(dev,
 				      RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
-				      &dev->link_stat, &size);
+				      &dev->link_state, &size);
 }
 
 static int rndis_filter_set_packet_filter(struct rndis_device *dev,
@@ -736,11 +736,11 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 	rndis_filter_query_device_link_status(rndis_device);
 
-	device_info->link_state = rndis_device->link_stat;
+	device_info->link_state = rndis_device->link_state;
 
 	dev_info(&dev->device, "Device MAC %pM link state %s",
 		 rndis_device->hw_mac_adr,
-		 ((device_info->link_state) ? ("down\n") : ("up\n")));
+		 device_info->link_state ? "down\n" : "up\n");
 
 	return ret;
 }
Signature · 1 line
1.7.4.1
#1 lore raw
Quoted 23 lines · K. Y. Srinivasan

Consistently name the variable tracking the link status. Use a consistent type for this variable and get rid of some unnecessary parentheses as well.

---
 drivers/staging/hv/rndis_filter.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/rndis_filter.c +1 -1
index 963582a..696d2c5 100644
@@ -41,7 +41,7 @@ struct rndis_device {
 	struct netvsc_device *net_dev;
 
 	enum rndis_device_state state;
-	u32 link_stat;
+	bool link_state;
 	atomic_t new_req_id;
 
 	spinlock_t request_lock;

drivers/staging/hv/rndis_filter.c static int rndis_filter_query_device_link_status(struct rndis_device *dev) · line 517

Quoted 5 lines
drivers/staging/hv/rndis_filter.c +1 -1
@@ -514,7 +514,7 @@ static int rndis_filter_query_device_link_status(struct rndis_device *dev)
 
 	return rndis_filter_query_device(dev,
 				      RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
-				      &dev->link_stat, &size);
+				      &dev->link_state, &size);

Are you sure you can do this?
You're changing the info request from u32 to bool without changing the size above it

	u32 size = sizeof(u32);
Quoted 4 lines
drivers/staging/hv/rndis_filter.c +0 -0
 }
 
 static int rndis_filter_set_packet_filter(struct rndis_device *dev,

drivers/staging/hv/rndis_filter.c int rndis_filter_device_add(struct hv_device *dev, · line 743

Quoted 10 lines
drivers/staging/hv/rndis_filter.c +2 -2
@@ -736,11 +736,11 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 	rndis_filter_query_device_link_status(rndis_device);
 
-	device_info->link_state = rndis_device->link_stat;
+	device_info->link_state = rndis_device->link_state;
 
 	dev_info(&dev->device, "Device MAC %pM link state %s",
 		 rndis_device->hw_mac_adr,
-		 ((device_info->link_state) ? ("down\n") : ("up\n")));
+		 device_info->link_state ? "down\n" : "up\n");

It's better to remove the multiple "\n"s from "up" and "down" and move it to the format string as I suggested.

#2 lore raw
Quoted 37 lines

-----Original Message-----
From: Joe Perches [mailto:[email protected]]
Sent: Tuesday, September 13, 2011 4:05 PM
To: KY Srinivasan
Cc: [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: Re: [PATCH 1/1] Staging: hv: netvsc: Cleanup the name and type of link_stat variable

drivers/staging/hv/rndis_filter.c static int rndis_filter_query_device_link_status(struct

Quoted 23 lines · K. Y. Srinivasan

Consistently name the variable tracking the link status. Use a consistent type for this variable and get rid of some unnecessary parentheses as well.

---
 drivers/staging/hv/rndis_filter.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/hv/rndis_filter.c +1 -1
index 963582a..696d2c5 100644
@@ -41,7 +41,7 @@ struct rndis_device {
 	struct netvsc_device *net_dev;
 
 	enum rndis_device_state state;
-	u32 link_stat;
+	bool link_state;
 	atomic_t new_req_id;
 
 	spinlock_t request_lock;
@@ -514,7 +514,7 @@ static int rndis_filter_query_device_link_status(struct

rndis_device *dev)

Quoted 1 line
Quoted 8 lines

drivers/staging/hv/rndis_filter.c static int rndis_filter_query_device_link_status(struct rndis_device *dev) · line 517

Quoted 4 lines
drivers/staging/hv/rndis_filter.c +1 -1
 	return rndis_filter_query_device(dev,
 				      RNDIS_OID_GEN_MEDIA_CONNECT_STATUS,
-				      &dev->link_stat, &size);
+				      &dev->link_state, &size);

Are you sure you can do this?
You're changing the info request from u32 to bool
without changing the size above it

Oops! I will fix this.

Quoted 14 lines
	u32 size = sizeof(u32);
Quoted 10 lines

}

static int rndis_filter_set_packet_filter(struct rndis_device *dev,

drivers/staging/hv/rndis_filter.c +1 -1
@@ -736,11 +736,11 @@ int rndis_filter_device_add(struct hv_device *dev,
 
 	rndis_filter_query_device_link_status(rndis_device);
 
-	device_info->link_state = rndis_device->link_stat;
+	device_info->link_state = rndis_device->link_state;
 
Quoted 7 lines

drivers/staging/hv/rndis_filter.c int rndis_filter_device_add(struct hv_device *dev, · line 743

Quoted 4 lines
drivers/staging/hv/rndis_filter.c +1 -1
 	dev_info(&dev->device, "Device MAC %pM link state %s",
 		 rndis_device->hw_mac_adr,
-		 ((device_info->link_state) ? ("down\n") : ("up\n")));
+		 device_info->link_state ? "down\n" : "up\n");

It's better to remove the multiple "\n"s from "up" and "down" and move it to the format string as I suggested.

I will fix it.

Thank you,

K. Y