Skip to contentSkip to conversation

Staging: lustre: lnet: Remove int typecast of offsetof().

PATCH In review Sandhya Bankar 2 participants 4 messages Feb 28, 2016 – Mar 2, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 Staging: lustre: lnet: Remove int typecast of offsetof().

Remove int typecast of offsetof().
As per below coccinelle rule:

@@
type T;
expression E;
@@

- (int)(offsetof(T,E))
+ offsetof(T,E)

---
 drivers/staging/lustre/lnet/lnet/api-ni.c | 54 +++++++++++++++----------------
 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/staging/lustre/lnet/lnet/api-ni.c +27 -27
index 3ecc96a..c3fe782 100644
@@ -197,75 +197,75 @@ static void lnet_assert_wire_constants(void)
 	CLASSERT((int)sizeof(lnet_handle_wire_t) == 16);
 	CLASSERT((int)offsetof(lnet_handle_wire_t, wh_interface_cookie) == 0);
 	CLASSERT((int)sizeof(((lnet_handle_wire_t *)0)->wh_interface_cookie) == 8);
-	CLASSERT((int)offsetof(lnet_handle_wire_t, wh_object_cookie) == 8);
+	CLASSERT(offsetof(lnet_handle_wire_t, wh_object_cookie) == 8);
 	CLASSERT((int)sizeof(((lnet_handle_wire_t *)0)->wh_object_cookie) == 8);
 
 	/* Checks for struct lnet_magicversion_t */
 	CLASSERT((int)sizeof(lnet_magicversion_t) == 8);
 	CLASSERT((int)offsetof(lnet_magicversion_t, magic) == 0);
 	CLASSERT((int)sizeof(((lnet_magicversion_t *)0)->magic) == 4);
-	CLASSERT((int)offsetof(lnet_magicversion_t, version_major) == 4);
+	CLASSERT(offsetof(lnet_magicversion_t, version_major) == 4);
 	CLASSERT((int)sizeof(((lnet_magicversion_t *)0)->version_major) == 2);
-	CLASSERT((int)offsetof(lnet_magicversion_t, version_minor) == 6);
+	CLASSERT(offsetof(lnet_magicversion_t, version_minor) == 6);
 	CLASSERT((int)sizeof(((lnet_magicversion_t *)0)->version_minor) == 2);
 
 	/* Checks for struct lnet_hdr_t */
 	CLASSERT((int)sizeof(lnet_hdr_t) == 72);
 	CLASSERT((int)offsetof(lnet_hdr_t, dest_nid) == 0);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->dest_nid) == 8);
-	CLASSERT((int)offsetof(lnet_hdr_t, src_nid) == 8);
+	CLASSERT(offsetof(lnet_hdr_t, src_nid) == 8);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->src_nid) == 8);
-	CLASSERT((int)offsetof(lnet_hdr_t, dest_pid) == 16);
+	CLASSERT(offsetof(lnet_hdr_t, dest_pid) == 16);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->dest_pid) == 4);
-	CLASSERT((int)offsetof(lnet_hdr_t, src_pid) == 20);
+	CLASSERT(offsetof(lnet_hdr_t, src_pid) == 20);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->src_pid) == 4);
-	CLASSERT((int)offsetof(lnet_hdr_t, type) == 24);
+	CLASSERT(offsetof(lnet_hdr_t, type) == 24);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->type) == 4);
-	CLASSERT((int)offsetof(lnet_hdr_t, payload_length) == 28);
+	CLASSERT(offsetof(lnet_hdr_t, payload_length) == 28);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->payload_length) == 4);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg) == 32);
+	CLASSERT(offsetof(lnet_hdr_t, msg) == 32);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg) == 40);
 
 	/* Ack */
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.ack.dst_wmd) == 32);
+	CLASSERT(offsetof(lnet_hdr_t, msg.ack.dst_wmd) == 32);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.ack.dst_wmd) == 16);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.ack.match_bits) == 48);
+	CLASSERT(offsetof(lnet_hdr_t, msg.ack.match_bits) == 48);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.ack.match_bits) == 8);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.ack.mlength) == 56);
+	CLASSERT(offsetof(lnet_hdr_t, msg.ack.mlength) == 56);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.ack.mlength) == 4);
 
 	/* Put */
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.put.ack_wmd) == 32);
+	CLASSERT(offsetof(lnet_hdr_t, msg.put.ack_wmd) == 32);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.ack_wmd) == 16);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.put.match_bits) == 48);
+	CLASSERT(offsetof(lnet_hdr_t, msg.put.match_bits) == 48);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.match_bits) == 8);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.put.hdr_data) == 56);
+	CLASSERT(offsetof(lnet_hdr_t, msg.put.hdr_data) == 56);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.hdr_data) == 8);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.put.ptl_index) == 64);
+	CLASSERT(offsetof(lnet_hdr_t, msg.put.ptl_index) == 64);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.ptl_index) == 4);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.put.offset) == 68);
+	CLASSERT(offsetof(lnet_hdr_t, msg.put.offset) == 68);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.offset) == 4);
 
 	/* Get */
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.get.return_wmd) == 32);
+	CLASSERT(offsetof(lnet_hdr_t, msg.get.return_wmd) == 32);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.return_wmd) == 16);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.get.match_bits) == 48);
+	CLASSERT(offsetof(lnet_hdr_t, msg.get.match_bits) == 48);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.match_bits) == 8);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.get.ptl_index) == 56);
+	CLASSERT(offsetof(lnet_hdr_t, msg.get.ptl_index) == 56);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.ptl_index) == 4);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.get.src_offset) == 60);
+	CLASSERT(offsetof(lnet_hdr_t, msg.get.src_offset) == 60);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.src_offset) == 4);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.get.sink_length) == 64);
+	CLASSERT(offsetof(lnet_hdr_t, msg.get.sink_length) == 64);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.sink_length) == 4);
 
 	/* Reply */
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.reply.dst_wmd) == 32);
+	CLASSERT(offsetof(lnet_hdr_t, msg.reply.dst_wmd) == 32);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.reply.dst_wmd) == 16);
 
 	/* Hello */
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.hello.incarnation) == 32);
+	CLASSERT(offsetof(lnet_hdr_t, msg.hello.incarnation) == 32);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.hello.incarnation) == 8);
-	CLASSERT((int)offsetof(lnet_hdr_t, msg.hello.type) == 40);
+	CLASSERT(offsetof(lnet_hdr_t, msg.hello.type) == 40);
 	CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.hello.type) == 4);
 }
 
@@ -2266,7 +2266,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms,
 
 	if (nob < offsetof(lnet_ping_info_t, pi_ni[0])) {
 		CERROR("%s: Short reply %d(%d min)\n", libcfs_id2str(id),
-		       nob, (int)offsetof(lnet_ping_info_t, pi_ni[0]));
+		       nob, offsetof(lnet_ping_info_t, pi_ni[0]));
 		goto out_1;
 	}
 
@@ -2275,7 +2275,7 @@ static int lnet_ping(lnet_process_id_t id, int timeout_ms,
 
 	if (nob < offsetof(lnet_ping_info_t, pi_ni[n_ids])) {
 		CERROR("%s: Short reply %d(%d expected)\n", libcfs_id2str(id),
-		       nob, (int)offsetof(lnet_ping_info_t, pi_ni[n_ids]));
+		       nob, offsetof(lnet_ping_info_t, pi_ni[n_ids]));
 		goto out_1;
 	}
 
Signature · 1 line
1.8.3.4
maintainer
#1 lore raw
Quoted 21 lines · Sandhya Bankar

Remove int typecast of offsetof().
As per below coccinelle rule:

@@
type T;
expression E;
@@

- (int)(offsetof(T,E))
+ offsetof(T,E)

---
 drivers/staging/lustre/lnet/lnet/api-ni.c | 54 +++++++++++++++----------------
 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/staging/lustre/lnet/lnet/api-ni.c +0 -0
index 3ecc96a..c3fe782 100644

drivers/staging/lustre/lnet/lnet/api-ni.c static void lnet_assert_wire_constants(void) · line 201

Quoted 6 lines
drivers/staging/lustre/lnet/lnet/api-ni.c +1 -1
@@ -197,75 +197,75 @@ static void lnet_assert_wire_constants(void)
 	CLASSERT((int)sizeof(lnet_handle_wire_t) == 16);
 	CLASSERT((int)offsetof(lnet_handle_wire_t, wh_interface_cookie) == 0);
 	CLASSERT((int)sizeof(((lnet_handle_wire_t *)0)->wh_interface_cookie) == 8);
-	CLASSERT((int)offsetof(lnet_handle_wire_t, wh_object_cookie) == 8);
+	CLASSERT(offsetof(lnet_handle_wire_t, wh_object_cookie) == 8);
 	CLASSERT((int)sizeof(((lnet_handle_wire_t *)0)->wh_object_cookie) == 8);

Why did you only change 1 of them here and not all instances?

thanks,

greg k-h

#2 lore raw
In reply to Sandhya Bankar

Thanks.!! I will send fresh patch for the same.

Quoted 164 lines · sandhya bankar

Remove int typecast of offsetof().
As per below coccinelle rule:

@@
type T;
expression E;
@@

- (int)(offsetof(T,E))
+ offsetof(T,E)

---

 drivers/staging/lustre/lnet/lnet/api-ni.c | 54 
+++++++++++++++---------------- 
 1 file changed, 27 insertions(+), 27 deletions(-) 
drivers/staging/lustre/lnet/lnet/api-ni.c +22 -22
index 3ecc96a..c3fe782 100644 
@@ -197,75 +197,75 @@ static void lnet_assert_wire_constants(void) 
         CLASSERT((int)sizeof(lnet_handle_wire_t) == 16); 
         CLASSERT((int)offsetof(lnet_handle_wire_t, wh_interface_cookie) 
 == 0); 
         CLASSERT((int)sizeof(((lnet_handle_wire_t 
 *)0)->wh_interface_cookie) == 8); 
-        CLASSERT((int)offsetof(lnet_handle_wire_t, wh_object_cookie) == 
 8); 
+        CLASSERT(offsetof(lnet_handle_wire_t, wh_object_cookie) == 8); 
         CLASSERT((int)sizeof(((lnet_handle_wire_t *)0)->wh_object_cookie) 
 == 8); 
 
         /* Checks for struct lnet_magicversion_t */ 
         CLASSERT((int)sizeof(lnet_magicversion_t) == 8); 
         CLASSERT((int)offsetof(lnet_magicversion_t, magic) == 0); 
         CLASSERT((int)sizeof(((lnet_magicversion_t *)0)->magic) == 4); 
-        CLASSERT((int)offsetof(lnet_magicversion_t, version_major) == 4); 
+        CLASSERT(offsetof(lnet_magicversion_t, version_major) == 4); 
         CLASSERT((int)sizeof(((lnet_magicversion_t *)0)->version_major) 
 == 2); 
-        CLASSERT((int)offsetof(lnet_magicversion_t, version_minor) == 6); 
+        CLASSERT(offsetof(lnet_magicversion_t, version_minor) == 6); 
         CLASSERT((int)sizeof(((lnet_magicversion_t *)0)->version_minor) 
 == 2); 
 
         /* Checks for struct lnet_hdr_t */ 
         CLASSERT((int)sizeof(lnet_hdr_t) == 72); 
         CLASSERT((int)offsetof(lnet_hdr_t, dest_nid) == 0); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->dest_nid) == 8); 
-        CLASSERT((int)offsetof(lnet_hdr_t, src_nid) == 8); 
+        CLASSERT(offsetof(lnet_hdr_t, src_nid) == 8); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->src_nid) == 8); 
-        CLASSERT((int)offsetof(lnet_hdr_t, dest_pid) == 16); 
+        CLASSERT(offsetof(lnet_hdr_t, dest_pid) == 16); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->dest_pid) == 4); 
-        CLASSERT((int)offsetof(lnet_hdr_t, src_pid) == 20); 
+        CLASSERT(offsetof(lnet_hdr_t, src_pid) == 20); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->src_pid) == 4); 
-        CLASSERT((int)offsetof(lnet_hdr_t, type) == 24); 
+        CLASSERT(offsetof(lnet_hdr_t, type) == 24); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->type) == 4); 
-        CLASSERT((int)offsetof(lnet_hdr_t, payload_length) == 28); 
+        CLASSERT(offsetof(lnet_hdr_t, payload_length) == 28); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->payload_length) == 4); 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg) == 32); 
+        CLASSERT(offsetof(lnet_hdr_t, msg) == 32); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg) == 40); 
 
         /* Ack */ 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.ack.dst_wmd) == 32); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.ack.dst_wmd) == 32); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.ack.dst_wmd) == 16); 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.ack.match_bits) == 48); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.ack.match_bits) == 48); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.ack.match_bits) == 
 8); 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.ack.mlength) == 56); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.ack.mlength) == 56); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.ack.mlength) == 4); 
 
         /* Put */ 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.put.ack_wmd) == 32); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.put.ack_wmd) == 32); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.ack_wmd) == 16); 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.put.match_bits) == 48); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.put.match_bits) == 48); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.match_bits) == 
 8); 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.put.hdr_data) == 56); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.put.hdr_data) == 56); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.hdr_data) == 8); 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.put.ptl_index) == 64); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.put.ptl_index) == 64); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.ptl_index) == 4); 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.put.offset) == 68); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.put.offset) == 68); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.put.offset) == 4); 
 
         /* Get */ 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.get.return_wmd) == 32); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.get.return_wmd) == 32); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.return_wmd) == 
 16); 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.get.match_bits) == 48); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.get.match_bits) == 48); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.match_bits) == 
 8); 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.get.ptl_index) == 56); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.get.ptl_index) == 56); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.ptl_index) == 4); 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.get.src_offset) == 60); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.get.src_offset) == 60); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.src_offset) == 
 4); 
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.get.sink_length) == 64); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.get.sink_length) == 64); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.get.sink_length) == 
 4); 
  
         /* Reply */ 
drivers/staging/lustre/lnet/lnet/api-ni.c +1 -1
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.reply.dst_wmd) == 32); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.reply.dst_wmd) == 32); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.reply.dst_wmd) == 

16);

         /* Hello */ 
drivers/staging/lustre/lnet/lnet/api-ni.c +1 -1
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.hello.incarnation) == 32); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.hello.incarnation) == 32); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.hello.incarnation) == 

8);

drivers/staging/lustre/lnet/lnet/api-ni.c +3 -3
-        CLASSERT((int)offsetof(lnet_hdr_t, msg.hello.type) == 40); 
+        CLASSERT(offsetof(lnet_hdr_t, msg.hello.type) == 40); 
         CLASSERT((int)sizeof(((lnet_hdr_t *)0)->msg.hello.type) == 4); 
 } 
@@ -2266,7 +2266,7 @@ static int lnet_ping(lnet_process_id_t id, int 
 timeout_ms, 
 
         if (nob < offsetof(lnet_ping_info_t, pi_ni[0])) { 
                 CERROR("%s: Short reply %d(%d min)\n", libcfs_id2str(id), 
-                       nob, (int)offsetof(lnet_ping_info_t, pi_ni[0])); 
+                       nob, offsetof(lnet_ping_info_t, pi_ni[0])); 
                 goto out_1; 
         } 
@@ -2275,7 +2275,7 @@ static int lnet_ping(lnet_process_id_t id, int 
 timeout_ms, 
 
         if (nob < offsetof(lnet_ping_info_t, pi_ni[n_ids])) { 
                 CERROR("%s: Short reply %d(%d expected)\n", 
 libcfs_id2str(id), 
-                       nob, (int)offsetof(lnet_ping_info_t, 
 pi_ni[n_ids])); 
+                       nob, offsetof(lnet_ping_info_t, pi_ni[n_ids])); 
                 goto out_1; 
         } 
Signature · 1 line
1.8.3.4 
maintainer
#3 lore raw
In reply to Sandhya Bankar
Quoted 21 lines · Sandhya Bankar

Remove int typecast of offsetof().
As per below coccinelle rule:

@@
type T;
expression E;
@@

- (int)(offsetof(T,E))
+ offsetof(T,E)

---
 drivers/staging/lustre/lnet/lnet/api-ni.c | 54 +++++++++++++++----------------
 1 file changed, 27 insertions(+), 27 deletions(-)
drivers/staging/lustre/lnet/lnet/api-ni.c +0 -0
index 3ecc96a..c3fe782 100644

drivers/staging/lustre/lnet/lnet/api-ni.c static void lnet_assert_wire_constants(void) · line 201

Quoted 6 lines
drivers/staging/lustre/lnet/lnet/api-ni.c +1 -1
@@ -197,75 +197,75 @@ static void lnet_assert_wire_constants(void)
 	CLASSERT((int)sizeof(lnet_handle_wire_t) == 16);
 	CLASSERT((int)offsetof(lnet_handle_wire_t, wh_interface_cookie) == 0);
 	CLASSERT((int)sizeof(((lnet_handle_wire_t *)0)->wh_interface_cookie) == 8);
-	CLASSERT((int)offsetof(lnet_handle_wire_t, wh_object_cookie) == 8);
+	CLASSERT(offsetof(lnet_handle_wire_t, wh_object_cookie) == 8);
 	CLASSERT((int)sizeof(((lnet_handle_wire_t *)0)->wh_object_cookie) == 8);

Why did you only change 1 of them here and not all instances?

thanks,

greg k-h