fs: fat: avoid useless conversion when calling get_cluster
PATCH v2 1/1 fs: fat: avoid useless conversion when calling get_cluster
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.
---
v2
change type of parameter size
--- fs/fat/fat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/fat/fat.c +4 -4
@@ -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 ; }
Signature · 1 line
2.11.0
PATCH v2 1/1 fs: fat: avoid useless conversion when calling get_cluster
Quoted 41 lines · Heinrich Schuchardt
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. Let't uset_offas type of parameter to avoid any type conversion.Signed-off-by Heinrich Schuchardt <[email protected]>---
v2
change type of parameter size--- fs/fat/fat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)fs/fat/fat.c +3
-3@@ -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" );
fs/fat/fat.c static int get_contents(fsdata *mydata, dir_entry *dentptr, loff_t pos, · line 406
Quoted 10 lines
fs/fat/fat.c +1
-1return -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.
Signature · 8 lines
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>