Re: [PATCH V3 10/17] Squashfs: cache operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx
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-embedded" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Gstreamer Embedded]     [Linux MMC Devel]     [U-Boot V2]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux ARM Kernel]     [Linux OMAP]     [Linux SCSI]

  Powered by Linux