Linux: cache bypass: avoid unused variable warnings
[openafs.git] / src / afs / afs_bypasscache.c
index 5ec1fce..baa79e1 100644 (file)
@@ -303,7 +303,8 @@ static afs_int32
 afs_NoCacheFetchProc(register struct rx_call *acall, 
                      register struct vcache *avc, 
                                         register uio_t *auio, 
-                     afs_int32 release_pages)
+                     afs_int32 release_pages,
+                    afs_int32 size)
 {
     afs_int32 length;
     afs_int32 code;
@@ -336,6 +337,14 @@ afs_NoCacheFetchProc(register struct rx_call *acall,
            goto done;
        } else
            length = ntohl(length);             
+
+       if (length > size) {
+           result = EIO;
+           afs_warn("Preread error. Got length %d, which is greater than size %d\n",
+                    length, size);
+           unlock_pages(auio);
+           goto done;
+       }
                                        
        /*
         * The fetch protocol is extended for the AFS/DFS translator
@@ -492,7 +501,7 @@ afs_ReadNoCache(register struct vcache *avc,
     AFS_GLOCK();
     while(bcnt < 20) {
        breq = afs_BQueue(BOP_FETCH_NOCACHE, avc, B_DONTWAIT, 0, acred, 1, 1,
-                         bparms);
+                         bparms, (void *)0, (void *)0);
        if(breq != 0) {
            code = 0;
            break;
@@ -538,7 +547,10 @@ afs_PrefetchNoCache(register struct vcache *avc,
     uio_t *auio;
     struct iovec *iovecp;
     struct vrequest *areq;
-    afs_int32 code, length_hi, bytes, locked;    
+    afs_int32 code = 0;
+#ifdef AFS_64BIT_CLIENT
+    afs_int32 length_hi, bytes, locked;
+#endif
        
     register struct afs_conn *tc;
     afs_int32 i;
@@ -606,7 +618,8 @@ afs_PrefetchNoCache(register struct vcache *avc,
 #endif
            if (code == 0) {
                code = afs_NoCacheFetchProc(tcall, avc, auio,
-                                           1 /* release_pages */);
+                                           1 /* release_pages */,
+                                           bparms->length);
            } else {
                afs_warn("BYPASS: StartRXAFS_FetchData failed: %d\n", code);
                unlock_pages(auio);