* [PATCH] net/9p: Use proper data types
@ 2011-01-05 16:53 M. Mohan Kumar
2011-01-05 17:07 ` [V9fs-developer] " M. Mohan Kumar
2011-01-05 23:30 ` Venkateswararao Jujjuri (JV)
0 siblings, 2 replies; 3+ messages in thread
From: M. Mohan Kumar @ 2011-01-05 16:53 UTC (permalink / raw)
To: v9fs-developer, linux-fsdevel@vger.kernel.org, LKML
Use proper data types for storing the count of the binary blob and
length of a string. Without this patch length calculation of string will
always result in -1 because of comparision between signed and unsigned
integer.
Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
---
net/9p/protocol.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/net/9p/protocol.c b/net/9p/protocol.c
index c5180fd..2902eb1 100644
--- a/net/9p/protocol.c
+++ b/net/9p/protocol.c
@@ -234,14 +234,14 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
}
break;
case 'D':{
- int32_t *count = va_arg(ap, int32_t *);
+ uint32_t *count = va_arg(ap, int32_t *);
void **data = va_arg(ap, void **);
errcode =
p9pdu_readf(pdu, proto_version, "d", count);
if (!errcode) {
*count =
- min_t(int32_t, *count,
+ min_t(uint32_t, *count,
pdu->size - pdu->offset);
*data = &pdu->sdata[pdu->offset];
}
@@ -404,9 +404,9 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
break;
case 's':{
const char *sptr = va_arg(ap, const char *);
- int16_t len = 0;
+ uint16_t len = 0;
if (sptr)
- len = min_t(int16_t, strlen(sptr),
+ len = min_t(uint16_t, strlen(sptr),
USHRT_MAX);
errcode = p9pdu_writef(pdu, proto_version,
--
1.7.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [V9fs-developer] [PATCH] net/9p: Use proper data types
2011-01-05 16:53 [PATCH] net/9p: Use proper data types M. Mohan Kumar
@ 2011-01-05 17:07 ` M. Mohan Kumar
2011-01-05 23:30 ` Venkateswararao Jujjuri (JV)
1 sibling, 0 replies; 3+ messages in thread
From: M. Mohan Kumar @ 2011-01-05 17:07 UTC (permalink / raw)
To: v9fs-developer; +Cc: linux-fsdevel@vger.kernel.org, LKML
Commit 33551d7be66cec324c47990ed526b7fe327b011f net/9p/protocol.c: Remove
duplicated macros from Thiago Farina <tfransosi@gmail.com> exposed this issue
On Wednesday 05 January 2011 10:23:43 pm M. Mohan Kumar wrote:
> Use proper data types for storing the count of the binary blob and
> length of a string. Without this patch length calculation of string will
> always result in -1 because of comparision between signed and unsigned
> integer.
>
> Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
> ---
> net/9p/protocol.c | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/net/9p/protocol.c b/net/9p/protocol.c
> index c5180fd..2902eb1 100644
> --- a/net/9p/protocol.c
> +++ b/net/9p/protocol.c
> @@ -234,14 +234,14 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version,
> const char *fmt, }
> break;
> case 'D':{
> - int32_t *count = va_arg(ap, int32_t *);
> + uint32_t *count = va_arg(ap, int32_t *);
> void **data = va_arg(ap, void **);
>
> errcode =
> p9pdu_readf(pdu, proto_version, "d", count);
> if (!errcode) {
> *count =
> - min_t(int32_t, *count,
> + min_t(uint32_t, *count,
> pdu->size - pdu->offset);
> *data = &pdu->sdata[pdu->offset];
> }
> @@ -404,9 +404,9 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version,
> const char *fmt, break;
> case 's':{
> const char *sptr = va_arg(ap, const char *);
> - int16_t len = 0;
> + uint16_t len = 0;
> if (sptr)
> - len = min_t(int16_t, strlen(sptr),
> + len = min_t(uint16_t, strlen(sptr),
> USHRT_MAX);
>
> errcode = p9pdu_writef(pdu, proto_version,
----
M. Mohan Kumar
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [V9fs-developer] [PATCH] net/9p: Use proper data types
2011-01-05 16:53 [PATCH] net/9p: Use proper data types M. Mohan Kumar
2011-01-05 17:07 ` [V9fs-developer] " M. Mohan Kumar
@ 2011-01-05 23:30 ` Venkateswararao Jujjuri (JV)
1 sibling, 0 replies; 3+ messages in thread
From: Venkateswararao Jujjuri (JV) @ 2011-01-05 23:30 UTC (permalink / raw)
To: M. Mohan Kumar; +Cc: v9fs-developer, linux-fsdevel@vger.kernel.org, LKML
On 1/5/2011 8:53 AM, M. Mohan Kumar wrote:
> Use proper data types for storing the count of the binary blob and
> length of a string. Without this patch length calculation of string will
> always result in -1 because of comparision between signed and unsigned
> integer.
>
> Signed-off-by: M. Mohan Kumar <mohan@in.ibm.com>
> ---
> net/9p/protocol.c | 8 ++++----
> 1 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/net/9p/protocol.c b/net/9p/protocol.c
> index c5180fd..2902eb1 100644
> --- a/net/9p/protocol.c
> +++ b/net/9p/protocol.c
> @@ -234,14 +234,14 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
> }
> break;
> case 'D':{
> - int32_t *count = va_arg(ap, int32_t *);
> + uint32_t *count = va_arg(ap, int32_t *);
uinit32_t * inside the va_arg also to be consistent?
> void **data = va_arg(ap, void **);
>
> errcode =
> p9pdu_readf(pdu, proto_version, "d", count);
> if (!errcode) {
> *count =
> - min_t(int32_t, *count,
> + min_t(uint32_t, *count,
> pdu->size - pdu->offset);
> *data = &pdu->sdata[pdu->offset];
> }
Did you take care of MAX/max_t comparisons too? Looks like you missed at least
one for case 's'
Thanks,
JV
> @@ -404,9 +404,9 @@ p9pdu_vwritef(struct p9_fcall *pdu, int proto_version, const char *fmt,
> break;
> case 's':{
> const char *sptr = va_arg(ap, const char *);
> - int16_t len = 0;
> + uint16_t len = 0;
> if (sptr)
> - len = min_t(int16_t, strlen(sptr),
> + len = min_t(uint16_t, strlen(sptr),
> USHRT_MAX);
>
> errcode = p9pdu_writef(pdu, proto_version,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-05 23:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-05 16:53 [PATCH] net/9p: Use proper data types M. Mohan Kumar
2011-01-05 17:07 ` [V9fs-developer] " M. Mohan Kumar
2011-01-05 23:30 ` Venkateswararao Jujjuri (JV)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).