read_file: Pass NULL for the size parameter if the return value is not used
Subsystems (3)
PATCH 1/1 read_file: Pass NULL for the size parameter if the return value is not used
Signed-off-by Alexander Shiyan <[email protected]>
--- arch/arm/boards/kindle-mx50/board.c | 3 +-- arch/arm/boards/vscom-baltos/board.c | 3 +-- arch/arm/mach-omap/xload.c | 14 +++++--------- commands/spd_decode.c | 3 +-- common/menutree.c | 3 +-- lib/libfile.c | 3 +-- 6 files changed, 10 insertions(+), 19 deletions(-)
arch/arm/boards/kindle-mx50/board.c +1 -2
@@ -84,10 +84,9 @@ static char *mac;static void kindle_rev_init (void ) {int ret; -size_t size;void *buf;const char userdata[] ="/dev/mmc2.boot0.userdata" ; - ret =read_file_2 (userdata, &size, &buf,128 ); + ret =read_file_2 (userdata,NULL , &buf,128 );if (ret && ret != -EFBIG ) {pr_err ("Could not read board info from %s\n" , userdata);return ;
arch/arm/boards/vscom-baltos/board.c +1 -2
@@ -85,7 +85,6 @@ static uint8_t get_dip_switch(uint16_t id, uint32_t rev)static int baltos_read_eeprom (void ) {struct bsp_vs_hwparam hw_param; -size_t size;char *buf, var_buf[32 ];int rc;unsigned char mac_addr[6 ];
@@ -95,7 +94,7 @@ static int baltos_read_eeprom(void)return 0 ; rc =read_file_2 ("/dev/eeprom0" , - &size, +NULL , (void *)&buf,sizeof (hw_param));if (rc && rc != -EFBIG )
arch/arm/mach-omap/xload.c +5 -9
@@ -115,7 +115,6 @@ static void *omap_xload_boot_mmc(void) {int ret;void *buf; -int len;const char *diskdev;char *partname;
@@ -137,9 +136,9 @@ static void *omap_xload_boot_mmc(void)free (partname); - buf =read_file ("/barebox.bin" , &len); + buf =read_file ("/barebox.bin" ,NULL );if (!buf) - buf =read_file ("/boot/barebox.bin" , &len); + buf =read_file ("/boot/barebox.bin" ,NULL );if (!buf) {printf ("could not read barebox.bin from sd card\n" );return NULL ;
@@ -156,7 +155,6 @@ static void *omap_xload_boot_spi(struct omap_barebox_part *part)static void *omap4_xload_boot_usb (void ){int ret;void *buf; -int len; ret =mount ("omap4_usbboot" ,"omap4_usbbootfs" ,"/" ,NULL );if (ret) {
@@ -164,7 +162,7 @@ static void *omap4_xload_boot_usb(void){return NULL ; } - buf =read_file ("/barebox.bin" , &len); + buf =read_file ("/barebox.bin" ,NULL );if (!buf)printf ("could not read barebox.bin from omap4_usbbootfs\n" );
@@ -175,7 +173,6 @@ static void *omap_serial_boot(void){struct console_device *cdev;int ret;void *buf; -int len;int fd;/* need temporary place to store file */
@@ -203,7 +200,7 @@ static void *omap_serial_boot(void){return NULL ; } - buf =read_file ("/barebox.bin" , &len); + buf =read_file ("/barebox.bin" ,NULL );if (!buf)printf ("could not read barebox.bin from serial\n" );
@@ -216,7 +213,6 @@ static void *am33xx_net_boot(void) {void *buf =NULL ;int err; -int len;struct dhcp_req_param dhcp_param;const char *bootfile;IPaddr_t ip;
@@ -276,7 +272,7 @@ static void *am33xx_net_boot(void) file =basprintf ("%s/%s" ,TFTP_MOUNT , bootfile); - buf =read_file (file, &len); + buf =read_file (file,NULL );if (!buf)printf ("could not read %s.\n" , bootfile);
commands/spd_decode.c +1 -2
@@ -16,13 +16,12 @@static int do_spd_decode (int argc,char *argv[]) {int ret; -size_t size;void *data;if (argc !=2 )return COMMAND_ERROR_USAGE ; - ret =read_file_2 (argv[1 ], &size, &data,256 ); + ret =read_file_2 (argv[1 ],NULL , &data,256 );if (ret && ret != -EFBIG ) {printf ("unable to read %s: %s\n" , argv[1 ],strerror (-ret));return COMMAND_ERROR ;
common/menutree.c +1 -2
@@ -87,7 +87,6 @@ int menutree(const char *path, int toplevel)glob_t g = {};int i;char *globpath, *display; -size_t size; menu =menu_alloc ();
@@ -100,7 +99,7 @@ int menutree(const char *path, int toplevel) } globpath =basprintf ("%s/title" , path); - display =read_file (globpath, &size); + display =read_file (globpath,NULL );free (globpath);if (!display) {eprintf ("no title found in %s/title\n" , path);
lib/libfile.c +1 -2
@@ -162,7 +162,6 @@ char *read_file_line(const char *fmt, ...)va_list args;char *filename;char *buf, *line =NULL ; -size_t size;int ret;struct stat s;
@@ -177,7 +176,7 @@ char *read_file_line(const char *fmt, ...)if (s.st_size >1024 ) goto out; - buf =read_file (filename, &size); + buf =read_file (filename,NULL );if (!buf) goto out;
Signature · 7 lines
2.32.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 9 lines · Alexander Shiyan
Signed-off-by Alexander Shiyan <[email protected]>--- arch/arm/boards/kindle-mx50/board.c | 3 +-- arch/arm/boards/vscom-baltos/board.c | 3 +-- arch/arm/mach-omap/xload.c | 14 +++++--------- commands/spd_decode.c | 3 +-- common/menutree.c | 3 +-- lib/libfile.c | 3 +-- 6 files changed, 10 insertions(+), 19 deletions(-)
Applied, thanks
Sascha
Quoted 183 lines
arch/arm/boards/kindle-mx50/board.c +1
-2@@ -84,10 +84,9 @@ static char *mac;static void kindle_rev_init (void ) {int ret; -size_t size;void *buf;const char userdata[] ="/dev/mmc2.boot0.userdata" ; - ret =read_file_2 (userdata, &size, &buf,128 ); + ret =read_file_2 (userdata,NULL , &buf,128 );if (ret && ret != -EFBIG ) {pr_err ("Could not read board info from %s\n" , userdata);return ;arch/arm/boards/vscom-baltos/board.c +1
-2@@ -85,7 +85,6 @@ static uint8_t get_dip_switch(uint16_t id, uint32_t rev)static int baltos_read_eeprom (void ) {struct bsp_vs_hwparam hw_param; -size_t size;char *buf, var_buf[32 ];int rc;unsigned char mac_addr[6 ];@@ -95,7 +94,7 @@ static int baltos_read_eeprom(void)return 0 ; rc =read_file_2 ("/dev/eeprom0" , - &size, +NULL , (void *)&buf,sizeof (hw_param));if (rc && rc != -EFBIG )arch/arm/mach-omap/xload.c +5
-9@@ -115,7 +115,6 @@ static void *omap_xload_boot_mmc(void) {int ret;void *buf; -int len;const char *diskdev;char *partname;@@ -137,9 +136,9 @@ static void *omap_xload_boot_mmc(void)free (partname); - buf =read_file ("/barebox.bin" , &len); + buf =read_file ("/barebox.bin" ,NULL );if (!buf) - buf =read_file ("/boot/barebox.bin" , &len); + buf =read_file ("/boot/barebox.bin" ,NULL );if (!buf) {printf ("could not read barebox.bin from sd card\n" );return NULL ;@@ -156,7 +155,6 @@ static void *omap_xload_boot_spi(struct omap_barebox_part *part)static void *omap4_xload_boot_usb (void ){int ret;void *buf; -int len; ret =mount ("omap4_usbboot" ,"omap4_usbbootfs" ,"/" ,NULL );if (ret) {@@ -164,7 +162,7 @@ static void *omap4_xload_boot_usb(void){return NULL ; } - buf =read_file ("/barebox.bin" , &len); + buf =read_file ("/barebox.bin" ,NULL );if (!buf)printf ("could not read barebox.bin from omap4_usbbootfs\n" );@@ -175,7 +173,6 @@ static void *omap_serial_boot(void){struct console_device *cdev;int ret;void *buf; -int len;int fd;/* need temporary place to store file */ @@ -203,7 +200,7 @@ static void *omap_serial_boot(void){return NULL ; } - buf =read_file ("/barebox.bin" , &len); + buf =read_file ("/barebox.bin" ,NULL );if (!buf)printf ("could not read barebox.bin from serial\n" );@@ -216,7 +213,6 @@ static void *am33xx_net_boot(void) {void *buf =NULL ;int err; -int len;struct dhcp_req_param dhcp_param;const char *bootfile;IPaddr_t ip;@@ -276,7 +272,7 @@ static void *am33xx_net_boot(void) file =basprintf ("%s/%s" ,TFTP_MOUNT , bootfile); - buf =read_file (file, &len); + buf =read_file (file,NULL );if (!buf)printf ("could not read %s.\n" , bootfile);commands/spd_decode.c +1
-2@@ -16,13 +16,12 @@static int do_spd_decode (int argc,char *argv[]) {int ret; -size_t size;void *data;if (argc !=2 )return COMMAND_ERROR_USAGE ; - ret =read_file_2 (argv[1 ], &size, &data,256 ); + ret =read_file_2 (argv[1 ],NULL , &data,256 );if (ret && ret != -EFBIG ) {printf ("unable to read %s: %s\n" , argv[1 ],strerror (-ret));return COMMAND_ERROR ;common/menutree.c +1
-2@@ -87,7 +87,6 @@ int menutree(const char *path, int toplevel)glob_t g = {};int i;char *globpath, *display; -size_t size; menu =menu_alloc ();@@ -100,7 +99,7 @@ int menutree(const char *path, int toplevel) } globpath =basprintf ("%s/title" , path); - display =read_file (globpath, &size); + display =read_file (globpath,NULL );free (globpath);if (!display) {eprintf ("no title found in %s/title\n" , path);lib/libfile.c +1
-2@@ -162,7 +162,6 @@ char *read_file_line(const char *fmt, ...)va_list args;char *filename;char *buf, *line =NULL ; -size_t size;int ret;struct stat s;@@ -177,7 +176,7 @@ char *read_file_line(const char *fmt, ...)if (s.st_size >1024 ) goto out; - buf =read_file (filename, &size); + buf =read_file (filename,NULL );if (!buf) goto out;Signature · 7 lines
2.32.0 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox