All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/1] fs: fat: avoid useless conversion when calling getcluster
@ 2018-02-13 18:18 Heinrich Schuchardt
  2018-02-13 21:27 ` Lukasz Majewski
  2018-02-13 21:50 ` Tuomas Tynkkynen
  0 siblings, 2 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-02-13 18:18 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 fs/fat/fat.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/fat/fat.c b/fs/fat/fat.c
index dd7888cd6d4..a3c7bf604eb 100644
--- a/fs/fat/fat.c
+++ b/fs/fat/fat.c
@@ -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) {
+				(unsigned long)actsize) != 0) {
 			printf("Error reading cluster\n");
 			return -1;
 		}
@@ -393,14 +393,16 @@ 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,
+				(unsigned long)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,
+				(unsigned long)actsize) != 0) {
 			printf("Error reading cluster\n");
 			return -1;
 		}
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] fs: fat: avoid useless conversion when calling getcluster
  2018-02-13 18:18 [U-Boot] [PATCH 1/1] fs: fat: avoid useless conversion when calling getcluster Heinrich Schuchardt
@ 2018-02-13 21:27 ` Lukasz Majewski
  2018-02-13 21:50 ` Tuomas Tynkkynen
  1 sibling, 0 replies; 4+ messages in thread
From: Lukasz Majewski @ 2018-02-13 21:27 UTC (permalink / raw)
  To: u-boot

On Tue, 13 Feb 2018 19:18:58 +0100
Heinrich Schuchardt <xypron.glpk@gmx.de> 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.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  fs/fat/fat.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> index dd7888cd6d4..a3c7bf604eb 100644
> --- a/fs/fat/fat.c
> +++ b/fs/fat/fat.c
> @@ -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) {
> +				(unsigned long)actsize) != 0) {
>  			printf("Error reading cluster\n");
>  			return -1;
>  		}
> @@ -393,14 +393,16 @@ 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,
> +				(unsigned long)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,
> +				(unsigned long)actsize) != 0) {
>  			printf("Error reading cluster\n");
>  			return -1;
>  		}

Reviewed-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180213/76aa2778/attachment.sig>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] fs: fat: avoid useless conversion when calling getcluster
  2018-02-13 18:18 [U-Boot] [PATCH 1/1] fs: fat: avoid useless conversion when calling getcluster Heinrich Schuchardt
  2018-02-13 21:27 ` Lukasz Majewski
@ 2018-02-13 21:50 ` Tuomas Tynkkynen
  2018-02-14  7:17   ` Heinrich Schuchardt
  1 sibling, 1 reply; 4+ messages in thread
From: Tuomas Tynkkynen @ 2018-02-13 21:50 UTC (permalink / raw)
  To: u-boot

Hi,

On Tue, 13 Feb 2018 19:18:58 +0100
Heinrich Schuchardt <xypron.glpk@gmx.de> 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.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  fs/fat/fat.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/fat/fat.c b/fs/fat/fat.c
> index dd7888cd6d4..a3c7bf604eb 100644
> --- a/fs/fat/fat.c
> +++ b/fs/fat/fat.c
> @@ -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) {
> +				(unsigned long)actsize) != 0) {
>  			printf("Error reading cluster\n");

If the type is unsigned long, the explicit cast here seems redundant.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [U-Boot] [PATCH 1/1] fs: fat: avoid useless conversion when calling getcluster
  2018-02-13 21:50 ` Tuomas Tynkkynen
@ 2018-02-14  7:17   ` Heinrich Schuchardt
  0 siblings, 0 replies; 4+ messages in thread
From: Heinrich Schuchardt @ 2018-02-14  7:17 UTC (permalink / raw)
  To: u-boot

On 02/13/2018 10:50 PM, Tuomas Tynkkynen wrote:
> Hi,
> 
> On Tue, 13 Feb 2018 19:18:58 +0100
> Heinrich Schuchardt <xypron.glpk@gmx.de> 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.
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
>> ---
>>   fs/fat/fat.c | 8 +++++---
>>   1 file changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/fat/fat.c b/fs/fat/fat.c
>> index dd7888cd6d4..a3c7bf604eb 100644
>> --- a/fs/fat/fat.c
>> +++ b/fs/fat/fat.c
>> @@ -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) {
>> +				(unsigned long)actsize) != 0) {
>>   			printf("Error reading cluster\n");
> 
> If the type is unsigned long, the explicit cast here seems redundant.
> 
actsize is of type l_off_t. As long as loff_t does not have more bits 
than unsigned long you are right. But the C language does not require 
this to hold true.

But why shouldn't we use the same type loff_t in the interface of 
get_cluster. I will update the patch.

Best regards

Heinrich

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-02-14  7:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-13 18:18 [U-Boot] [PATCH 1/1] fs: fat: avoid useless conversion when calling getcluster Heinrich Schuchardt
2018-02-13 21:27 ` Lukasz Majewski
2018-02-13 21:50 ` Tuomas Tynkkynen
2018-02-14  7:17   ` Heinrich Schuchardt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.