lkml.org 
[lkml]   [2009]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V3 10/17] Squashfs: cache operations
On Mon, 5 Jan 2009, Phillip Lougher wrote:
> diff --git a/fs/squashfs/cache.c b/fs/squashfs/cache.c
> new file mode 100644
> index 0000000..f29eda1
> --- /dev/null
> +++ b/fs/squashfs/cache.c

> +/*
> + * Copy upto length bytes from cache entry to buffer starting at offset bytes
> + * into the cache entry. If there's not length bytes then copy the number of
> + * bytes available. In all cases return the number of bytes copied.
> + */
> +int squashfs_copy_data(void *buffer, struct squashfs_cache_entry *entry,
^
const?

It also makes it clear from the prototype in which direction is copied.
> + int offset, int length)
^^^ ^^^
> +{
> + int remaining = length;
^^^
Shouldn't all of these be unsigned int?

> +
> + 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);
> + int bytes = min_t(int, entry->length - offset,
> + PAGE_CACHE_SIZE - (offset % PAGE_CACHE_SIZE));
> +
> + if (bytes >= remaining) {
> + memcpy(buffer, buff, remaining);
> + remaining = 0;
> + break;
> + }
> +
> + memcpy(buffer, buff, bytes);
> + buffer += bytes;
> + remaining -= bytes;
> + offset += bytes;
> + }
> +
> + return length - remaining;
> +}

With kind regards,

Geert Uytterhoeven
Software Architect

Sony Techsoft Centre Europe
The Corporate Village · Da Vincilaan 7-D1 · B-1935 Zaventem · Belgium

Phone: +32 (0)2 700 8453
Fax: +32 (0)2 700 8622
E-mail: Geert.Uytterhoeven@sonycom.com
Internet: http://www.sony-europe.com/

A division of Sony Europe (Belgium) N.V.
VAT BE 0413.825.160 · RPR Brussels
Fortis · BIC GEBABEBB · IBAN BE41293037680010
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2009-01-07 17:21    [W:0.028 / U:20.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site