net/9p: fix endian issues
PATCH 1/1 net/9p: fix endian issues
From: Eric Van Hensbergen <[email protected]>
When the changes were done to the protocol last release, some endian bugs crept in. This patch fixes those endian problems and has been verified to run on 32/64 bit and x86/ppc architectures.
--- net/9p/protocol.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)
net/9p/protocol.c +6 -6
@@ -164,7 +164,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) errcode = -EFAULT ;break ; } - *val =cpu_to_le16 (*val); + *val =le16_to_cpu (*val); }break ;case 'd' :{
@@ -173,7 +173,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) errcode = -EFAULT ;break ; } - *val =cpu_to_le32 (*val); + *val =le32_to_cpu (*val); }break ;case 'q' :{
@@ -182,7 +182,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) errcode = -EFAULT ;break ; } - *val =cpu_to_le64 (*val); + *val =le64_to_cpu (*val); }break ;case 's' :{
@@ -362,19 +362,19 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) }break ;case 'w' :{ -int16_t val =va_arg (ap, int); +int16_t val =cpu_to_le16 (va_arg (ap, int));if (pdu_write (pdu, &val,sizeof (val))) errcode = -EFAULT ; }break ;case 'd' :{ -int32_t val =va_arg (ap, int32_t); +int32_t val =cpu_to_le32 (va_arg (ap, int32_t));if (pdu_write (pdu, &val,sizeof (val))) errcode = -EFAULT ; }break ;case 'q' :{ -int64_t val =va_arg (ap, int64_t); +int64_t val =cpu_to_le64 (va_arg (ap, int64_t));if (pdu_write (pdu, &val,sizeof (val))) errcode = -EFAULT ; }
Signature · 1 line
1.5.6.3
Quoted 34 lines · On Tue, 2009-02-03 at 09:51 -0600, [email protected] wrote:
From: Eric Van Hensbergen <[email protected]>
When the changes were done to the protocol last release, some endian bugs crept in. This patch fixes those endian problems and has been verified to run on 32/64 bit and x86/ppc architectures.
Signed-off-by Eric Van Hensbergen <[email protected]>--- net/9p/protocol.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-)net/9p/protocol.c +2
-2@@ -164,7 +164,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) errcode = -EFAULT ;break ; } - *val =cpu_to_le16 (*val); + *val =le16_to_cpu (*val); }break ;case 'd' :{@@ -173,7 +173,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) errcode = -EFAULT ;break ; } - *val =cpu_to_le32 (*val); + *val =le32_to_cpu (*val); }break ;case 'q' :{
net/9p/protocol.c p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) · line 186
Quoted 6 lines
net/9p/protocol.c +1
-1@@ -182,7 +182,7 @@ p9pdu_vreadf(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) errcode = -EFAULT ;break ; } - *val =cpu_to_le64 (*val); + *val =le64_to_cpu (*val); }
Umm, the above three have absolutely no functional effect you know. And you're just trading one set of sparse warnings for another.
Quoted 15 lines
net/9p/protocol.c +2
-2break ;case 's' :{@@ -362,19 +362,19 @@ p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) }break ;case 'w' :{ -int16_t val =va_arg (ap, int); +int16_t val =cpu_to_le16 (va_arg (ap, int));if (pdu_write (pdu, &val,sizeof (val))) errcode = -EFAULT ; }break ;case 'd' :{ -int32_t val =va_arg (ap, int32_t); +int32_t val =cpu_to_le32 (va_arg (ap, int32_t));
net/9p/protocol.c p9pdu_vwritef(struct p9_fcall *pdu, int optional, const char *fmt, va_list ap) · line 380
Quoted 10 lines
net/9p/protocol.c +1
-1if (pdu_write (pdu, &val,sizeof (val))) errcode = -EFAULT ; }break ;case 'q' :{ -int64_t val =va_arg (ap, int64_t); +int64_t val =cpu_to_le64 (va_arg (ap, int64_t));if (pdu_write (pdu, &val,sizeof (val))) errcode = -EFAULT ; }
And here even if you are fixing endian bugs, you're actively _introducing_ sparse warnings, it would be nice if you could annotate the variable types properly too.
Cheers,
Harvey