Re: [PATCH] dlm: sparse endian annotations

Previous thread: [PATCH] block: Trivial fix for blk_integrity_rq() by Martin K. Petersen on Wednesday, July 16, 2008 - 1:09 pm. (1 message)

Next thread: [PATCH] : A better approach to compute int_sqrt in lib/int_sqrt.c by Soumyadip Das Mahapatra on Wednesday, July 16, 2008 - 1:19 pm. (2 messages)
From: Harvey Harrison
Date: Wednesday, July 16, 2008 - 1:16 pm

fs/dlm/dir.c:419:14: warning: incorrect type in assignment (different base types)
fs/dlm/dir.c:419:14:    expected unsigned short [unsigned] [addressable] [assigned] [usertype] be_namelen
fs/dlm/dir.c:419:14:    got restricted __be16 [usertype] <noident>

fs/dlm/util.c:27:17: warning: incorrect type in assignment (different base types)
fs/dlm/util.c:27:17:    expected unsigned int [unsigned] [usertype] h_version
fs/dlm/util.c:27:17:    got restricted __le32 [usertype] <noident>
..lots more...

fs/dlm/util.c:149:17: warning: cast to restricted __le32
fs/dlm/util.c:150:19: warning: cast to restricted __le32
fs/dlm/util.c:151:15: warning: cast to restricted __le64
fs/dlm/util.c:152:16: warning: cast to restricted __le64
fs/dlm/util.c:153:21: warning: cast to restricted __le64

Signed-off-by: Harvey Harrison <harvey.harrison@gmail.com>
---
 fs/dlm/dir.c  |   18 ++++----
 fs/dlm/util.c |  148 ++++++++++++++++++++++++++++----------------------------
 2 files changed, 83 insertions(+), 83 deletions(-)

diff --git a/fs/dlm/dir.c b/fs/dlm/dir.c
index 85defeb..92969f8 100644
--- a/fs/dlm/dir.c
+++ b/fs/dlm/dir.c
@@ -374,7 +374,7 @@ void dlm_copy_master_names(struct dlm_ls *ls, char *inbuf, int inlen,
 	struct list_head *list;
 	struct dlm_rsb *r;
 	int offset = 0, dir_nodeid;
-	uint16_t be_namelen;
+	__be16 be_namelen;
 
 	down_read(&ls->ls_root_sem);
 
@@ -410,15 +410,15 @@ void dlm_copy_master_names(struct dlm_ls *ls, char *inbuf, int inlen,
 
 		if (offset + sizeof(uint16_t)*2 + r->res_length > outlen) {
 			/* Write end-of-block record */
-			be_namelen = 0;
-			memcpy(outbuf + offset, &be_namelen, sizeof(uint16_t));
-			offset += sizeof(uint16_t);
+			be_namelen = cpu_to_be16(0);
+			memcpy(outbuf + offset, &be_namelen, sizeof(__be16));
+			offset += sizeof(__be16);
 			goto out;
 		}
 
 		be_namelen = cpu_to_be16(r->res_length);
-		memcpy(outbuf + offset, &be_namelen, sizeof(uint16_t));
-		offset += sizeof(uint16_t);
+		memcpy(outbuf + offset, &be_namelen, ...
From: Al Viro
Date: Wednesday, July 16, 2008 - 2:38 pm

On Wed, Jul 16, 2008 at 01:16:07PM -0700, Harvey Harrison wrote:


NAK on ones below.  You are only hiding the warnings; ...s() is not making
--

From: Harvey Harrison
Date: Wednesday, July 16, 2008 - 2:43 pm

I'd suggest that any use of {endian}s() points to code that should be
looked at.  But if you'd also rather have the warnings, so be it.

Cheers,

Harvey

--

From: Al Viro
Date: Wednesday, July 16, 2008 - 3:12 pm

Frankly, I would rather have the rest of byteswaps in dlm eliminated...
--

From: Harvey Harrison
Date: Thursday, July 17, 2008 - 1:00 pm

I am curious though, in the general case of taking stuff off the wire
and doing work on it in-place.  Would you suggest two structs for things
like this, one in cpu-order and one with the endian annotations, then
the one place where you receive can do appropriate endian conversion
using a pointer to a wire-endian struct and the rest of the code just
uses the cpu-endian struct everywhere?

Just a general design question.

In the DLM case, these util functions are only used in 1-2 places each
so it wouldn't be too bad to fold them into the receive/send paths, but
you still need to byteswap somewhere, just curious what you are
suggesting.

Harvey

--

Previous thread: [PATCH] block: Trivial fix for blk_integrity_rq() by Martin K. Petersen on Wednesday, July 16, 2008 - 1:09 pm. (1 message)

Next thread: [PATCH] : A better approach to compute int_sqrt in lib/int_sqrt.c by Soumyadip Das Mahapatra on Wednesday, July 16, 2008 - 1:19 pm. (2 messages)