diff mbox

[OPW,kernel,05/10] staging: lustre: Fix sparse warning on incorrect casting

Message ID 3a0b071e7e8d85b4cd2e9fd2ece75da0630a90be.1383233124.git.dulshani.gunawardhana89@gmail.com
State New, archived
Headers show

Commit Message

Dulshani Gunawardhana Oct. 31, 2013, 3:32 p.m. UTC
Fix the following sparse warnings on incorrect castings in lib-msg.c.

drivers/staging/lustre/lnet/lnet/lib-msg.c:72:37: warning: cast to
restricted __le64
drivers/staging/lustre/lnet/lnet/lib-msg.c:73:37: warning: cast to
restricted __le32
drivers/staging/lustre/lnet/lnet/lib-msg.c:116:42: warning: cast to
restricted __le32
drivers/staging/lustre/lnet/lnet/lib-msg.c:117:42: warning: cast to
restricted __le64
drivers/staging/lustre/lnet/lnet/lib-msg.c:118:42: warning: cast to
restricted __le32
drivers/staging/lustre/lnet/lnet/lib-msg.c:120:42: warning: cast to
restricted __le32
drivers/staging/lustre/lnet/lnet/lib-msg.c:121:42: warning: cast to
restricted __le64
drivers/staging/lustre/lnet/lnet/lib-msg.c:125:42: warning: cast to
restricted __le32
drivers/staging/lustre/lnet/lnet/lib-msg.c:126:42: warning: cast to
restricted __le64
drivers/staging/lustre/lnet/lnet/lib-msg.c:128:42: warning: cast to
restricted __le32
drivers/staging/lustre/lnet/lnet/lib-msg.c:129:42: warning: cast to
restricted __le32

Signed-off-by: Dulshani Gunawardhana <dulshani.gunawardhana89@gmail.com>
---
 drivers/staging/lustre/lnet/lnet/lib-msg.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Comments

Greg Kroah-Hartman Oct. 31, 2013, 3:48 p.m. UTC | #1
On Thu, Oct 31, 2013 at 09:02:18PM +0530, Dulshani Gunawardhana wrote:
> Fix the following sparse warnings on incorrect castings in lib-msg.c.
> 
> drivers/staging/lustre/lnet/lnet/lib-msg.c:72:37: warning: cast to
> restricted __le64
> drivers/staging/lustre/lnet/lnet/lib-msg.c:73:37: warning: cast to
> restricted __le32

Line wrap :(

> drivers/staging/lustre/lnet/lnet/lib-msg.c:116:42: warning: cast to
> restricted __le32
> drivers/staging/lustre/lnet/lnet/lib-msg.c:117:42: warning: cast to
> restricted __le64
> drivers/staging/lustre/lnet/lnet/lib-msg.c:118:42: warning: cast to
> restricted __le32
> drivers/staging/lustre/lnet/lnet/lib-msg.c:120:42: warning: cast to
> restricted __le32
> drivers/staging/lustre/lnet/lnet/lib-msg.c:121:42: warning: cast to
> restricted __le64
> drivers/staging/lustre/lnet/lnet/lib-msg.c:125:42: warning: cast to
> restricted __le32
> drivers/staging/lustre/lnet/lnet/lib-msg.c:126:42: warning: cast to
> restricted __le64
> drivers/staging/lustre/lnet/lnet/lib-msg.c:128:42: warning: cast to
> restricted __le32
> drivers/staging/lustre/lnet/lnet/lib-msg.c:129:42: warning: cast to
> restricted __le32
> 
> Signed-off-by: Dulshani Gunawardhana <dulshani.gunawardhana89@gmail.com>
> ---
>  drivers/staging/lustre/lnet/lnet/lib-msg.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c
> index 61ae88b..5d797c1 100644
> --- a/drivers/staging/lustre/lnet/lnet/lib-msg.c
> +++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c
> @@ -69,8 +69,8 @@ lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type)
>  
>  	if (ev_type == LNET_EVENT_SEND) {
>  		/* event for active message */
> -		ev->target.nid    = le64_to_cpu(hdr->dest_nid);
> -		ev->target.pid    = le32_to_cpu(hdr->dest_pid);
> +		ev->target.nid    = hdr->dest_nid;
> +		ev->target.pid    = hdr->dest_pid;

This is odd, it's implying that dest_nid and dest_pid are really in
little-endian format.  If so, they need to be marked as such, don't
break the code by removing the conversion like you did, assume that it
was added for a good reason.

thanks,

greg k-h
diff mbox

Patch

diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c
index 61ae88b..5d797c1 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-msg.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c
@@ -69,8 +69,8 @@  lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type)
 
 	if (ev_type == LNET_EVENT_SEND) {
 		/* event for active message */
-		ev->target.nid    = le64_to_cpu(hdr->dest_nid);
-		ev->target.pid    = le32_to_cpu(hdr->dest_pid);
+		ev->target.nid    = hdr->dest_nid;
+		ev->target.pid    = hdr->dest_pid;
 		ev->initiator.nid = LNET_NID_ANY;
 		ev->initiator.pid = the_lnet.ln_pid;
 		ev->sender	  = LNET_NID_ANY;
@@ -113,20 +113,20 @@  lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type)
 
 	case LNET_EVENT_SEND: /* active message */
 		if (msg->msg_type == LNET_MSG_PUT) {
-			ev->pt_index   = le32_to_cpu(hdr->msg.put.ptl_index);
-			ev->match_bits = le64_to_cpu(hdr->msg.put.match_bits);
-			ev->offset     = le32_to_cpu(hdr->msg.put.offset);
+			ev->pt_index   = hdr->msg.put.ptl_index;
+			ev->match_bits = hdr->msg.put.match_bits;
+			ev->offset     = hdr->msg.put.offset;
 			ev->mlength    =
-			ev->rlength    = le32_to_cpu(hdr->payload_length);
-			ev->hdr_data   = le64_to_cpu(hdr->msg.put.hdr_data);
+			ev->rlength    = hdr->payload_length;
+			ev->hdr_data   = hdr->msg.put.hdr_data;
 
 		} else {
 			LASSERT(msg->msg_type == LNET_MSG_GET);
-			ev->pt_index   = le32_to_cpu(hdr->msg.get.ptl_index);
-			ev->match_bits = le64_to_cpu(hdr->msg.get.match_bits);
+			ev->pt_index   = hdr->msg.get.ptl_index;
+			ev->match_bits = hdr->msg.get.match_bits;
 			ev->mlength    =
-			ev->rlength    = le32_to_cpu(hdr->msg.get.sink_length);
-			ev->offset     = le32_to_cpu(hdr->msg.get.src_offset);
+			ev->rlength    = hdr->msg.get.sink_length;
+			ev->offset     = hdr->msg.get.src_offset;
 			ev->hdr_data   = 0;
 		}
 		return;