]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix two minor warnings in BoundingBox.
authorDavid Wells <drwells@email.unc.edu>
Fri, 28 Aug 2020 13:27:51 +0000 (09:27 -0400)
committerDavid Wells <drwells@email.unc.edu>
Fri, 28 Aug 2020 13:28:35 +0000 (09:28 -0400)
GCC 10.2.0 has two new warnings:
1. Whenever dim is unsigned, equal to 0, and we check dim < 0 we get a type
   limits warning.
2. When spacedim = 2 we get a warning that both OR statements are equivalent.
   Make GCC happy by subtracting instead (and make things clearer by switching
   to a signed dimension).

include/deal.II/base/bounding_box.h
source/base/bounding_box.cc

index 36d515d40e07a0c67929ab50c34d69c32059581d..c842c8796a1b612a78074d5a7972ecf82af620c4 100644 (file)
@@ -362,19 +362,19 @@ namespace internal
    * dimension to a coordinate index in dim + 1 dimensions.
    *
    * @param locked_coordinate should be in the range [0, dim+1).
-   * @param coordiante_in_dim should be in the range [0, dim).
+   * @param coordinate_in_dim should be in the range [0, dim).
    * @return A coordinate index in the range [0, dim+1)
    *
    * @relates BoundingBox
    */
   template <int dim>
-  inline unsigned int
-  coordinate_to_one_dim_higher(const unsigned int locked_coordinate,
-                               const unsigned int coordiante_in_dim)
+  inline int
+  coordinate_to_one_dim_higher(const int locked_coordinate,
+                               const int coordinate_in_dim)
   {
     AssertIndexRange(locked_coordinate, dim + 1);
-    AssertIndexRange(coordiante_in_dim, dim);
-    return (locked_coordinate + coordiante_in_dim + 1) % (dim + 1);
+    AssertIndexRange(coordinate_in_dim, dim);
+    return (locked_coordinate + coordinate_in_dim + 1) % (dim + 1);
   }
 
 } // namespace internal
index 73ff6d088aea7f4814c0d340dbde6eff48c49e78..f4d9ec10e33c18c2a789287edd1b95bff5a78265 100644 (file)
@@ -96,8 +96,7 @@ BoundingBox<spacedim, Number>::get_neighbor_type(
         }
 
       // Finding the intersection's dimension
-
-      unsigned int intersect_dim = spacedim;
+      int intersect_dim = spacedim;
       for (unsigned int d = 0; d < spacedim; ++d)
         if (std::abs(intersect_bbox_min[d] - intersect_bbox_max[d]) <=
             std::numeric_limits<Number>::epsilon() *
@@ -105,7 +104,7 @@ BoundingBox<spacedim, Number>::get_neighbor_type(
                std::abs(intersect_bbox_max[d])))
           --intersect_dim;
 
-      if (intersect_dim == 0 || intersect_dim + 2 == spacedim)
+      if (intersect_dim == 0 || intersect_dim == spacedim - 2)
         return NeighborType::simple_neighbors;
 
       // Checking the two mergeable cases: first if the boxes are aligned so

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.