From 9502cc4477c2b1db1429d36d47221da7f57a5bfa Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Tue, 5 Nov 2024 12:04:37 -0700 Subject: [PATCH] Eliminate static analyzer warnings --- .../seacas/libraries/exodus/src/ex_inquire.c | 4 +- .../exodus/src/ex_put_field_metadata.c | 6 +-- .../libraries/ioss/src/Ioss_ChangeSet.h | 2 +- .../ioss/src/Ioss_DynamicTopologyBroker.h | 4 +- .../src/Ioss_DynamicTopologyFileControl.h | 2 +- .../ioss/src/Ioss_DynamicTopologyNotifier.h | 2 +- .../ioss/src/Ioss_DynamicTopologyObserver.h | 6 +-- .../src/Ioss_DynamicTopologyStateLocator.h | 2 +- .../libraries/ioss/src/Ioss_GroupingEntity.h | 42 +++++++++---------- .../ioss/src/exodus/Ioex_ChangeSet.h | 2 +- .../libraries/ioss/src/exonull/Ioexnl_Utils.C | 4 +- .../libraries/ioss/src/utest/Utst_sort.C | 2 +- 12 files changed, 39 insertions(+), 39 deletions(-) diff --git a/packages/seacas/libraries/exodus/src/ex_inquire.c b/packages/seacas/libraries/exodus/src/ex_inquire.c index 8931656168..885b465cd4 100644 --- a/packages/seacas/libraries/exodus/src/ex_inquire.c +++ b/packages/seacas/libraries/exodus/src/ex_inquire.c @@ -1,5 +1,5 @@ /* - * Copyright(C) 1999-2023 National Technology & Engineering Solutions + * Copyright(C) 1999-2024 National Technology & Engineering Solutions * of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with * NTESS, the U.S. Government retains certain rights in this software. * @@ -980,7 +980,7 @@ static int ex_inquire_internal(int exoid, int req_info, int64_t *ret_int, float */ int nc_format = 0; nc_inq_format(exoid, &nc_format); - *ret_int = (int)nc_format; + *ret_int = nc_format; } break; case EX_INQ_THREADSAFE: diff --git a/packages/seacas/libraries/exodus/src/ex_put_field_metadata.c b/packages/seacas/libraries/exodus/src/ex_put_field_metadata.c index 81c4906995..f0ec11ead7 100644 --- a/packages/seacas/libraries/exodus/src/ex_put_field_metadata.c +++ b/packages/seacas/libraries/exodus/src/ex_put_field_metadata.c @@ -77,7 +77,7 @@ int ex_put_field_metadata(int exoid, const ex_field field) exi_persist_redef(exoid, __func__); int status = 0; - static char *field_template = "Field@%s@%s"; + static const char *field_template = "Field@%s@%s"; char attribute_name[NC_MAX_NAME + 1]; snprintf(attribute_name, NC_MAX_NAME + 1, field_template, field.name, "type"); if ((status = ex_put_integer_attribute(exoid, field.entity_type, field.entity_id, attribute_name, @@ -136,7 +136,7 @@ int exi_put_type_attribute(int exoid, const char *att_root, const char *name, co { int status = EX_NOERR; if (entry != NULL) { - static char *template = "%s@%s@%s"; + static const char *template = "%s@%s@%s"; char attribute_name[NC_MAX_NAME + 1]; snprintf(attribute_name, NC_MAX_NAME + 1, template, att_root, name, type); if (value_type == EX_INTEGER) { @@ -301,7 +301,7 @@ int ex_put_field_suffices(int exoid, const ex_field field, const char *suffices) char errmsg[MAX_ERR_LENGTH]; char attribute_name[NC_MAX_NAME + 1]; - static char *field_template = "Field@%s@%s"; + static const char *field_template = "Field@%s@%s"; if (field.type[0] != EX_FIELD_TYPE_USER_DEFINED) { snprintf( diff --git a/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.h b/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.h index d2cdb29684..23ad17d09f 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.h +++ b/packages/seacas/libraries/ioss/src/Ioss_ChangeSet.h @@ -47,7 +47,7 @@ namespace Ioss { class IOSS_EXPORT ChangeSet { public: - ChangeSet(Ioss::Region *region); + explicit ChangeSet(Ioss::Region *region); ChangeSet(Ioss::DatabaseIO *db, const std::string &dbName, const std::string &dbType, unsigned fileCyclicCount); diff --git a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyBroker.h b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyBroker.h index 06fc4b6358..a029fc8e27 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyBroker.h +++ b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyBroker.h @@ -49,8 +49,8 @@ namespace Ioss { void set_topology_modification(const std::string &model_name, unsigned int type); private: - DynamicTopologyBroker() {}; - DynamicTopologyBroker(DynamicTopologyBroker &); + DynamicTopologyBroker() = default; + DynamicTopologyBroker(DynamicTopologyBroker &) = delete; std::map> m_notifiers; }; diff --git a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyFileControl.h b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyFileControl.h index 8a4a95a84e..044c1036df 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyFileControl.h +++ b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyFileControl.h @@ -28,7 +28,7 @@ namespace Ioss { class IOSS_EXPORT DynamicTopologyFileControl { public: - DynamicTopologyFileControl(Region *region); + explicit DynamicTopologyFileControl(Region *region); void clone_and_replace_output_database(int steps = 0); void add_output_database_change_set(int steps = 0); diff --git a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyNotifier.h b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyNotifier.h index 24bd3d6009..a90d36a37b 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyNotifier.h +++ b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyNotifier.h @@ -28,7 +28,7 @@ namespace Ioss { class IOSS_EXPORT DynamicTopologyNotifier { public: - DynamicTopologyNotifier(const std::string &model_name) : m_modelName(model_name) {} + explicit DynamicTopologyNotifier(const std::string &model_name) : m_modelName(model_name) {} virtual ~DynamicTopologyNotifier() = default; diff --git a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyObserver.h b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyObserver.h index 6bb08cd018..65530994bc 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyObserver.h +++ b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyObserver.h @@ -29,9 +29,9 @@ namespace Ioss { class IOSS_EXPORT DynamicTopologyObserver { public: - DynamicTopologyObserver(Region *region) : m_region(region) {} + explicit DynamicTopologyObserver(Region *region) : m_region(region) {} - virtual ~DynamicTopologyObserver() {} + virtual ~DynamicTopologyObserver() = default; virtual void reset_topology_modification_all(); virtual void reset_topology_modification(); @@ -51,7 +51,7 @@ namespace Ioss { void set_automatic_restart(bool flag) { m_automaticRestart = flag; } void set_restart_requested(bool flag) { m_restartRequested = flag; } - static const std::string topology_modification_change_name() + static std::string topology_modification_change_name() { return std::string("CUMULATIVE_TOPOLOGY_MODIFICATION"); } diff --git a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyStateLocator.h b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyStateLocator.h index 557772c155..f62f79cddc 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyStateLocator.h +++ b/packages/seacas/libraries/ioss/src/Ioss_DynamicTopologyStateLocator.h @@ -48,7 +48,7 @@ namespace Ioss { private: struct DatabaseState { - DatabaseState(Ioss::DatabaseIO *db) + explicit DatabaseState(Ioss::DatabaseIO *db) { if (!db->supports_internal_change_set()) { changeSet = db->get_filename(); diff --git a/packages/seacas/libraries/ioss/src/Ioss_GroupingEntity.h b/packages/seacas/libraries/ioss/src/Ioss_GroupingEntity.h index e6123be18c..e3336329f2 100644 --- a/packages/seacas/libraries/ioss/src/Ioss_GroupingEntity.h +++ b/packages/seacas/libraries/ioss/src/Ioss_GroupingEntity.h @@ -161,20 +161,20 @@ namespace Ioss { // ======================================================================== // Property-related information.... // Just forward it through to the property manager... - inline void property_add(const Property &new_prop); - inline void property_erase(const std::string &property_name); - IOSS_NODISCARD inline bool property_exists(const std::string &property_name) const; - IOSS_NODISCARD inline Property get_property(const std::string &property_name) const; - IOSS_NODISCARD inline int64_t get_optional_property(const std::string &property, + void property_add(const Property &new_prop); + void property_erase(const std::string &property_name); + IOSS_NODISCARD bool property_exists(const std::string &property_name) const; + IOSS_NODISCARD Property get_property(const std::string &property_name) const; + IOSS_NODISCARD int64_t get_optional_property(const std::string &property, int64_t optional_value) const; - IOSS_NODISCARD inline std::string + IOSS_NODISCARD std::string get_optional_property(const std::string &property_name, const std::string &optional_value) const; - IOSS_NODISCARD inline NameList property_describe() const; - inline int property_describe(NameList *names) const; - IOSS_NODISCARD inline NameList property_describe(Ioss::Property::Origin origin) const; - inline int property_describe(Ioss::Property::Origin origin, NameList *names) const; - IOSS_NODISCARD inline size_t property_count() const; + IOSS_NODISCARD NameList property_describe() const; + int property_describe(NameList *names) const; + IOSS_NODISCARD NameList property_describe(Ioss::Property::Origin origin) const; + int property_describe(Ioss::Property::Origin origin, NameList *names) const; + IOSS_NODISCARD size_t property_count() const; /** Add a property, or change its value if it already exists with a different value */ void property_update(const std::string &property, int64_t value) const; @@ -185,16 +185,16 @@ namespace Ioss { // ======================================================================== // Just forward these through to the field manager... void field_add(Field new_field); - inline void field_erase(const std::string &field_name); - inline void field_erase(Field::RoleType role); - IOSS_NODISCARD inline bool field_exists(const std::string &field_name) const; - IOSS_NODISCARD inline Field get_field(const std::string &field_name) const; - IOSS_NODISCARD inline const Field &get_fieldref(const std::string &field_name) const; - inline int field_describe(NameList *names) const; - IOSS_NODISCARD inline NameList field_describe() const; - inline int field_describe(Field::RoleType role, NameList *names) const; - IOSS_NODISCARD inline NameList field_describe(Field::RoleType role) const; - IOSS_NODISCARD inline size_t field_count() const; + void field_erase(const std::string &field_name); + void field_erase(Field::RoleType role); + IOSS_NODISCARD bool field_exists(const std::string &field_name) const; + IOSS_NODISCARD Field get_field(const std::string &field_name) const; + IOSS_NODISCARD const Field &get_fieldref(const std::string &field_name) const; + int field_describe(NameList *names) const; + IOSS_NODISCARD NameList field_describe() const; + int field_describe(Field::RoleType role, NameList *names) const; + IOSS_NODISCARD NameList field_describe(Field::RoleType role) const; + IOSS_NODISCARD size_t field_count() const; IOSS_NODISCARD size_t field_count(Field::RoleType role) const; IOSS_NODISCARD bool check_for_duplicate(const Ioss::Field &new_field) const; diff --git a/packages/seacas/libraries/ioss/src/exodus/Ioex_ChangeSet.h b/packages/seacas/libraries/ioss/src/exodus/Ioex_ChangeSet.h index 176847eeeb..cc04313901 100644 --- a/packages/seacas/libraries/ioss/src/exodus/Ioex_ChangeSet.h +++ b/packages/seacas/libraries/ioss/src/exodus/Ioex_ChangeSet.h @@ -42,7 +42,7 @@ namespace Ioex { class IOEX_EXPORT ChangeSet : public Ioss::ChangeSet { public: - ChangeSet(Ioss::Region *region); + explicit ChangeSet(Ioss::Region *region); ChangeSet(Ioss::DatabaseIO *db, const std::string &dbName, const std::string &dbType, unsigned fileCyclicCount); diff --git a/packages/seacas/libraries/ioss/src/exonull/Ioexnl_Utils.C b/packages/seacas/libraries/ioss/src/exonull/Ioexnl_Utils.C index 52f3d0f48f..b724bc2098 100644 --- a/packages/seacas/libraries/ioss/src/exonull/Ioexnl_Utils.C +++ b/packages/seacas/libraries/ioss/src/exonull/Ioexnl_Utils.C @@ -207,7 +207,7 @@ namespace Ioexnl { auto errmsg = fmt::format("Error: failed to read processor info attribute from file {}", filename); ex_err_fn(exodusFilePtr, __func__, errmsg.c_str(), status); - return (EX_FATAL) != 0; + return EX_FATAL != 0; } } return matches; @@ -488,7 +488,7 @@ namespace Ioexnl { } nodes.resize(active); nodes.shrink_to_fit(); // shrink to fit - return (active != orig_size); + return active != orig_size; } void filter_element_list(Ioss::Region *region, Ioss::Int64Vector &elements, diff --git a/packages/seacas/libraries/ioss/src/utest/Utst_sort.C b/packages/seacas/libraries/ioss/src/utest/Utst_sort.C index b8d05bc61f..d2f46e561a 100644 --- a/packages/seacas/libraries/ioss/src/utest/Utst_sort.C +++ b/packages/seacas/libraries/ioss/src/utest/Utst_sort.C @@ -74,7 +74,7 @@ namespace { TEST_CASE("empty") { - std::vector x{}; + std::vector x; Ioss::sort(x); CHECK(verify_sorted(x)); }