[PATCH] Verify sending of completion packet

Stefan Schmidt stefan at datenfreihafen.org
Mon Nov 8 12:21:05 CET 2010


Hello.

On Sun, 2010-11-07 at 18:51, Tormod Volden wrote:
> From: Tormod Volden <debian.tormod at gmail.com>
> 
> If the completion packet is not received properly it is not
> sure anything will be written.
> 
> Return the total number of bytes written.
> 
> Remove a stray perror.
> 
> Remove a trailing newline.

Same comment on the commit message as in your other patches.

> More patches for dfu-util. I hope they do not drown in Russion spam :)

CC'ing me might be faster but I'm reading openmoko-devel from time to time and
should hopefully not miss patches here. :)

> diff --git a/src/sam7dfu.c b/src/sam7dfu.c
> index d839952..177ba7b 100644
> --- a/src/sam7dfu.c
> +++ b/src/sam7dfu.c
> @@ -104,7 +104,6 @@ int sam7dfu_do_dnload(struct usb_dev_handle *usb_handle, int interface,
>  	if (ret < 0) {
>  		perror(fname);
>  		goto out_close;
> -		perror(fname);

Good spot. Spliting this out in a sperate fix patch might be a good idea. No
string feelings though.

>  	}
>  
>  	if (st.st_size <= 0 /* + DFU_HDR */) {
> @@ -164,8 +163,10 @@ int sam7dfu_do_dnload(struct usb_dev_handle *usb_handle, int interface,
>  
>  	/* send one zero sized download request to signalize end */
>  	ret = dfu_download(usb_handle, interface, 0, NULL);
> -	if (ret >= 0)
> -		ret = bytes_sent;
> +	if (ret < 0) {
> +			fprintf(stderr, "Error sending completion packet\n");
> +			goto out_close;
> +	}
>  
>  	printf("] finished!\n");
>  	fflush(stdout);
> @@ -206,7 +207,7 @@ out_close:
>  out_free:
>  	free(buf);
>  
> -	return ret;
> +	return bytes_sent;
>  }
>  
>  void sam7dfu_init()
> @@ -215,4 +216,3 @@ void sam7dfu_init()
>      dfu_init( 5000 );
>  }

Looks ok to me and my testing did not show any problems.

regards
Stefan Schmidt



More information about the devel mailing list