aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/nfs4xdr.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-05-14 16:50:45 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-05-14 19:33:45 -0400
commit8ae20abdd18c6c7f21bbae931353e7cfad77d7b6 (patch)
tree8134b98cb6b741742972764307d455e078c52bbf /fs/nfs/nfs4xdr.c
parent60945cb7c8377b727288275f21791914fe65311c (diff)
NFS4: Fix incorrect use of sizeof() in fs/nfs/nfs4xdr.c
The XDR code should not depend on the physical allocation size of structures like nfs4_stateid and nfs4_verifier since those may have to change at some future date. We therefore replace all uses of sizeof() with constants like NFS4_VERIFIER_SIZE and NFS4_STATEID_SIZE. This also has the side-effect of fixing some warnings of the type format ‘%u’ expects type ‘unsigned int’, but argument X has type ‘long unsigned int’ on 64-bit systems Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/nfs4xdr.c')
-rw-r--r--fs/nfs/nfs4xdr.c90
1 files changed, 45 insertions, 45 deletions
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 938f37166788..a57eacfec4d0 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -646,10 +646,10 @@ static int encode_close(struct xdr_stream *xdr, const struct nfs_closeargs *arg)
646{ 646{
647 __be32 *p; 647 __be32 *p;
648 648
649 RESERVE_SPACE(8+sizeof(arg->stateid->data)); 649 RESERVE_SPACE(8+NFS4_STATEID_SIZE);
650 WRITE32(OP_CLOSE); 650 WRITE32(OP_CLOSE);
651 WRITE32(arg->seqid->sequence->counter); 651 WRITE32(arg->seqid->sequence->counter);
652 WRITEMEM(arg->stateid->data, sizeof(arg->stateid->data)); 652 WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE);
653 653
654 return 0; 654 return 0;
655} 655}
@@ -793,17 +793,17 @@ static int encode_lock(struct xdr_stream *xdr, const struct nfs_lock_args *args)
793 WRITE64(nfs4_lock_length(args->fl)); 793 WRITE64(nfs4_lock_length(args->fl));
794 WRITE32(args->new_lock_owner); 794 WRITE32(args->new_lock_owner);
795 if (args->new_lock_owner){ 795 if (args->new_lock_owner){
796 RESERVE_SPACE(40); 796 RESERVE_SPACE(4+NFS4_STATEID_SIZE+20);
797 WRITE32(args->open_seqid->sequence->counter); 797 WRITE32(args->open_seqid->sequence->counter);
798 WRITEMEM(args->open_stateid->data, sizeof(args->open_stateid->data)); 798 WRITEMEM(args->open_stateid->data, NFS4_STATEID_SIZE);
799 WRITE32(args->lock_seqid->sequence->counter); 799 WRITE32(args->lock_seqid->sequence->counter);
800 WRITE64(args->lock_owner.clientid); 800 WRITE64(args->lock_owner.clientid);
801 WRITE32(4); 801 WRITE32(4);
802 WRITE32(args->lock_owner.id); 802 WRITE32(args->lock_owner.id);
803 } 803 }
804 else { 804 else {
805 RESERVE_SPACE(20); 805 RESERVE_SPACE(NFS4_STATEID_SIZE+4);
806 WRITEMEM(args->lock_stateid->data, sizeof(args->lock_stateid->data)); 806 WRITEMEM(args->lock_stateid->data, NFS4_STATEID_SIZE);
807 WRITE32(args->lock_seqid->sequence->counter); 807 WRITE32(args->lock_seqid->sequence->counter);
808 } 808 }
809 809
@@ -830,11 +830,11 @@ static int encode_locku(struct xdr_stream *xdr, const struct nfs_locku_args *arg
830{ 830{
831 __be32 *p; 831 __be32 *p;
832 832
833 RESERVE_SPACE(44); 833 RESERVE_SPACE(12+NFS4_STATEID_SIZE+16);
834 WRITE32(OP_LOCKU); 834 WRITE32(OP_LOCKU);
835 WRITE32(nfs4_lock_type(args->fl, 0)); 835 WRITE32(nfs4_lock_type(args->fl, 0));
836 WRITE32(args->seqid->sequence->counter); 836 WRITE32(args->seqid->sequence->counter);
837 WRITEMEM(args->stateid->data, sizeof(args->stateid->data)); 837 WRITEMEM(args->stateid->data, NFS4_STATEID_SIZE);
838 WRITE64(args->fl->fl_start); 838 WRITE64(args->fl->fl_start);
839 WRITE64(nfs4_lock_length(args->fl)); 839 WRITE64(nfs4_lock_length(args->fl));
840 840
@@ -966,9 +966,9 @@ static inline void encode_claim_delegate_cur(struct xdr_stream *xdr, const struc
966{ 966{
967 __be32 *p; 967 __be32 *p;
968 968
969 RESERVE_SPACE(4+sizeof(stateid->data)); 969 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
970 WRITE32(NFS4_OPEN_CLAIM_DELEGATE_CUR); 970 WRITE32(NFS4_OPEN_CLAIM_DELEGATE_CUR);
971 WRITEMEM(stateid->data, sizeof(stateid->data)); 971 WRITEMEM(stateid->data, NFS4_STATEID_SIZE);
972 encode_string(xdr, name->len, name->name); 972 encode_string(xdr, name->len, name->name);
973} 973}
974 974
@@ -996,9 +996,9 @@ static int encode_open_confirm(struct xdr_stream *xdr, const struct nfs_open_con
996{ 996{
997 __be32 *p; 997 __be32 *p;
998 998
999 RESERVE_SPACE(8+sizeof(arg->stateid->data)); 999 RESERVE_SPACE(4+NFS4_STATEID_SIZE+4);
1000 WRITE32(OP_OPEN_CONFIRM); 1000 WRITE32(OP_OPEN_CONFIRM);
1001 WRITEMEM(arg->stateid->data, sizeof(arg->stateid->data)); 1001 WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE);
1002 WRITE32(arg->seqid->sequence->counter); 1002 WRITE32(arg->seqid->sequence->counter);
1003 1003
1004 return 0; 1004 return 0;
@@ -1008,9 +1008,9 @@ static int encode_open_downgrade(struct xdr_stream *xdr, const struct nfs_closea
1008{ 1008{
1009 __be32 *p; 1009 __be32 *p;
1010 1010
1011 RESERVE_SPACE(8+sizeof(arg->stateid->data)); 1011 RESERVE_SPACE(4+NFS4_STATEID_SIZE+4);
1012 WRITE32(OP_OPEN_DOWNGRADE); 1012 WRITE32(OP_OPEN_DOWNGRADE);
1013 WRITEMEM(arg->stateid->data, sizeof(arg->stateid->data)); 1013 WRITEMEM(arg->stateid->data, NFS4_STATEID_SIZE);
1014 WRITE32(arg->seqid->sequence->counter); 1014 WRITE32(arg->seqid->sequence->counter);
1015 encode_share_access(xdr, arg->open_flags); 1015 encode_share_access(xdr, arg->open_flags);
1016 return 0; 1016 return 0;
@@ -1045,12 +1045,12 @@ static void encode_stateid(struct xdr_stream *xdr, const struct nfs_open_context
1045 nfs4_stateid stateid; 1045 nfs4_stateid stateid;
1046 __be32 *p; 1046 __be32 *p;
1047 1047
1048 RESERVE_SPACE(16); 1048 RESERVE_SPACE(NFS4_STATEID_SIZE);
1049 if (ctx->state != NULL) { 1049 if (ctx->state != NULL) {
1050 nfs4_copy_stateid(&stateid, ctx->state, ctx->lockowner); 1050 nfs4_copy_stateid(&stateid, ctx->state, ctx->lockowner);
1051 WRITEMEM(stateid.data, sizeof(stateid.data)); 1051 WRITEMEM(stateid.data, NFS4_STATEID_SIZE);
1052 } else 1052 } else
1053 WRITEMEM(zero_stateid.data, sizeof(zero_stateid.data)); 1053 WRITEMEM(zero_stateid.data, NFS4_STATEID_SIZE);
1054} 1054}
1055 1055
1056static int encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args) 1056static int encode_read(struct xdr_stream *xdr, const struct nfs_readargs *args)
@@ -1079,10 +1079,10 @@ static int encode_readdir(struct xdr_stream *xdr, const struct nfs4_readdir_arg
1079 int replen; 1079 int replen;
1080 __be32 *p; 1080 __be32 *p;
1081 1081
1082 RESERVE_SPACE(32+sizeof(nfs4_verifier)); 1082 RESERVE_SPACE(12+NFS4_VERIFIER_SIZE+20);
1083 WRITE32(OP_READDIR); 1083 WRITE32(OP_READDIR);
1084 WRITE64(readdir->cookie); 1084 WRITE64(readdir->cookie);
1085 WRITEMEM(readdir->verifier.data, sizeof(readdir->verifier.data)); 1085 WRITEMEM(readdir->verifier.data, NFS4_VERIFIER_SIZE);
1086 WRITE32(readdir->count >> 1); /* We're not doing readdirplus */ 1086 WRITE32(readdir->count >> 1); /* We're not doing readdirplus */
1087 WRITE32(readdir->count); 1087 WRITE32(readdir->count);
1088 WRITE32(2); 1088 WRITE32(2);
@@ -1190,9 +1190,9 @@ encode_setacl(struct xdr_stream *xdr, struct nfs_setaclargs *arg)
1190{ 1190{
1191 __be32 *p; 1191 __be32 *p;
1192 1192
1193 RESERVE_SPACE(4+sizeof(zero_stateid.data)); 1193 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
1194 WRITE32(OP_SETATTR); 1194 WRITE32(OP_SETATTR);
1195 WRITEMEM(zero_stateid.data, sizeof(zero_stateid.data)); 1195 WRITEMEM(zero_stateid.data, NFS4_STATEID_SIZE);
1196 RESERVE_SPACE(2*4); 1196 RESERVE_SPACE(2*4);
1197 WRITE32(1); 1197 WRITE32(1);
1198 WRITE32(FATTR4_WORD0_ACL); 1198 WRITE32(FATTR4_WORD0_ACL);
@@ -1220,9 +1220,9 @@ static int encode_setattr(struct xdr_stream *xdr, const struct nfs_setattrargs *
1220 int status; 1220 int status;
1221 __be32 *p; 1221 __be32 *p;
1222 1222
1223 RESERVE_SPACE(4+sizeof(arg->stateid.data)); 1223 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
1224 WRITE32(OP_SETATTR); 1224 WRITE32(OP_SETATTR);
1225 WRITEMEM(arg->stateid.data, sizeof(arg->stateid.data)); 1225 WRITEMEM(arg->stateid.data, NFS4_STATEID_SIZE);
1226 1226
1227 if ((status = encode_attrs(xdr, arg->iap, server))) 1227 if ((status = encode_attrs(xdr, arg->iap, server)))
1228 return status; 1228 return status;
@@ -1234,9 +1234,9 @@ static int encode_setclientid(struct xdr_stream *xdr, const struct nfs4_setclien
1234{ 1234{
1235 __be32 *p; 1235 __be32 *p;
1236 1236
1237 RESERVE_SPACE(4 + sizeof(setclientid->sc_verifier->data)); 1237 RESERVE_SPACE(4 + NFS4_VERIFIER_SIZE);
1238 WRITE32(OP_SETCLIENTID); 1238 WRITE32(OP_SETCLIENTID);
1239 WRITEMEM(setclientid->sc_verifier->data, sizeof(setclientid->sc_verifier->data)); 1239 WRITEMEM(setclientid->sc_verifier->data, NFS4_VERIFIER_SIZE);
1240 1240
1241 encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name); 1241 encode_string(xdr, setclientid->sc_name_len, setclientid->sc_name);
1242 RESERVE_SPACE(4); 1242 RESERVE_SPACE(4);
@@ -1253,10 +1253,10 @@ static int encode_setclientid_confirm(struct xdr_stream *xdr, const struct nfs_c
1253{ 1253{
1254 __be32 *p; 1254 __be32 *p;
1255 1255
1256 RESERVE_SPACE(12 + sizeof(client_state->cl_confirm.data)); 1256 RESERVE_SPACE(12 + NFS4_VERIFIER_SIZE);
1257 WRITE32(OP_SETCLIENTID_CONFIRM); 1257 WRITE32(OP_SETCLIENTID_CONFIRM);
1258 WRITE64(client_state->cl_clientid); 1258 WRITE64(client_state->cl_clientid);
1259 WRITEMEM(client_state->cl_confirm.data, sizeof(client_state->cl_confirm.data)); 1259 WRITEMEM(client_state->cl_confirm.data, NFS4_VERIFIER_SIZE);
1260 1260
1261 return 0; 1261 return 0;
1262} 1262}
@@ -1284,10 +1284,10 @@ static int encode_delegreturn(struct xdr_stream *xdr, const nfs4_stateid *statei
1284{ 1284{
1285 __be32 *p; 1285 __be32 *p;
1286 1286
1287 RESERVE_SPACE(20); 1287 RESERVE_SPACE(4+NFS4_STATEID_SIZE);
1288 1288
1289 WRITE32(OP_DELEGRETURN); 1289 WRITE32(OP_DELEGRETURN);
1290 WRITEMEM(stateid->data, sizeof(stateid->data)); 1290 WRITEMEM(stateid->data, NFS4_STATEID_SIZE);
1291 return 0; 1291 return 0;
1292 1292
1293} 1293}
@@ -2897,8 +2897,8 @@ static int decode_close(struct xdr_stream *xdr, struct nfs_closeres *res)
2897 status = decode_op_hdr(xdr, OP_CLOSE); 2897 status = decode_op_hdr(xdr, OP_CLOSE);
2898 if (status) 2898 if (status)
2899 return status; 2899 return status;
2900 READ_BUF(sizeof(res->stateid.data)); 2900 READ_BUF(NFS4_STATEID_SIZE);
2901 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 2901 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
2902 return 0; 2902 return 0;
2903} 2903}
2904 2904
@@ -3186,8 +3186,8 @@ static int decode_lock(struct xdr_stream *xdr, struct nfs_lock_res *res)
3186 3186
3187 status = decode_op_hdr(xdr, OP_LOCK); 3187 status = decode_op_hdr(xdr, OP_LOCK);
3188 if (status == 0) { 3188 if (status == 0) {
3189 READ_BUF(sizeof(res->stateid.data)); 3189 READ_BUF(NFS4_STATEID_SIZE);
3190 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 3190 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3191 } else if (status == -NFS4ERR_DENIED) 3191 } else if (status == -NFS4ERR_DENIED)
3192 return decode_lock_denied(xdr, NULL); 3192 return decode_lock_denied(xdr, NULL);
3193 return status; 3193 return status;
@@ -3209,8 +3209,8 @@ static int decode_locku(struct xdr_stream *xdr, struct nfs_locku_res *res)
3209 3209
3210 status = decode_op_hdr(xdr, OP_LOCKU); 3210 status = decode_op_hdr(xdr, OP_LOCKU);
3211 if (status == 0) { 3211 if (status == 0) {
3212 READ_BUF(sizeof(res->stateid.data)); 3212 READ_BUF(NFS4_STATEID_SIZE);
3213 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 3213 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3214 } 3214 }
3215 return status; 3215 return status;
3216} 3216}
@@ -3251,8 +3251,8 @@ static int decode_delegation(struct xdr_stream *xdr, struct nfs_openres *res)
3251 res->delegation_type = 0; 3251 res->delegation_type = 0;
3252 return 0; 3252 return 0;
3253 } 3253 }
3254 READ_BUF(20); 3254 READ_BUF(NFS4_STATEID_SIZE+4);
3255 COPYMEM(res->delegation.data, sizeof(res->delegation.data)); 3255 COPYMEM(res->delegation.data, NFS4_STATEID_SIZE);
3256 READ32(res->do_recall); 3256 READ32(res->do_recall);
3257 switch (delegation_type) { 3257 switch (delegation_type) {
3258 case NFS4_OPEN_DELEGATE_READ: 3258 case NFS4_OPEN_DELEGATE_READ:
@@ -3275,8 +3275,8 @@ static int decode_open(struct xdr_stream *xdr, struct nfs_openres *res)
3275 status = decode_op_hdr(xdr, OP_OPEN); 3275 status = decode_op_hdr(xdr, OP_OPEN);
3276 if (status) 3276 if (status)
3277 return status; 3277 return status;
3278 READ_BUF(sizeof(res->stateid.data)); 3278 READ_BUF(NFS4_STATEID_SIZE);
3279 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 3279 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3280 3280
3281 decode_change_info(xdr, &res->cinfo); 3281 decode_change_info(xdr, &res->cinfo);
3282 3282
@@ -3302,8 +3302,8 @@ static int decode_open_confirm(struct xdr_stream *xdr, struct nfs_open_confirmre
3302 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM); 3302 status = decode_op_hdr(xdr, OP_OPEN_CONFIRM);
3303 if (status) 3303 if (status)
3304 return status; 3304 return status;
3305 READ_BUF(sizeof(res->stateid.data)); 3305 READ_BUF(NFS4_STATEID_SIZE);
3306 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 3306 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3307 return 0; 3307 return 0;
3308} 3308}
3309 3309
@@ -3315,8 +3315,8 @@ static int decode_open_downgrade(struct xdr_stream *xdr, struct nfs_closeres *re
3315 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE); 3315 status = decode_op_hdr(xdr, OP_OPEN_DOWNGRADE);
3316 if (status) 3316 if (status)
3317 return status; 3317 return status;
3318 READ_BUF(sizeof(res->stateid.data)); 3318 READ_BUF(NFS4_STATEID_SIZE);
3319 COPYMEM(res->stateid.data, sizeof(res->stateid.data)); 3319 COPYMEM(res->stateid.data, NFS4_STATEID_SIZE);
3320 return 0; 3320 return 0;
3321} 3321}
3322 3322
@@ -3590,9 +3590,9 @@ static int decode_setclientid(struct xdr_stream *xdr, struct nfs_client *clp)
3590 } 3590 }
3591 READ32(nfserr); 3591 READ32(nfserr);
3592 if (nfserr == NFS_OK) { 3592 if (nfserr == NFS_OK) {
3593 READ_BUF(8 + sizeof(clp->cl_confirm.data)); 3593 READ_BUF(8 + NFS4_VERIFIER_SIZE);
3594 READ64(clp->cl_clientid); 3594 READ64(clp->cl_clientid);
3595 COPYMEM(clp->cl_confirm.data, sizeof(clp->cl_confirm.data)); 3595 COPYMEM(clp->cl_confirm.data, NFS4_VERIFIER_SIZE);
3596 } else if (nfserr == NFSERR_CLID_INUSE) { 3596 } else if (nfserr == NFSERR_CLID_INUSE) {
3597 uint32_t len; 3597 uint32_t len;
3598 3598