]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use modernize-use-nullptr 7601/head
authorDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 14 Jan 2019 14:57:02 +0000 (15:57 +0100)
committerDaniel Arndt <daniel.arndt@iwr.uni-heidelberg.de>
Mon, 14 Jan 2019 23:18:38 +0000 (00:18 +0100)
15 files changed:
contrib/utilities/run_clang_tidy.sh
include/deal.II/base/hdf5.h
include/deal.II/fe/fe_tools.templates.h
include/deal.II/matrix_free/fe_evaluation.h
include/deal.II/particles/particle.h
include/deal.II/particles/particle_accessor.h
source/base/data_out_base.cc
source/base/exceptions.cc
source/base/hdf5.cc
source/base/multithread_info.cc
source/base/subscriptor.cc
source/fe/fe_enriched.cc
source/fe/fe_nedelec_sz.cc
source/lac/petsc_matrix_base.cc
source/lac/trilinos_vector.cc

index ebf6f8e5f2babbe735550fc5c90855f3122a1d2c..4cfeb0c5cd32eedf336247d92295e46dd6a83432 100755 (executable)
@@ -49,8 +49,9 @@ ARGS="-D DEAL_II_WITH_MUPARSER=OFF -D DEAL_II_WITH_MPI=ON -D CMAKE_EXPORT_COMPIL
 CHECKS="-*,
         cppcoreguidelines-pro-type-static-cast-downcast,
         google-readability-casting,
-        modernize-use-emplace,
         modernize-deprecated-headers,
+        modernize-use-emplace,
+        modernize-use-nullptr,
         modernize-use-using,
         mpi-*,
         performance-*,
index a036daa425282bc51c18d2adb5b4e9469ba28019..292640535d1e723d0c2591f035dbdc63cd4eaf66 100644 (file)
@@ -478,7 +478,7 @@ namespace HDF5
      *
      * When reading a hyperslab, HDF5 also allows to provide "stride" and
      * "block" parameters (see the [HDF5 documentation](https://support.hdfgroup.org/HDF5/doc1.8/RM/RM_H5S.html#Dataspace-SelectHyperslab)).
-     * These are not used by the current function and set to `NULL`. However
+     * These are not used by the current function and set to `nullptr`. However
      * these parameters can be used with the function
      * read_hyperslab(const std::vector<hsize_t> &, const std::vector<hsize_t> &, const std::vector<hsize_t> &, const std::vector<hsize_t> &, const std::vector<hsize_t> &)
      *
@@ -628,7 +628,7 @@ namespace HDF5
      *
      * When writing a hyperslab, HDF5 also allows to provide "stride" and
      * "block" parameters (see the [HDF5 documentation](https://support.hdfgroup.org/HDF5/doc1.8/RM/RM_H5S.html#Dataspace-SelectHyperslab)).
-     * These are not used by the current function and set to `NULL`. However
+     * These are not used by the current function and set to `nullptr`. However
      * these parameters can be used with the function
      * write_hyperslab(const Container &data, const std::vector<hsize_t> &data_dimensions, const std::vector<hsize_t> &offset, const std::vector<hsize_t> &stride, const std::vector<hsize_t> &count, const std::vector<hsize_t> &block).
      *
index 36b5665eb1a6a7095a236b7760a4e984413da162..7a0f374a300d7e6bdc923185625039557de28fa3 100644 (file)
@@ -210,7 +210,7 @@ namespace FETools
       // given FEs
       unsigned int n_shape_functions = 0;
       for (unsigned int i = 0; i < fes.size(); ++i)
-        if (multiplicities[i] > 0) // check needed as fe might be NULL
+        if (multiplicities[i] > 0) // check needed as fe might be nullptr
           n_shape_functions += fes[i]->dofs_per_cell * multiplicities[i];
 
       // generate the array that will hold the output
@@ -376,27 +376,27 @@ namespace FETools
       // given FEs
       unsigned int n_shape_functions = 0;
       for (unsigned int i = 0; i < fes.size(); ++i)
-        if (multiplicities[i] > 0) // needed because fe might be NULL
+        if (multiplicities[i] > 0) // needed because fe might be nullptr
           n_shape_functions += fes[i]->dofs_per_cell * multiplicities[i];
 
       unsigned int n_components = 0;
       if (do_tensor_product)
         {
           for (unsigned int i = 0; i < fes.size(); ++i)
-            if (multiplicities[i] > 0) // needed because fe might be NULL
+            if (multiplicities[i] > 0) // needed because fe might be nullptr
               n_components += fes[i]->n_components() * multiplicities[i];
         }
       else
         {
           for (unsigned int i = 0; i < fes.size(); ++i)
-            if (multiplicities[i] > 0) // needed because fe might be NULL
+            if (multiplicities[i] > 0) // needed because fe might be nullptr
               {
                 n_components = fes[i]->n_components();
                 break;
               }
           // Now check that all FEs have the same number of components:
           for (unsigned int i = 0; i < fes.size(); ++i)
-            if (multiplicities[i] > 0) // needed because fe might be NULL
+            if (multiplicities[i] > 0) // needed because fe might be nullptr
               Assert(n_components == fes[i]->n_components(),
                      ExcDimensionMismatch(n_components,
                                           fes[i]->n_components()));
index f1b37b0c9581824fe81ab2d5bf3757b2f0167a7f..7315fd9908407a56b3de3192625b7d688b6b74d6 100644 (file)
@@ -3285,7 +3285,7 @@ inline unsigned int
 FEEvaluationBase<dim, n_components_, Number, is_face>::
   get_mapping_data_index_offset() const
 {
-  if (matrix_info == 0)
+  if (matrix_info == nullptr)
     return 0;
   else
     {
index 20148e464786bb3c860a567e35374d143e7208cc..b4d3de0581b3b6b1233a3ee40e11d590a3999d34 100644 (file)
@@ -181,7 +181,7 @@ namespace Particles
      * point to the first entry of the array to which the data should be
      * written. This function is meant for serializing all particle properties
      * and later de-serializing the properties by calling the appropriate
-     * constructor Particle(void *&data, PropertyPool *property_pool = NULL);
+     * constructor Particle(void *&data, PropertyPool *property_pool = nullptr);
      *
      * @param [in,out] data The memory location to write particle data
      * into. This pointer points to the begin of the memory, in which the
index 2d74711b073f7d20ad39029dcbac6c7173aa7d13..d104f66d99a4ba6ce95dc597fea18cb7052c5060 100644 (file)
@@ -41,7 +41,7 @@ namespace Particles
      * point to the first element in which the data should be written. This
      * function is meant for serializing all particle properties and
      * afterwards de-serializing the properties by calling the appropriate
-     * constructor Particle(void *&data, PropertyPool *property_pool = NULL);
+     * constructor Particle(void *&data, PropertyPool *property_pool = nullptr);
      *
      * @param [in,out] data The memory location to write particle data
      * into. This pointer points to the begin of the memory, in which the
index 897131aeee8a75735bb56dd116a4aed06300ce63..881f0e787888e71f183db90dcc4d50e10e707f5f 100644 (file)
@@ -4901,7 +4901,7 @@ namespace DataOutBase
     // later
     char *file_name = (char *)flags.tecplot_binary_file_name;
 
-    if (file_name == NULL)
+    if (file_name == nullptr)
       {
         // At least in debug mode we should tell users why they don't get
         // tecplot binary output
@@ -5164,12 +5164,13 @@ namespace DataOutBase
       // As we don't do anything else with tec_var_names following const_cast is
       // ok
       char *var_names = const_cast<char *>(tec_var_names.c_str());
-      ierr = TECINI(NULL, var_names, file_name, dot, &tec_debug, &is_double);
+      ierr = TECINI(nullptr, var_names, file_name, dot, &tec_debug, &is_double);
 
       Assert(ierr == 0, ExcErrorOpeningTecplotFile(file_name));
 
       char FEBLOCK[] = {'F', 'E', 'B', 'L', 'O', 'C', 'K', 0};
-      ierr = TECZNE(NULL, &num_nodes, &num_cells, &cell_type, FEBLOCK, NULL);
+      ierr =
+        TECZNE(nullptr, &num_nodes, &num_cells, &cell_type, FEBLOCK, nullptr);
 
       Assert(ierr == 0, ExcTecplotAPIError());
 
index 0d17ae45d2481a5f9633a1ce3db7cb59592368fb..08d63382537b75cf4cc08f9bbf268d98f4fcdc74 100644 (file)
@@ -120,7 +120,7 @@ ExceptionBase::ExceptionBase(const ExceptionBase &exc)
 
 ExceptionBase::~ExceptionBase() noexcept
 {
-  free(stacktrace); // free(NULL) is allowed
+  free(stacktrace); // free(nullptr) is allowed
   stacktrace = nullptr;
 }
 
@@ -161,7 +161,7 @@ ExceptionBase::what() const noexcept
       // backtrace_symbols.
 
       // first delete old stacktrace if necessary
-      free(stacktrace); // free(NULL) is allowed
+      free(stacktrace); // free(nullptr) is allowed
       stacktrace = backtrace_symbols(raw_stacktrace, n_stacktrace_frames);
 #endif
 
index b5ff668b92c767a00ee662bf1e243a6d22f65410..bb51d880e3ddad5b85a2805d4372e8fa7e4bd484 100644 (file)
@@ -619,7 +619,8 @@ namespace HDF5
     Assert(rank_ret >= 0, ExcInternalError());
     rank = rank_ret;
     dimensions.resize(rank);
-    rank_ret = H5Sget_simple_extent_dims(*dataspace, dimensions.data(), NULL);
+    rank_ret =
+      H5Sget_simple_extent_dims(*dataspace, dimensions.data(), nullptr);
     AssertDimension(rank_ret, static_cast<int>(rank));
 
     size = 1;
@@ -655,7 +656,7 @@ namespace HDF5
       delete pointer;
     });
 
-    *dataspace = H5Screate_simple(rank, dimensions.data(), NULL);
+    *dataspace = H5Screate_simple(rank, dimensions.data(), nullptr);
     Assert(*dataspace >= 0, ExcMessage("Error at H5Screate_simple"));
 
     *hdf5_reference = H5Dcreate2(parent_group_id,
@@ -729,7 +730,7 @@ namespace HDF5
 
     Container data = internal::initialize_container<Container>(data_dimensions);
 
-    memory_dataspace = H5Screate_simple(1, data_dimensions.data(), NULL);
+    memory_dataspace = H5Screate_simple(1, data_dimensions.data(), nullptr);
     Assert(memory_dataspace >= 0, ExcMessage("Error at H5Screate_simple"));
     ret = H5Sselect_elements(*dataspace,
                              H5S_SELECT_SET,
@@ -781,10 +782,14 @@ namespace HDF5
     Container data = internal::initialize_container<Container>(data_dimensions);
 
     memory_dataspace =
-      H5Screate_simple(data_dimensions.size(), data_dimensions.data(), NULL);
+      H5Screate_simple(data_dimensions.size(), data_dimensions.data(), nullptr);
     Assert(memory_dataspace >= 0, ExcMessage("Error at H5Screate_simple"));
-    ret = H5Sselect_hyperslab(
-      *dataspace, H5S_SELECT_SET, offset.data(), NULL, count.data(), NULL);
+    ret = H5Sselect_hyperslab(*dataspace,
+                              H5S_SELECT_SET,
+                              offset.data(),
+                              nullptr,
+                              count.data(),
+                              nullptr);
     Assert(ret >= 0, ExcMessage("Error at H5Sselect_hyperslab"));
 
     internal::set_plist(plist, mpi);
@@ -830,7 +835,7 @@ namespace HDF5
     Container data = internal::initialize_container<Container>(data_dimensions);
 
     memory_dataspace =
-      H5Screate_simple(data_dimensions.size(), data_dimensions.data(), NULL);
+      H5Screate_simple(data_dimensions.size(), data_dimensions.data(), nullptr);
     Assert(memory_dataspace >= 0, ExcMessage("Error at H5Screate_simple"));
     ret = H5Sselect_hyperslab(*dataspace,
                               H5S_SELECT_SET,
@@ -877,18 +882,18 @@ namespace HDF5
     hid_t  plist;
     herr_t ret;
 
-    memory_dataspace = H5Screate_simple(1, data_dimensions.data(), NULL);
+    memory_dataspace = H5Screate_simple(1, data_dimensions.data(), nullptr);
     Assert(memory_dataspace >= 0, ExcMessage("Error at H5Screate_simple"));
     ret = H5Sselect_none(*dataspace);
     Assert(ret >= 0, ExcMessage("H5Sselect_none"));
 
     internal::set_plist(plist, mpi);
 
-    // The pointer of data can safely be NULL, see the discussion at the HDF5
+    // The pointer of data can safely be nullptr, see the discussion at the HDF5
     // forum:
     // https://forum.hdfgroup.org/t/parallel-i-o-does-not-support-filters-yet/884/17
     ret = H5Dread(
-      *hdf5_reference, *t_type, memory_dataspace, *dataspace, plist, NULL);
+      *hdf5_reference, *t_type, memory_dataspace, *dataspace, plist, nullptr);
     Assert(ret >= 0, ExcMessage("Error at H5Dread"));
 
     internal::release_plist(plist,
@@ -954,7 +959,7 @@ namespace HDF5
     herr_t ret;
 
 
-    memory_dataspace = H5Screate_simple(1, data_dimensions.data(), NULL);
+    memory_dataspace = H5Screate_simple(1, data_dimensions.data(), nullptr);
     Assert(memory_dataspace >= 0, ExcMessage("Error at H5Screate_simple"));
     ret = H5Sselect_elements(*dataspace,
                              H5S_SELECT_SET,
@@ -1009,10 +1014,14 @@ namespace HDF5
     herr_t ret;
 
     memory_dataspace =
-      H5Screate_simple(data_dimensions.size(), data_dimensions.data(), NULL);
+      H5Screate_simple(data_dimensions.size(), data_dimensions.data(), nullptr);
     Assert(memory_dataspace >= 0, ExcMessage("Error at H5Screate_simple"));
-    ret = H5Sselect_hyperslab(
-      *dataspace, H5S_SELECT_SET, offset.data(), NULL, count.data(), NULL);
+    ret = H5Sselect_hyperslab(*dataspace,
+                              H5S_SELECT_SET,
+                              offset.data(),
+                              nullptr,
+                              count.data(),
+                              nullptr);
     Assert(ret >= 0, ExcMessage("Error at H5Sselect_hyperslab"));
 
     internal::set_plist(plist, mpi);
@@ -1057,7 +1066,7 @@ namespace HDF5
     herr_t ret;
 
     memory_dataspace =
-      H5Screate_simple(data_dimensions.size(), data_dimensions.data(), NULL);
+      H5Screate_simple(data_dimensions.size(), data_dimensions.data(), nullptr);
     Assert(memory_dataspace >= 0, ExcMessage("Error at H5Screate_simple"));
     ret = H5Sselect_hyperslab(*dataspace,
                               H5S_SELECT_SET,
@@ -1103,18 +1112,18 @@ namespace HDF5
     hid_t  plist;
     herr_t ret;
 
-    memory_dataspace = H5Screate_simple(1, data_dimensions.data(), NULL);
+    memory_dataspace = H5Screate_simple(1, data_dimensions.data(), nullptr);
     Assert(memory_dataspace >= 0, ExcMessage("Error at H5Screate_simple"));
     ret = H5Sselect_none(*dataspace);
     Assert(ret >= 0, ExcMessage("Error at H5PSselect_none"));
 
     internal::set_plist(plist, mpi);
 
-    // The pointer of data can safely be NULL, see the discussion at the HDF5
+    // The pointer of data can safely be nullptr, see the discussion at the HDF5
     // forum:
     // https://forum.hdfgroup.org/t/parallel-i-o-does-not-support-filters-yet/884/17
     ret = H5Dwrite(
-      *hdf5_reference, *t_type, memory_dataspace, *dataspace, plist, NULL);
+      *hdf5_reference, *t_type, memory_dataspace, *dataspace, plist, nullptr);
     Assert(ret >= 0, ExcMessage("Error at H5Dwrite"));
 
     internal::release_plist(plist,
index af64a8b7d8da7a6c4fc66deac87f097d99359110..0283ed8fdff7d1574ce64c55b436584ea308d392 100644 (file)
@@ -68,7 +68,7 @@ MultithreadInfo::get_n_cpus()
   mib[0] = CTL_HW;
   mib[1] = HW_NCPU;
   len    = sizeof(n_cpus);
-  sysctl(mib, 2, &n_cpus, &len, NULL, 0);
+  sysctl(mib, 2, &n_cpus, &len, nullptr, 0);
 
   return n_cpus;
 }
index eec6f7305b8182f5dd3b6ff7550ba50d31369072..886483bb34c6ddc2e9864bef2d0ff63bc6027260 100644 (file)
@@ -164,7 +164,7 @@ Subscriptor::subscribe<const char *>(std::atomic<bool> *const validity,
     object_info = &typeid(*this);
   ++counter;
 
-  const char *const name = (id != 0) ? id : unknown_subscriber;
+  const char *const name = (id != nullptr) ? id : unknown_subscriber;
 
   map_iterator it = counter_map.find(name);
   if (it == counter_map.end())
index fc0b24487bdd59250bd2d690cd3d93cffefd9721..195101e5ee5ce106ceba13f87f3f930e31685cdd 100644 (file)
@@ -727,7 +727,8 @@ FE_Enriched<dim, spacedim>::multiply_by_enrichment(
             continue;
 
           Assert(enrichments[base_no - 1][m](cell) != nullptr,
-                 ExcMessage("The pointer to the enrichment function is NULL"));
+                 ExcMessage(
+                   "The pointer to the enrichment function is not set"));
 
           Assert(enrichments[base_no - 1][m](cell)->n_components == 1,
                  ExcMessage(
index 0afb57d1535c52e05baf1cbe44e887fbc6e8d3b8..9e3eebb63795078e0ca52e76f42b05b91ae8ca55 100644 (file)
@@ -1910,7 +1910,7 @@ FE_NedelecSZ<dim, spacedim>::fill_fe_values(
     &data) const
 {
   // Convert to the correct internal data class for this FE class.
-  Assert(dynamic_cast<const InternalData *>(&fe_internal) != 0,
+  Assert(dynamic_cast<const InternalData *>(&fe_internal) != nullptr,
          ExcInternalError());
   const InternalData &fe_data = static_cast<const InternalData &>(fe_internal);
 
@@ -2034,7 +2034,7 @@ FE_NedelecSZ<dim, spacedim>::fill_fe_face_values(
   // data for this class. fails with
   // an exception if that is not
   // possible
-  Assert(dynamic_cast<const InternalData *>(&fe_internal) != 0,
+  Assert(dynamic_cast<const InternalData *>(&fe_internal) != nullptr,
          ExcInternalError());
   const InternalData &fe_data = static_cast<const InternalData &>(fe_internal);
 
index 9ad476e4fd8df6860f3e5a0cbf407f6f0f98602b..ef8249183111a20fc6496b6d0798cefdffe246df 100644 (file)
@@ -321,7 +321,7 @@ namespace PETScWrappers
 
     // then restore the matrix and return the number of columns in this row as
     // queried previously. Starting with PETSc 3.4, MatRestoreRow actually
-    // resets the last three arguments to zero/NULL, to avoid abuse of pointers
+    // resets the last three arguments to nullptr, to avoid abuse of pointers
     // now dangling. as a consequence, we need to save the size of the array
     // and return the saved value.
     const PetscInt ncols_saved = ncols;
index 0f53cca4bbcf0e22972e45c818f8de379324f165..5adf4bb6e3641ba5fb89e1cb507b53d2764f0a5e 100644 (file)
@@ -433,8 +433,9 @@ namespace TrilinosWrappers
       // somewhere. This can happen when a vector lives in GrowingVectorMemory
       // data structures. Thus, the following code is commented out.
       //
-      // if (my_comm != NULL && v_comm != NULL && my_comm->DataPtr() !=
-      // v_comm->DataPtr())
+      // if (my_comm != nullptr &&
+      //     v_comm != nullptr &&
+      //     my_comm->DataPtr() != v_comm->DataPtr())
       //  {
       //    int communicators_same = 0;
       //    const int ierr = MPI_Comm_compare (my_comm->GetMpiComm(),

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.