fs: fat: avoid useless conversion when calling getcluster
PATCH 1/1 fs: fat: avoid useless conversion when calling getcluster
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.
--- fs/fat/fat.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
fs/fat/fat.c +5 -3
@@ -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 ; }
Signature · 1 line
2.14.2
PATCH 1/1 fs: fat: avoid useless conversion when calling getcluster
Quoted 42 lines · On Tue, 13 Feb 2018 19:18:58 +0100 Heinrich Schuchardt <[email protected]>…
Parameter size of function
get_cluster()is of type unsigned long. It makes no sense to convert actsize to int before passing it toget_clusteras size.Signed-off-by Heinrich Schuchardt <[email protected]>--- fs/fat/fat.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)fs/fat/fat.c +1
-1@@ -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 ;fs/fat/fat.c +4
-2}@@ -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" );
fs/fat/fat.c
Quoted 2 lines
fs/fat/fat.c +0
-0return -1 ; }
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>
PATCH 1/1 fs: fat: avoid useless conversion when calling getcluster
In reply to Heinrich SchuchardtHi,
Quoted 14 lines · On Tue, 13 Feb 2018 19:18:58 +0100 Heinrich Schuchardt <[email protected]>…
Parameter size of function
get_cluster()is of type unsigned long. It makes no sense to convert actsize to int before passing it toget_clusteras size.Signed-off-by Heinrich Schuchardt <[email protected]>--- fs/fat/fat.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)fs/fat/fat.c +0
-0
fs/fat/fat.c static int get_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, · line 357
Quoted 6 lines
fs/fat/fat.c +1
-1@@ -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.
PATCH 1/1 fs: fat: avoid useless conversion when calling getcluster
Quoted 14 lines · Tuomas Tynkkynen
Hi,
Quoted 9 lines · On Tue, 13 Feb 2018 19:18:58 +0100 Heinrich Schuchardt <[email protected]>…
Parameter size of function
get_cluster()is of type unsigned long. It makes no sense to convert actsize to int before passing it toget_clusteras size.Signed-off-by Heinrich Schuchardt <[email protected]>--- fs/fat/fat.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Quoted 14 lines
fs/fat/fat.c static int get_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, · line 357
Quoted 11 lines
fs/fat/fat.c +1
-1@@ -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