mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] commands: ubiupdatevol: store return value of read() in a signed int
@ 2016-09-05 19:36 Ulrich Ölmann
  2016-09-05 19:36 ` [PATCH 2/2] commands: ubiupdatevol: confirm success with return value 0 Ulrich Ölmann
  2016-09-06 14:21 ` [PATCH 1/2] commands: ubiupdatevol: store return value of read() in a signed int Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Ulrich Ölmann @ 2016-09-05 19:36 UTC (permalink / raw)
  To: Barebox List

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 commands/ubi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/commands/ubi.c b/commands/ubi.c
index 65d2d256a830..dd981f95ea5d 100644
--- a/commands/ubi.c
+++ b/commands/ubi.c
@@ -14,10 +14,9 @@
 
 static int do_ubiupdatevol(int argc, char *argv[])
 {
-	int fd_img, fd_vol, ret = 0;
+	int count, fd_img, fd_vol, ret = 0;
 	uint64_t size = 0;
 	struct stat st;
-	unsigned int count;
 	void *buf;
 
 	if (argc - optind < 2)
-- 
2.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/2] commands: ubiupdatevol: confirm success with return value 0
  2016-09-05 19:36 [PATCH 1/2] commands: ubiupdatevol: store return value of read() in a signed int Ulrich Ölmann
@ 2016-09-05 19:36 ` Ulrich Ölmann
  2016-09-06 14:21 ` [PATCH 1/2] commands: ubiupdatevol: store return value of read() in a signed int Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Ulrich Ölmann @ 2016-09-05 19:36 UTC (permalink / raw)
  To: Barebox List

Treat the write() case analogously to the read() case and do not return the
number of most recently written bytes as the status of sucessful command
execution.

Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
---
 commands/ubi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/commands/ubi.c b/commands/ubi.c
index dd981f95ea5d..26b521f3748e 100644
--- a/commands/ubi.c
+++ b/commands/ubi.c
@@ -65,9 +65,10 @@ static int do_ubiupdatevol(int argc, char *argv[])
 			break;
 		}
 
-		ret = write(fd_vol, buf, count);
-		if (ret < 0) {
+		count = write(fd_vol, buf, count);
+		if (count < 0) {
 			perror("write");
+			ret = 1;
 			break;
 		}
 
-- 
2.8.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] commands: ubiupdatevol: store return value of read() in a signed int
  2016-09-05 19:36 [PATCH 1/2] commands: ubiupdatevol: store return value of read() in a signed int Ulrich Ölmann
  2016-09-05 19:36 ` [PATCH 2/2] commands: ubiupdatevol: confirm success with return value 0 Ulrich Ölmann
@ 2016-09-06 14:21 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2016-09-06 14:21 UTC (permalink / raw)
  To: Ulrich Ölmann; +Cc: Barebox List

Hi Ulrich,

please add to the commit log *why* you did this change. *What* you did
is already clear from the change itself.

Added this while applying:

With an unsigned int test for errors from read() can never become true.

Sascha


On Mon, Sep 05, 2016 at 09:36:17PM +0200, Ulrich Ölmann wrote:
> Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de>
> ---
>  commands/ubi.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/commands/ubi.c b/commands/ubi.c
> index 65d2d256a830..dd981f95ea5d 100644
> --- a/commands/ubi.c
> +++ b/commands/ubi.c
> @@ -14,10 +14,9 @@
>  
>  static int do_ubiupdatevol(int argc, char *argv[])
>  {
> -	int fd_img, fd_vol, ret = 0;
> +	int count, fd_img, fd_vol, ret = 0;
>  	uint64_t size = 0;
>  	struct stat st;
> -	unsigned int count;
>  	void *buf;
>  
>  	if (argc - optind < 2)
> -- 
> 2.8.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2016-09-06 14:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-05 19:36 [PATCH 1/2] commands: ubiupdatevol: store return value of read() in a signed int Ulrich Ölmann
2016-09-05 19:36 ` [PATCH 2/2] commands: ubiupdatevol: confirm success with return value 0 Ulrich Ölmann
2016-09-06 14:21 ` [PATCH 1/2] commands: ubiupdatevol: store return value of read() in a signed int Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox