[PATCH 1/1] fs/nfs: fix read when size < 1024

Jean-Christophe PLAGNIOL-VILLARD plagnioj at jcrosoft.com
Fri Sep 7 03:41:30 EDT 2012


Currently we always request 1024.

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj at jcrosoft.com>
---
 fs/nfs.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/nfs.c b/fs/nfs.c
index 4a880cd..797e3bd 100644
--- a/fs/nfs.c
+++ b/fs/nfs.c
@@ -819,7 +819,11 @@ static int nfs_read(struct device_d *dev, FILE *file, void *buf, size_t insize)
 		insize -= now;
 
 		if (insize) {
-			now = 1024;
+			/* do not use min as insize is a size_t */
+			if (insize < 1024)
+				now = insize;
+			else
+				now = 1024;
 
 			if (pos + now > file->size)
 				now = file->size - pos;
-- 
1.7.10.4




More information about the barebox mailing list