summaryrefslogtreecommitdiffstats
path: root/c++/test
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2021-03-22 17:51:18 (GMT)
committerGitHub <noreply@github.com>2021-03-22 17:51:18 (GMT)
commit38b9474af03909d49cc928c71c190e4f26a15b5c (patch)
treeb8eb735f44b4e246816a4daec9714d5c4d89675e /c++/test
parent60e14b826a22452934f7057196c1ce4d0054d97a (diff)
downloadhdf5-38b9474af03909d49cc928c71c190e4f26a15b5c.zip
hdf5-38b9474af03909d49cc928c71c190e4f26a15b5c.tar.gz
hdf5-38b9474af03909d49cc928c71c190e4f26a15b5c.tar.bz2
Applied clang-tidy readability-delete-null-pointer fixes (#430)
delete nullptr is well-defined, does not need check. Manually fixed indentation after automatic changes.
Diffstat (limited to 'c++/test')
-rw-r--r--c++/test/dsets.cpp36
-rw-r--r--c++/test/tcompound.cpp12
-rw-r--r--c++/test/tfile.cpp12
-rw-r--r--c++/test/trefer.cpp9
-rw-r--r--c++/test/ttypes.cpp3
-rw-r--r--c++/test/tvlstr.cpp6
6 files changed, 28 insertions, 50 deletions
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp
index 0faf457..356112e 100644
--- a/c++/test/dsets.cpp
+++ b/c++/test/dsets.cpp
@@ -159,8 +159,7 @@ test_create(H5File &file)
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
// clean up and return with failure
- if (dataset != NULL)
- delete dataset;
+ delete dataset;
return -1;
}
// catch all other exceptions
@@ -168,8 +167,7 @@ test_create(H5File &file)
issue_fail_msg("test_create", __LINE__, __FILE__);
// clean up and return with failure
- if (dataset != NULL)
- delete dataset;
+ delete dataset;
return -1;
}
} // test_create
@@ -249,8 +247,7 @@ test_simple_io(H5File &file)
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
// clean up and return with failure
- if (tconv_buf)
- delete[] tconv_buf;
+ delete[] tconv_buf;
return -1;
}
} // test_simple_io
@@ -692,10 +689,8 @@ test_compression(H5File &file)
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
// clean up and return with failure
- if (dataset != NULL)
- delete dataset;
- if (tconv_buf)
- delete[] tconv_buf;
+ delete dataset;
+ delete[] tconv_buf;
return -1;
}
} // test_compression
@@ -885,8 +880,7 @@ test_multiopen(H5File &file)
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
// clean up and return with failure
- if (space != NULL)
- delete space;
+ delete space;
return -1;
}
} // test_multiopen
@@ -964,8 +958,7 @@ test_types(H5File &file)
cerr << " <<< "
<< "bitfield_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl
<< endl;
- if (dset != NULL)
- delete dset;
+ delete dset;
return -1;
}
@@ -996,8 +989,7 @@ test_types(H5File &file)
cerr << " <<< "
<< "bitfield_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl
<< endl;
- if (dset != NULL)
- delete dset;
+ delete dset;
throw E; // propagate the exception
}
@@ -1031,10 +1023,8 @@ test_types(H5File &file)
cerr << " <<< "
<< "opaque_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl
<< endl;
- if (dset != NULL)
- delete dset;
- if (optype != NULL)
- delete optype;
+ delete dset;
+ delete optype;
throw E; // propagate the exception
}
@@ -1067,10 +1057,8 @@ test_types(H5File &file)
cerr << " <<< "
<< "opaque_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl
<< endl;
- if (dset != NULL)
- delete dset;
- if (optype != NULL)
- delete optype;
+ delete dset;
+ delete optype;
throw E; // propagate the exception
}
diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp
index 82c21e8..2170a9d 100644
--- a/c++/test/tcompound.cpp
+++ b/c++/test/tcompound.cpp
@@ -176,8 +176,7 @@ test_compound_2()
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
- if (array_dt)
- delete array_dt;
+ delete array_dt;
} // test_compound_2()
/*-------------------------------------------------------------------------
@@ -287,8 +286,7 @@ test_compound_3()
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
- if (array_dt)
- delete array_dt;
+ delete array_dt;
} // test_compound_3()
/*-------------------------------------------------------------------------
@@ -407,8 +405,7 @@ test_compound_4()
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
- if (array_dt)
- delete array_dt;
+ delete array_dt;
} // test_compound_4()
/*-------------------------------------------------------------------------
@@ -504,8 +501,7 @@ test_compound_5()
issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());
}
- if (array_dt)
- delete array_dt;
+ delete array_dt;
} // test_compound_5()
/*-------------------------------------------------------------------------
diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp
index 5e4e91b..255fc30 100644
--- a/c++/test/tfile.cpp
+++ b/c++/test/tfile.cpp
@@ -175,14 +175,14 @@ test_file_create()
catch (InvalidActionException &E) {
cerr << " *FAILED*" << endl;
cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl;
- if (file1 != NULL) // clean up
- delete file1;
+ // clean up
+ delete file1;
}
// catch all other exceptions
catch (Exception &E) {
issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg());
- if (file1 != NULL) // clean up
- delete file1;
+ // clean up
+ delete file1;
}
// Setting this to NULL for cleaning up in failure situations
@@ -260,8 +260,8 @@ test_file_create()
// catch all exceptions
catch (Exception &E) {
issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg());
- if (tmpl1 != NULL) // clean up
- delete tmpl1;
+ // clean up
+ delete tmpl1;
}
} // test_file_create()
diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp
index 939b0ee..604ccc0 100644
--- a/c++/test/trefer.cpp
+++ b/c++/test/trefer.cpp
@@ -179,8 +179,7 @@ test_reference_params()
issue_fail_msg("test_reference_param()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg());
}
- if (file1)
- delete file1;
+ delete file1;
} /* test_reference_param() */
/*-------------------------------------------------------------------------
@@ -374,8 +373,7 @@ test_reference_obj()
issue_fail_msg("test_reference_obj()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg());
}
- if (file1)
- delete file1;
+ delete file1;
} // test_reference_obj()
/*-------------------------------------------------------------------------
@@ -518,8 +516,7 @@ test_reference_group()
issue_fail_msg("test_reference_group()", __LINE__, __FILE__, E.getCFuncName(), E.getCDetailMsg());
}
- if (file1)
- delete file1;
+ delete file1;
} /* test_reference_group() */
/*-------------------------------------------------------------------------
diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp
index 5fc82a5..b633740 100644
--- a/c++/test/ttypes.cpp
+++ b/c++/test/ttypes.cpp
@@ -802,8 +802,7 @@ test_named()
issue_fail_msg("test_named", __LINE__, __FILE__, E.getCDetailMsg());
}
- if (ds_type)
- delete ds_type;
+ delete ds_type;
} // test_named
/*-------------------------------------------------------------------------
diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp
index b371518..9c0f78a 100644
--- a/c++/test/tvlstr.cpp
+++ b/c++/test/tvlstr.cpp
@@ -313,8 +313,7 @@ test_vlstring_array_dataset()
issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg());
}
- if (file1)
- delete file1;
+ delete file1;
} // end test_vlstring_array_dataset()
/*-------------------------------------------------------------------------
@@ -527,8 +526,7 @@ test_vlstring_type()
issue_fail_msg("test_vlstring_type()", __LINE__, __FILE__, E.getCDetailMsg());
}
- if (file1)
- delete file1;
+ delete file1;
} // end test_vlstring_type()
/*-------------------------------------------------------------------------