aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorplougher <plougher>2009-01-31 07:32:47 +0000
committerMohamad Ayyash <mkayyash@google.com>2015-02-23 12:34:12 -0800
commitdd2dee4f02c52cb10cde44cc1d44a2df28800294 (patch)
tree48a5739b2dfeeb27232eb71dd8273a8a607e24e5 /kernel
parent142191333e91c13aac6e6c2e718867a6b5f4088b (diff)
downloadsquashfs-tools-dd2dee4f02c52cb10cde44cc1d44a2df28800294.tar.gz
Squashfs_copy_data: add special case for length == 0, and factor out
buffer == NULL special case Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/fs/squashfs/cache.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/kernel/fs/squashfs/cache.c b/kernel/fs/squashfs/cache.c
index b2bc4de..ec1033e 100644
--- a/kernel/fs/squashfs/cache.c
+++ b/kernel/fs/squashfs/cache.c
@@ -273,6 +273,11 @@ int squashfs_copy_data(void *buffer, struct squashfs_cache_entry *entry,
{
int remaining = length;
+ if (length == 0)
+ return 0;
+ else if (buffer == NULL)
+ return min(length, entry->length - offset);
+
while (offset < entry->length) {
void *buff = entry->data[offset / PAGE_CACHE_SIZE]
+ (offset % PAGE_CACHE_SIZE);
@@ -280,17 +285,13 @@ int squashfs_copy_data(void *buffer, struct squashfs_cache_entry *entry,
PAGE_CACHE_SIZE - (offset % PAGE_CACHE_SIZE));
if (bytes >= remaining) {
- if (buffer)
- memcpy(buffer, buff, remaining);
+ memcpy(buffer, buff, remaining);
remaining = 0;
break;
}
- if (buffer) {
- memcpy(buffer, buff, bytes);
- buffer += bytes;
- }
-
+ memcpy(buffer, buff, bytes);
+ buffer += bytes;
remaining -= bytes;
offset += bytes;
}