Linux filesystem development
 help / color / mirror / Atom feed
* [PATCH 2.6.13-rc6-mm2] v9fs: use standard kernel byteswapping routines
@ 2005-08-28 21:05 Eric Van Hensbergen
  2005-08-28 21:46 ` Alexey Dobriyan
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Van Hensbergen @ 2005-08-28 21:05 UTC (permalink / raw)
  To: Linux FS Devel, V9FS Developers, Linux Kernel, Andrew Morton

[PATCH] v9fs: use standard kernel byteswapping routines

Originally suggested by hch, we have removed our byteswap code
and replaced it with calls to the standard kernel byteswapping code.

Signed-off-by: Eric Van Hensbergen <ericvh@gmail.com>

---
commit 06e00e56fdf2c3e230ff60f6fdab6db789f16e73
tree 6eff647a71c056d133aa0f0a9e0a0ff95af05683
parent f32fc66e311abe9e7167991e6b2d37e7c56dcc72
author Eric Van Hensbergen <ericvh@gmail.com> Sun, 28 Aug 2005 16:03:40
-0500
committer Eric Van Hensbergen <ericvh@gmail.com> Sun, 28 Aug 2005
16:03:40 -0500

 fs/9p/conv.c |   28 ++++++----------------------
 1 files changed, 6 insertions(+), 22 deletions(-)

diff --git a/fs/9p/conv.c b/fs/9p/conv.c
--- a/fs/9p/conv.c
+++ b/fs/9p/conv.c
@@ -88,8 +88,7 @@ static inline void buf_put_int16(struct 
 {
 	buf_check_size(buf, 2);
 
-	buf->p[0] = val;
-	buf->p[1] = val >> 8;
+	*(u16 *) buf->p = cpu_to_le16(val);
 	buf->p += 2;
 }
 
@@ -97,10 +96,7 @@ static inline void buf_put_int32(struct 
 {
 	buf_check_size(buf, 4);
 
-	buf->p[0] = val;
-	buf->p[1] = val >> 8;
-	buf->p[2] = val >> 16;
-	buf->p[3] = val >> 24;
+	*(u32 *)buf->p = cpu_to_le32(val);
 	buf->p += 4;
 }
 
@@ -108,14 +104,7 @@ static inline void buf_put_int64(struct 
 {
 	buf_check_size(buf, 8);
 
-	buf->p[0] = val;
-	buf->p[1] = val >> 8;
-	buf->p[2] = val >> 16;
-	buf->p[3] = val >> 24;
-	buf->p[4] = val >> 32;
-	buf->p[5] = val >> 40;
-	buf->p[6] = val >> 48;
-	buf->p[7] = val >> 56;
+	*(u64 *)buf->p = cpu_to_le64(val);
 	buf->p += 8;
 }
 
@@ -158,7 +147,7 @@ static inline u16 buf_get_int16(struct c
 	u16 ret = 0;
 
 	buf_check_size(buf, 2);
-	ret = buf->p[0] | (buf->p[1] << 8);
+	ret = le16_to_cpu(*(u16 *)buf->p);
 
 	buf->p += 2;
 
@@ -170,9 +159,7 @@ static inline u32 buf_get_int32(struct c
 	u32 ret = 0;
 
 	buf_check_size(buf, 4);
-	ret =
-	    buf->p[0] | (buf->p[1] << 8) | (buf->p[2] << 16) | (buf->
-								p[3] << 24);
+	ret = le32_to_cpu(*(u32 *)buf->p);
 
 	buf->p += 4;
 
@@ -184,10 +171,7 @@ static inline u64 buf_get_int64(struct c
 	u64 ret = 0;
 
 	buf_check_size(buf, 8);
-	ret = (u64) buf->p[0] | ((u64) buf->p[1] << 8) |
-	    ((u64) buf->p[2] << 16) | ((u64) buf->p[3] << 24) |
-	    ((u64) buf->p[4] << 32) | ((u64) buf->p[5] << 40) |
-	    ((u64) buf->p[6] << 48) | ((u64) buf->p[7] << 56);
+	ret = le64_to_cpu(*(u64 *)buf->p);
 
 	buf->p += 8;
 



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6.13-rc6-mm2] v9fs: use standard kernel byteswapping routines
  2005-08-28 21:46 ` Alexey Dobriyan
@ 2005-08-28 21:43   ` Eric Van Hensbergen
  2005-08-28 21:59     ` Alexey Dobriyan
  0 siblings, 1 reply; 4+ messages in thread
From: Eric Van Hensbergen @ 2005-08-28 21:43 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: Linux FS Devel, V9FS Developers, Linux Kernel, Andrew Morton

On 8/28/05, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> On Sun, Aug 28, 2005 at 04:05:07PM -0500, Eric Van Hensbergen wrote:
> > [PATCH] v9fs: use standard kernel byteswapping routines
> >
> > Originally suggested by hch, we have removed our byteswap code
> > and replaced it with calls to the standard kernel byteswapping code.
> 
> > -     buf->p[0] = val;
> > -     buf->p[1] = val >> 8;
> > +     *(u16 *) buf->p = cpu_to_le16(val);
> 
> *(__le16 *)
> 
> > -     ret = buf->p[0] | (buf->p[1] << 8);
> > +     ret = le16_to_cpu(*(u16 *)buf->p);
> 
> *(__le16 *) etc.
> 
> Otherwise sparse will warn.
> 

It didn't give me any complaints -- I'm building my kernels with a
recent (updated today) version of sparse and built with C=1 -- am I
not invoking it correctly?

            -eric

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6.13-rc6-mm2] v9fs: use standard kernel byteswapping routines
  2005-08-28 21:05 [PATCH 2.6.13-rc6-mm2] v9fs: use standard kernel byteswapping routines Eric Van Hensbergen
@ 2005-08-28 21:46 ` Alexey Dobriyan
  2005-08-28 21:43   ` Eric Van Hensbergen
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Dobriyan @ 2005-08-28 21:46 UTC (permalink / raw)
  To: Eric Van Hensbergen
  Cc: Linux FS Devel, V9FS Developers, Linux Kernel, Andrew Morton

On Sun, Aug 28, 2005 at 04:05:07PM -0500, Eric Van Hensbergen wrote:
> [PATCH] v9fs: use standard kernel byteswapping routines
> 
> Originally suggested by hch, we have removed our byteswap code
> and replaced it with calls to the standard kernel byteswapping code.

> -	buf->p[0] = val;
> -	buf->p[1] = val >> 8;
> +	*(u16 *) buf->p = cpu_to_le16(val);

*(__le16 *)

> -	ret = buf->p[0] | (buf->p[1] << 8);
> +	ret = le16_to_cpu(*(u16 *)buf->p);

*(__le16 *) etc.

Otherwise sparse will warn.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2.6.13-rc6-mm2] v9fs: use standard kernel byteswapping routines
  2005-08-28 21:43   ` Eric Van Hensbergen
@ 2005-08-28 21:59     ` Alexey Dobriyan
  0 siblings, 0 replies; 4+ messages in thread
From: Alexey Dobriyan @ 2005-08-28 21:59 UTC (permalink / raw)
  To: Eric Van Hensbergen
  Cc: Linux FS Devel, V9FS Developers, Linux Kernel, Andrew Morton

On Sun, Aug 28, 2005 at 04:43:27PM -0500, Eric Van Hensbergen wrote:
> On 8/28/05, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> > On Sun, Aug 28, 2005 at 04:05:07PM -0500, Eric Van Hensbergen wrote:
> > > [PATCH] v9fs: use standard kernel byteswapping routines
> > >
> > > Originally suggested by hch, we have removed our byteswap code
> > > and replaced it with calls to the standard kernel byteswapping code.
> > 
> > > -     buf->p[0] = val;
> > > -     buf->p[1] = val >> 8;
> > > +     *(u16 *) buf->p = cpu_to_le16(val);
> > 
> > *(__le16 *)
> > 
> > > -     ret = buf->p[0] | (buf->p[1] << 8);
> > > +     ret = le16_to_cpu(*(u16 *)buf->p);
> > 
> > *(__le16 *) etc.
> > 
> > Otherwise sparse will warn.
> > 
> 
> It didn't give me any complaints -- I'm building my kernels with a
> recent (updated today) version of sparse and built with C=1 -- am I
> not invoking it correctly?

	C=1 CHECK="sparse -Wbitwise"

This flag is not enabled by default. However, some of us are cleaning up
endian noise and not adding more would be nice.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2005-08-28 21:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-28 21:05 [PATCH 2.6.13-rc6-mm2] v9fs: use standard kernel byteswapping routines Eric Van Hensbergen
2005-08-28 21:46 ` Alexey Dobriyan
2005-08-28 21:43   ` Eric Van Hensbergen
2005-08-28 21:59     ` Alexey Dobriyan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox