Re: [PATCH opensm] osmtest/osmtest.c: Close file before exit function osmtest_create_inventory_file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 28, 2018 at 05:57:39AM -0400, Hal Rosenstock wrote:
> 
> If for some reason we get an error when trying to write the inventory
> file, we first need to close the file and then exit the function.
> 
> Signed-off-by: Dan Ben Yosef <danby@xxxxxxxxxxxx>
> Signed-off-by: Alex Netes <alexne@xxxxxxxxxxxx>
> ---
>  osmtest/osmtest.c | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/osmtest/osmtest.c b/osmtest/osmtest.c
> index c8c8e71..79e8af8 100644
> --- a/osmtest/osmtest.c
> +++ b/osmtest/osmtest.c
> @@ -2545,22 +2545,24 @@ osmtest_create_inventory_file(IN osmtest_t * const p_osmt)
>  	/* HACK: the order is important: nodes ports paths */
>  	status = osmtest_write_all_node_recs(p_osmt, fh);
>  	if (status != IB_SUCCESS)
> -		goto Exit;
> +		goto CloseFile;
>  
>  	status = osmtest_write_all_port_recs(p_osmt, fh);
>  	if (status != IB_SUCCESS)
> -		goto Exit;
> +		goto CloseFile;
>  
>  	if (!p_osmt->opt.ignore_path_records) {
>  		status = osmtest_write_all_path_recs(p_osmt, fh);
>  		if (status != IB_SUCCESS)
> -			goto Exit;
> +			goto CloseFile;
>  	}
>  
>  	status = osmtest_write_all_link_recs(p_osmt, fh);
>  	if (status != IB_SUCCESS)
> -		goto Exit;
> +		goto CloseFile;
> +
>  
> +CloseFile:
>  	fclose(fh);
>  
>  Exit:

Acked-by: Honggang Li <honli@xxxxxxxxxx>

thanks
> -- 
> 2.8.4
> 



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux