Skip to contentSkip to conversation

NFS: Fix compiler warnings in fs/nfs/callback_xdr.c

PATCH In review Chuck Lever 2 participants 3 messages May 25, 2007 – May 29, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 5/10 NFS: Fix compiler warnings in fs/nfs/callback_xdr.c

---

 fs/nfs/callback_xdr.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/nfs/callback_xdr.c +2 -2
index 849a202..d664193 100644
@@ -139,7 +139,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound
 	if (unlikely(status != 0))
 		return status;
 	/* We do not like overly long tags! */
-	if (hdr->taglen > CB_OP_TAGLEN_MAXSZ-12 || hdr->taglen < 0) {
+	if (hdr->taglen > CB_OP_TAGLEN_MAXSZ - 12) {
 		printk("NFSv4 CALLBACK %s: client sent tag of length %u\n",
 				__FUNCTION__, hdr->taglen);
 		return htonl(NFS4ERR_RESOURCE);
@@ -379,7 +379,7 @@ static __be32 process_op(struct svc_rqst *rqstp,
 	}
 
 	maxlen = xdr_out->end - xdr_out->p;
-	if (maxlen > 0 && maxlen < PAGE_SIZE) {
+	if (maxlen > 0 && maxlen < (long) PAGE_SIZE) {
 		if (likely(status == 0 && op->decode_args != NULL))
 			status = op->decode_args(rqstp, xdr_in, argp);
 		if (likely(status == 0 && op->process_op != NULL))

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#1 lore raw
Quoted 20 lines · Chuck Lever

---

 fs/nfs/callback_xdr.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/nfs/callback_xdr.c +1 -1
index 849a202..d664193 100644
@@ -139,7 +139,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound
 	if (unlikely(status != 0))
 		return status;
 	/* We do not like overly long tags! */
-	if (hdr->taglen > CB_OP_TAGLEN_MAXSZ-12 || hdr->taglen < 0) {
+	if (hdr->taglen > CB_OP_TAGLEN_MAXSZ - 12) {
 		printk("NFSv4 CALLBACK %s: client sent tag of length %u\n",
 				__FUNCTION__, hdr->taglen);
 		return htonl(NFS4ERR_RESOURCE);

fs/nfs/callback_xdr.c static __be32 process_op(struct svc_rqst *rqstp, · line 382

Quoted 5 lines
fs/nfs/callback_xdr.c +1 -1
@@ -379,7 +379,7 @@ static __be32 process_op(struct svc_rqst *rqstp,
 	}
 
 	maxlen = xdr_out->end - xdr_out->p;
-	if (maxlen > 0 && maxlen < PAGE_SIZE) {
+	if (maxlen > 0 && maxlen < (long) PAGE_SIZE) {

^^^^^^ shouldn't be needed. We've just checked that maxlen > 0.

fs/nfs/callback_xdr.c static __be32 process_op(struct svc_rqst *rqstp, · line 385

Quoted 4 lines
fs/nfs/callback_xdr.c +0 -0
 		if (likely(status == 0 && op->decode_args != NULL))
 			status = op->decode_args(rqstp, xdr_in, argp);
 		if (likely(status == 0 && op->process_op != NULL))

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs

#2 lore raw
Quoted 23 lines · Trond Myklebust
Quoted 22 lines · Chuck Lever

---

 fs/nfs/callback_xdr.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/nfs/callback_xdr.c +1 -1
index 849a202..d664193 100644
@@ -139,7 +139,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound
 	if (unlikely(status != 0))
 		return status;
 	/* We do not like overly long tags! */
-	if (hdr->taglen > CB_OP_TAGLEN_MAXSZ-12 || hdr->taglen < 0) {
+	if (hdr->taglen > CB_OP_TAGLEN_MAXSZ - 12) {
 		printk("NFSv4 CALLBACK %s: client sent tag of length %u\n",
 				__FUNCTION__, hdr->taglen);
 		return htonl(NFS4ERR_RESOURCE);
@@ -379,7 +379,7 @@ static __be32 process_op(struct svc_rqst *rqstp,
 	}
 
Quoted 4 lines

fs/nfs/callback_xdr.c static __be32 process_op(struct svc_rqst *rqstp, · line 382

Quoted 3 lines
fs/nfs/callback_xdr.c +1 -1
 	maxlen = xdr_out->end - xdr_out->p;
-	if (maxlen > 0 && maxlen < PAGE_SIZE) {
+	if (maxlen > 0 && maxlen < (long) PAGE_SIZE) {

^^^^^^ shouldn't be needed. We've just checked that maxlen > 0.

In this case, the "greater than zero" check is already there, so there isn't a bug. However, PAGE_SIZE is defined as an "unsigned" value. Comparing it to maxlen, which is "signed", produces a compiler warning.
The explicit cast documents that the signed versus unsigned comparison
is exactly what we want in this case.

Note that we included an explicit cast in the other fixes of this variety.

Quoted 4 lines

fs/nfs/callback_xdr.c static __be32 process_op(struct svc_rqst *rqstp, · line 385

Quoted 4 lines
fs/nfs/callback_xdr.c +0 -0
 		if (likely(status == 0 && op->decode_args != NULL))
 			status = op->decode_args(rqstp, xdr_in, argp);
 		if (likely(status == 0 && op->process_op != NULL))

begin:vcard
fn:Chuck Lever
n:Lever;Chuck
org:Oracle Corporation;Corporate Architecture: Linux Projects Group adr:;;1015 Granger Avenue;Ann Arbor;MI;48104;USA title:Principal Member of Staff
tel;work:+1 248 614 5091
x-mozilla-html:FALSE
url:http://oss.oracle.com/~cel/
version:2.1
end:vcard

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/

_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs