tools: imx8image: return SUCCESS when the required files not found
PATCH 1/1 tools: imx8image: return SUCCESS when the required files not found
When the required files to build a bootable imx8 image are not found, return EXIT_SUCCESS to avoid build CI system.
And if the files are missing, give a error message during the build.
--- tools/imx8image.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
tools/imx8image.c +8 -8
@@ -279,9 +279,9 @@ static void check_file(struct stat *sbuf, char *filename)int tmp_fd =open (filename,O_RDONLY |O_BINARY );if (tmp_fd <0 ) { -fprintf (stderr,"%s: Can't open: %s\n" , +fprintf (stderr,"*** %s: Can't open: %s ***\n" , filename,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }if (fstat (tmp_fd, sbuf) <0 ) {
@@ -311,9 +311,9 @@ static void copy_file_aligned(int ifd, const char *datafile, int offset, dfd =open (datafile,O_RDONLY |O_BINARY );if (dfd <0 ) { -fprintf (stderr,"Can't open %s: %s\n" , +fprintf (stderr,"*** Can't open %s: %s ***\n" , datafile,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }if (fstat (dfd, &sbuf) <0 ) {
@@ -365,9 +365,9 @@ static void copy_file (int ifd, const char *datafile, int pad, int offset) dfd =open (datafile,O_RDONLY |O_BINARY );if (dfd <0 ) { -fprintf (stderr,"Can't open %s: %s\n" , +fprintf (stderr,"*** Can't open %s: %s ***\n" , datafile,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }if (fstat (dfd, &sbuf) <0 ) {
@@ -648,8 +648,8 @@ static int get_container_image_start_pos(image_t *image_stack, uint32_t align)if (img_sp->option ==APPEND ) { fd =fopen (img_sp->filename,"r" );if (!fd) { -fprintf (stderr,"Fail open first container file %s\n" , img_sp->filename); -exit (EXIT_FAILURE ); +fprintf (stderr,"*** Fail open first container file %s ***\n" , img_sp->filename); +exit (EXIT_SUCCESS ); } ret =fread (&header,sizeof (header),1 , fd);
Signature · 1 line
2.14.1
PATCH 1/1 tools: imx8image: return SUCCESS when the required files not found
Hi Peng,
Quoted 4 lines · Peng Fan
When the required files to build a bootable imx8 image are not found, return
EXIT_SUCCESSto avoid build CI system.
And if the files are missing, give a error message during the build.
Thanks for this - anyway, I am thinking about if this is the correct solution. IMHO the current implementation in mkimage *is* already correct. Files are missing, mkimage cannot be completed with success, we do not get an image suitable for booting - an error is raised. What else ? There is nothing wrong on this :-).
However, we have to make CI happy - but mkimage could be called even outside a U-Boot build, and should be scriptable, that is it must report an error in case of failure. This is already provided.
Instead of changing mkimage, I thought to not call mkimage at all. We could add a test in arch/arm/mach-imx/Makefile to check if files for imx8 are available, and if not, we print warnings and Makefile returns with success. CI / Travis should be happy again without introducing a buggy behavior into mkimage. What do you think ?
Best regards,
Stefano
Quoted 57 lines
Signed-off-by Peng Fan <[email protected]>--- tools/imx8image.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)tools/imx8image.c +8
-8@@ -279,9 +279,9 @@ static void check_file(struct stat *sbuf, char *filename)int tmp_fd =open (filename,O_RDONLY |O_BINARY );if (tmp_fd <0 ) { -fprintf (stderr,"%s: Can't open: %s\n" , +fprintf (stderr,"*** %s: Can't open: %s ***\n" , filename,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }if (fstat (tmp_fd, sbuf) <0 ) {@@ -311,9 +311,9 @@ static void copy_file_aligned(int ifd, const char *datafile, int offset, dfd =open (datafile,O_RDONLY |O_BINARY );if (dfd <0 ) { -fprintf (stderr,"Can't open %s: %s\n" , +fprintf (stderr,"*** Can't open %s: %s ***\n" , datafile,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }if (fstat (dfd, &sbuf) <0 ) {@@ -365,9 +365,9 @@ static void copy_file (int ifd, const char *datafile, int pad, int offset) dfd =open (datafile,O_RDONLY |O_BINARY );if (dfd <0 ) { -fprintf (stderr,"Can't open %s: %s\n" , +fprintf (stderr,"*** Can't open %s: %s ***\n" , datafile,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }if (fstat (dfd, &sbuf) <0 ) {@@ -648,8 +648,8 @@ static int get_container_image_start_pos(image_t *image_stack, uint32_t align)if (img_sp->option ==APPEND ) { fd =fopen (img_sp->filename,"r" );if (!fd) { -fprintf (stderr,"Fail open first container file %s\n" , img_sp->filename); -exit (EXIT_FAILURE ); +fprintf (stderr,"*** Fail open first container file %s ***\n" , img_sp->filename); +exit (EXIT_SUCCESS ); } ret =fread (&header,sizeof (header),1 , fd);
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH 1/1 tools: imx8image: return SUCCESS when the required files not found
Hi Stefano,
Quoted 25 lines
-----Original Message-----
From: Stefano Babic [mailto:sbabic at denx.de]
Sent: 2018年10月24日 15:31
To: Peng Fan <[email protected]>; sbabic at denx.de
Cc: u-boot at lists.denx.de
Subject: Re: [PATCH] tools: imx8image: return SUCCESS when the required files not foundHi Peng,
Quoted 4 lines · Peng Fan
When the required files to build a bootable imx8 image are not found, return
EXIT_SUCCESSto avoid build CI system.
And if the files are missing, give a error message during the build.Thanks for this - anyway, I am thinking about if this is the correct solution. IMHO the current implementation in mkimage *is* already correct. Files are missing, mkimage cannot be completed with success, we do not get an image suitable for booting - an error is raised. What else ? There is nothing wrong on this :-).
However, we have to make CI happy - but mkimage could be called even outside a U-Boot build, and should be scriptable, that is it must report an error in case of failure. This is already provided.
Quoted 5 lines
Instead of changing mkimage, I thought to not call mkimage at all. We could add a test in
arch/arm/mach-imx/Makefileto check if files for
imx8 are available, and if not, we print warnings andMakefilereturns with success. CI / Travis should be happy again without introducing a buggy behavior into mkimage. What do you think ?
Just send out a new patch, please check whether it is ok.
I also kicked a CI build, still running, https://travis-ci.org/MrVan/u-boot/builds
Thanks,
Peng.
Quoted 77 lines
Best regards,
Stefanotools/imx8image.c static void check_file(struct stat *sbuf, char
Quoted 10 lines
Signed-off-by Peng Fan <[email protected]>--- tools/imx8image.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)tools/imx8image.c index renamed from tools/imx8image.c +0
-0
e6b0a146b6..35409646f5100644tools/imx8image.c +0
-0@@ -279,9 +279,9 @@ static void check_file(struct stat *sbuf, char*filename)
tools/imx8image.c static int get_container_image_start_pos(image_t
Quoted 38 lines
tools/imx8image.c +4
-4int tmp_fd =open (filename,O_RDONLY |O_BINARY );if (tmp_fd <0 ) { -fprintf (stderr,"%s: Can't open: %s\n" , +fprintf (stderr,"*** %s: Can't open: %s ***\n" , filename,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }if (fstat (tmp_fd, sbuf) <0 ) {@@ -311,9 +311,9 @@ static void copy_file_aligned(int ifd, const char *datafile, int offset, dfd =open (datafile,O_RDONLY |O_BINARY );if (dfd <0 ) { -fprintf (stderr,"Can't open %s: %s\n" , +fprintf (stderr,"*** Can't open %s: %s ***\n" , datafile,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }tools/imx8image.c +2
-2if (fstat (dfd, &sbuf) <0 ) {@@ -365,9 +365,9 @@ static void copy_file (int ifd, const char *datafile, int pad, int offset) dfd =open (datafile,O_RDONLY |O_BINARY );if (dfd <0 ) { -fprintf (stderr,"Can't open %s: %s\n" , +fprintf (stderr,"*** Can't open %s: %s ***\n" , datafile,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }tools/imx8image.c +0
-0if (fstat (dfd, &sbuf) <0 ) {@@ -648,8 +648,8 @@ static int get_container_image_start_pos(image_t
*image_stack,uint32_talign)tools/imx8image.c static int get_container_image_start_pos(image_t *image_stack, uint32_t align)
Quoted 4 lines
tools/imx8image.c +0
-1if (img_sp->option ==APPEND ) { fd =fopen (img_sp->filename,"r" );if (!fd) { - fprintf(stderr, "Fail open first container file %s\n",
img_sp->filename);tools/imx8image.c static int get_container_image_start_pos(image_t · line 651
Quoted 2 lines
tools/imx8image.c +1
-1-exit (EXIT_FAILURE ); + fprintf(stderr, "*** Fail open first container file %s ***\n",
img_sp->filename);tools/imx8image.c static int get_container_image_start_pos(image_t *image_stack, uint32_t align) · line 655
Quoted 5 lines
tools/imx8image.c +1
-0+exit (EXIT_SUCCESS ); } ret =fread (&header,sizeof (header),1 , fd);--
================================================================
=====
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
================================================================
=====
PATCH 1/1 tools: imx8image: return SUCCESS when the required files not found
Hi Peng,
Quoted 27 lines · Peng Fan
Hi Stefano,
Quoted 25 lines
-----Original Message-----
From: Stefano Babic [mailto:sbabic at denx.de]
Sent: 2018年10月24日 15:31
To: Peng Fan <[email protected]>; sbabic at denx.de
Cc: u-boot at lists.denx.de
Subject: Re: [PATCH] tools: imx8image: return SUCCESS when the required files not foundHi Peng,
Quoted 4 lines · Peng Fan
When the required files to build a bootable imx8 image are not found, return
EXIT_SUCCESSto avoid build CI system.
And if the files are missing, give a error message during the build.Thanks for this - anyway, I am thinking about if this is the correct solution. IMHO the current implementation in mkimage *is* already correct. Files are missing, mkimage cannot be completed with success, we do not get an image suitable for booting - an error is raised. What else ? There is nothing wrong on this :-).
However, we have to make CI happy - but mkimage could be called even outside a U-Boot build, and should be scriptable, that is it must report an error in case of failure. This is already provided.
Quoted 7 lines
Quoted 5 lines
Instead of changing mkimage, I thought to not call mkimage at all. We could add a test in
arch/arm/mach-imx/Makefileto check if files for
imx8 are available, and if not, we print warnings andMakefilereturns with success. CI / Travis should be happy again without introducing a buggy behavior into mkimage. What do you think ?Just send out a new patch, please check whether it is ok.
Thanks - it is what I mind ;-)
Quoted 1 line
I also kicked a CI build, still running, https://travis-ci.org/MrVan/u-boot/builds
Well, easy for me :-) I just wait your build is over, and then I merge and send a new PR to Tom !
Best regards,
Stefano
Quoted 81 lines
Thanks,
Peng.Quoted 77 lines
Best regards,
Stefanotools/imx8image.c static void check_file(struct stat *sbuf, char
Quoted 10 lines
Signed-off-by Peng Fan <[email protected]>--- tools/imx8image.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)tools/imx8image.c index renamed from tools/imx8image.c +0
-0
e6b0a146b6..35409646f5100644tools/imx8image.c +0
-0@@ -279,9 +279,9 @@ static void check_file(struct stat *sbuf, char*filename)
tools/imx8image.c static int get_container_image_start_pos(image_t
Quoted 38 lines
tools/imx8image.c +4
-4int tmp_fd =open (filename,O_RDONLY |O_BINARY );if (tmp_fd <0 ) { -fprintf (stderr,"%s: Can't open: %s\n" , +fprintf (stderr,"*** %s: Can't open: %s ***\n" , filename,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }if (fstat (tmp_fd, sbuf) <0 ) {@@ -311,9 +311,9 @@ static void copy_file_aligned(int ifd, const char *datafile, int offset, dfd =open (datafile,O_RDONLY |O_BINARY );if (dfd <0 ) { -fprintf (stderr,"Can't open %s: %s\n" , +fprintf (stderr,"*** Can't open %s: %s ***\n" , datafile,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }tools/imx8image.c +2
-2if (fstat (dfd, &sbuf) <0 ) {@@ -365,9 +365,9 @@ static void copy_file (int ifd, const char *datafile, int pad, int offset) dfd =open (datafile,O_RDONLY |O_BINARY );if (dfd <0 ) { -fprintf (stderr,"Can't open %s: %s\n" , +fprintf (stderr,"*** Can't open %s: %s ***\n" , datafile,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS ); }tools/imx8image.c +0
-0if (fstat (dfd, &sbuf) <0 ) {@@ -648,8 +648,8 @@ static int get_container_image_start_pos(image_t
*image_stack,uint32_talign)tools/imx8image.c static int get_container_image_start_pos(image_t *image_stack, uint32_t align)
Quoted 4 lines
tools/imx8image.c +0
-1if (img_sp->option ==APPEND ) { fd =fopen (img_sp->filename,"r" );if (!fd) { - fprintf(stderr, "Fail open first container file %s\n",
img_sp->filename);tools/imx8image.c static int get_container_image_start_pos(image_t · line 651
Quoted 2 lines
tools/imx8image.c +1
-1-exit (EXIT_FAILURE ); + fprintf(stderr, "*** Fail open first container file %s ***\n",
img_sp->filename);tools/imx8image.c static int get_container_image_start_pos(image_t *image_stack, uint32_t align) · line 655
Quoted 5 lines
tools/imx8image.c +1
-0+exit (EXIT_SUCCESS ); } ret =fread (&header,sizeof (header),1 , fd);--
================================================================
=====
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
================================================================
=====
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH 1/1 tools: imx8image: return SUCCESS when the required files not found
In reply to Peng FanDear Peng Fan,
Quoted 3 lines · In message <[email protected]> you wrote:
When the required files to build a bootable imx8 image are not found, return
EXIT_SUCCESSto avoid build CI system.
And if the files are missing, give a error message during the build.
Full NAK.
tools/imx8image.c static void check_file(struct stat *sbuf, char *filename) · line 284
Quoted 6 lines
tools/imx8image.c +2
-2if (tmp_fd <0 ) { -fprintf (stderr,"%s: Can't open: %s\n" , +fprintf (stderr,"*** %s: Can't open: %s ***\n" , filename,strerror (errno)); -exit (EXIT_FAILURE ); +exit (EXIT_SUCCESS );
An error like this must ALWAYS be reported by a proper return / exit code o fthe funtion / program, other wise it is impossible to use such tools in any automatic scripts, pipelines etc.
Anything else is just fundamentally broken. I am shocked to see such a patch.
Wolfgang Denk
Signature · 6 lines
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
It is common sense to take a method and try it. If it fails, admit it
frankly and try another. But above all, try something.
- Franklin D. Roosevelt