[U-Boot] [U-Boot, v2, 1/1] fs: fat: avoid useless conversion when calling get_cluster

Tom Rini trini at konsulko.com
Fri Feb 23 15:40:28 UTC 2018


On Wed, Feb 14, 2018 at 07:17:28PM +0100, Heinrich Schuchardt wrote:

> Parameter size of function get_cluster() is of type unsigned long. It makes
> no sense to convert actsize to int before passing it to get_cluster as
> size. Let't use t_off as type of parameter to avoid any type conversion.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
> v2
> 	change type of parameter size
> ---
>  fs/fat/fat.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> index dd7888cd6d4..cf4580b63df 100644
> --- a/fs/fat/fat.c
> +++ b/fs/fat/fat.c
> @@ -244,7 +244,7 @@ static __u32 get_fatent(fsdata *mydata, __u32 entry)
>   * Return 0 on success, -1 otherwise.
>   */
>  static int
> -get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, unsigned long size)
> +get_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, loff_t size)
>  {
>  	__u32 idx = 0;
>  	__u32 startsect;
> @@ -353,7 +353,7 @@ static int get_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos,
>  	if (pos) {
>  		actsize = min(filesize, (loff_t)bytesperclust);
>  		if (get_cluster(mydata, curclust, get_contents_vfatname_block,
> -				(int)actsize) != 0) {
> +				actsize) != 0) {
>  			printf("Error reading cluster\n");
>  			return -1;
>  		}
> @@ -393,14 +393,14 @@ static int get_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos,
>  
>  		/* get remaining bytes */
>  		actsize = filesize;
> -		if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
> +		if (get_cluster(mydata, curclust, buffer, actsize) != 0) {
>  			printf("Error reading cluster\n");
>  			return -1;
>  		}
>  		*gotsize += actsize;
>  		return 0;
>  getit:
> -		if (get_cluster(mydata, curclust, buffer, (int)actsize) != 0) {
> +		if (get_cluster(mydata, curclust, buffer, actsize) != 0) {
>  			printf("Error reading cluster\n");
>  			return -1;
>  		}

And similar to my last message, this also causes problems on for example
socfpga_sr1500.

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180223/e0ffa98e/attachment.sig>


More information about the U-Boot mailing list