Message ID | 3221fd97-731a-6e40-a9c1-f58d97c48b5b@dev.mellanox.co.il (mailing list archive) |
---|---|
State | Not Applicable |
Delegated to: | Hal Rosenstock |
Headers | show |
Series | [opensm] osmtest/osmtest.c: Close file before exit function osmtest_create_inventory_file | expand |
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@mellanox.com> > Signed-off-by: Alex Netes <alexne@mellanox.com> > --- > 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@redhat.com> thanks > -- > 2.8.4 >
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: