Skip to content

Commit

Permalink
fix nullptr dereferencing warning
Browse files Browse the repository at this point in the history
  • Loading branch information
niermann999 committed Jan 12, 2025
1 parent 5e89f23 commit 8cb1d01
Show file tree
Hide file tree
Showing 15 changed files with 29 additions and 23 deletions.
12 changes: 11 additions & 1 deletion core/include/detray/builders/surface_factory_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@

#pragma once

// TODO: Remove this when gcc fixes their false positives.
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic warning "-Wnull-dereference"
#endif

// Project include(s).
#include "detray/definitions/detail/indexing.hpp"
#include "detray/definitions/detail/qualifiers.hpp"
#include "detray/definitions/geometry.hpp"

// System include(s)
#include <memory>
#include <stdexcept>
#include <tuple>
#include <vector>

Expand Down Expand Up @@ -160,7 +166,11 @@ class factory_decorator : public surface_factory_interface<detector_t> {
explicit factory_decorator(
std::unique_ptr<surface_factory_interface<detector_t>> factory)
: m_factory(std::move(factory)) {
assert(m_factory != nullptr);
if (m_factory == nullptr || m_factory.get() == nullptr) {
throw std::runtime_error(
"Surface factory decorator constructed with invalid base "
"factory");
}
}

/// @returns access to the underlying factory - const
Expand Down
1 change: 0 additions & 1 deletion core/include/detray/core/detail/type_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#pragma once

// Project include(s)
#include "detray/core/detail/type_traits.hpp"
#include "detray/definitions/detail/indexing.hpp"
#include "detray/materials/detail/concepts.hpp"
#include "detray/materials/material_rod.hpp"
Expand Down
1 change: 1 addition & 0 deletions io/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ file(
"include/detray/io/frontend/detail/*.hpp"
"include/detray/io/frontend/impl/*.hpp"
"include/detray/io/json/*.hpp"
"include/detray/io/json/detail/*.hpp"
)
detray_add_library( detray_io io
${_detray_io_public_headers}
Expand Down
1 change: 0 additions & 1 deletion io/include/detray/io/backend/concepts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

// Project include(s)
#include "detray/builders/detector_builder.hpp"
#include "detray/utils/type_traits.hpp"

// System include(s)
#include <concepts>
Expand Down
6 changes: 3 additions & 3 deletions io/include/detray/io/backend/detail/type_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ get_id() {
}

/// Infer the IO material id from the material type - homogeneous material
template <concepts::homogeneous_material material_t>
template <detray::concepts::homogeneous_material material_t>
constexpr io::material_id get_id() {
using scalar_t = typename material_t::scalar_type;

Expand All @@ -67,7 +67,7 @@ constexpr io::material_id get_id() {
}

/// Infer the IO material id from the material type - material maps
template <concepts::material_map material_t>
template <detray::concepts::material_map material_t>
constexpr io::material_id get_id() {

using map_frame_t = typename material_t::local_frame_type;
Expand All @@ -88,7 +88,7 @@ constexpr io::material_id get_id() {
}

/// Infer the grid id from its coordinate system
template <concepts::surface_grid grid_t>
template <detray::concepts::surface_grid grid_t>
constexpr io::accel_id get_id() {

using frame_t = typename grid_t::local_frame_type;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class detector_components_writer final {

/// Create a new writer of type @tparam writer_t
template <class writer_t>
/*requires std::is_base_of_v<writer_interface<detector_t>, writer_t>*/ void
requires std::is_base_of_v<writer_interface<detector_t>, writer_t> void
add() {
add(std::make_unique<writer_t>());
}
Expand Down
2 changes: 0 additions & 2 deletions io/include/detray/io/frontend/impl/json_writers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ void add_json_writers(detector_components_writer<detector_t>& writers,
// Always needed
using json_geometry_writer = json_converter<detector_t, geometry_writer>;

static_assert(
io::concepts::writer_backend<detector_t, io::geometry_writer>);
writers.template add<json_geometry_writer>();

// Find other writers, depending on the detector type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

// Project include(s)
#include "detray/io/frontend/payloads.hpp"
#include "detray/io/json/detail/json_algebra_io.hpp"
#include "detray/io/json/detail/json_common_io.hpp"
#include "detray/io/json/detail/json_grids_io.hpp"
#include "detray/io/json/json.hpp"
#include "detray/io/json/json_algebra_io.hpp"
#include "detray/io/json/json_common_io.hpp"
#include "detray/io/json/json_grids_io.hpp"

// System include(s)
#include <array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
// Project include(s).
#include "detray/definitions/grid_axis.hpp"
#include "detray/io/frontend/payloads.hpp"
#include "detray/io/json/detail/json_algebra_io.hpp"
#include "detray/io/json/detail/json_common_io.hpp"
#include "detray/io/json/json.hpp"
#include "detray/io/json/json_algebra_io.hpp"
#include "detray/io/json/json_common_io.hpp"

// System include(s).
#include <array>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

// Project include(s)
#include "detray/io/frontend/payloads.hpp"
#include "detray/io/json/detail/json_common_io.hpp"
#include "detray/io/json/json.hpp"
#include "detray/io/json/json_common_io.hpp"

// System include(s)
#include <array>
Expand Down
10 changes: 5 additions & 5 deletions io/include/detray/io/json/json_io.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/** Detray library, part of the ACTS project (R&D line)
*
* (c) 2022-2023 CERN for the benefit of the ACTS project
* (c) 2022-2025 CERN for the benefit of the ACTS project
*
* Mozilla Public License Version 2.0
*/

#pragma once

#include "detray/io/json/json_algebra_io.hpp"
#include "detray/io/json/json_geometry_io.hpp"
#include "detray/io/json/json_grids_io.hpp"
#include "detray/io/json/json_material_io.hpp"
#include "detray/io/json/detail/json_algebra_io.hpp"
#include "detray/io/json/detail/json_geometry_io.hpp"
#include "detray/io/json/detail/json_grids_io.hpp"
#include "detray/io/json/detail/json_material_io.hpp"
3 changes: 1 addition & 2 deletions tests/integration_tests/io/io_json_detector_roundtrip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
#include "detray/io/backend/geometry_writer.hpp"
#include "detray/io/frontend/detector_reader.hpp"
#include "detray/io/frontend/detector_writer.hpp"
#include "detray/io/json/json_reader.hpp"
#include "detray/io/json/json_writer.hpp"
#include "detray/io/json/json_converter.hpp"

// Detray test include(s)
#include "detray/test/cpu/toy_detector_test.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit_tests/io/io_json_detector_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "detray/io/backend/material_map_writer.hpp"
#include "detray/io/backend/surface_grid_writer.hpp"
#include "detray/io/frontend/detector_writer.hpp"
#include "detray/io/json/json_writer.hpp"
#include "detray/io/json/json_converter.hpp"

// Detray test include(s)
#include "detray/test/utils/detectors/build_telescope_detector.hpp"
Expand Down

0 comments on commit 8cb1d01

Please sign in to comment.