From e985c3c9ec2d74a9897f7b6d437b009620a5a1af Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Mon, 26 Jan 2026 13:13:06 -0700 Subject: [PATCH 01/11] RCReaderTest fixed --- unit-tests/RCReaderTest.cc | 1 - unit-tests/marshT.cc | 71 ++++++++++++++++++-------------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/unit-tests/RCReaderTest.cc b/unit-tests/RCReaderTest.cc index e74477197..160fb4273 100644 --- a/unit-tests/RCReaderTest.cc +++ b/unit-tests/RCReaderTest.cc @@ -234,7 +234,6 @@ class RCReaderTest : public TestFixture { my_putenv(rc); try { - RCReader *reader = RCReader::instance(); rcr->loadRC(); CPPUNIT_ASSERT(!"initialize_instance() should throw Error."); } catch (const Error &e) { diff --git a/unit-tests/marshT.cc b/unit-tests/marshT.cc index 5f2529563..d294fd4e4 100644 --- a/unit-tests/marshT.cc +++ b/unit-tests/marshT.cc @@ -1,16 +1,14 @@ + #include #include #include #include -#include -#include #include "config.h" #ifdef HAVE_UNISTD_H #include #endif -#include #include #include @@ -33,10 +31,7 @@ #include "XDRFileUnMarshaller.h" #include "XDRStreamMarshaller.h" -#include "debug.h" - #include "run_tests_cppunit.h" -#include "test_config.h" using std::cerr; using std::cout; @@ -74,9 +69,9 @@ class marshT : public CppUnit::TestFixture { public: marshT() = default; - ~marshT() = default; + ~marshT() override = default; - void setUp() { + void setUp() override { b = new TestByte("b"); i16 = new TestInt16("i16"); i32 = new TestInt32("i32"); @@ -127,33 +122,33 @@ class marshT : public CppUnit::TestFixture { s->read(); } - void tearDown() { + void tearDown() override { delete b; - b = 0; + b = nullptr; delete i16; - i16 = 0; + i16 = nullptr; delete i32; - i32 = 0; + i32 = nullptr; delete ui16; - ui16 = 0; + ui16 = nullptr; delete ui32; - ui32 = 0; + ui32 = nullptr; delete f32; - f32 = 0; + f32 = nullptr; delete f64; - f64 = 0; + f64 = nullptr; delete str; - str = 0; + str = nullptr; delete url; - url = 0; + url = nullptr; delete ab; - ab = 0; + ab = nullptr; delete arr; - arr = 0; + arr = nullptr; delete s; - s = 0; + s = nullptr; delete seq; delete seq2; } @@ -173,7 +168,7 @@ class marshT : public CppUnit::TestFixture { DBG(cerr << "serializing using XDRFileMarshaller" << endl); - BaseType *bt = static_cast(b); + auto *bt = static_cast(b); FILE *f = fopen("test.file", "w"); CPPUNIT_ASSERT_THROW(bt->BaseType::serialize(eval, dds, fm, false), InternalErr); fclose(f); @@ -273,14 +268,16 @@ class marshT : public CppUnit::TestFixture { BaseType *bt = fs.var("fsab"); CPPUNIT_ASSERT(bt); - Array *fsarr_p = dynamic_cast(bt); + auto *fsarr_p = dynamic_cast(bt); CPPUNIT_ASSERT(fsarr_p); - dods_byte fdb[fsarr_p->length() * sizeof(dods_byte)]; - dods_byte db[arr->length() * sizeof(dods_byte)]; - fsarr_p->value(fdb); - arr->value(db); + // dods_byte fdb[fsarr_p->length() * sizeof(dods_byte)]; + // dods_byte db[arr->length() * sizeof(dods_byte)]; + vector fdb(fsarr_p->length() * sizeof(dods_byte)); + vector db(fsarr_p->length() * sizeof(dods_byte)); + fsarr_p->value(fdb.data()); + arr->value(db.data()); CPPUNIT_ASSERT(fsarr_p->length() == arr->length()); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db, fsarr_p->length() * sizeof(dods_byte))); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), fsarr_p->length() * sizeof(dods_byte))); DBG(cerr << " file array" << endl); TestByte fab("ab"); @@ -288,9 +285,9 @@ class marshT : public CppUnit::TestFixture { farr.append_dim(5, "dim1"); farr.append_dim(3, "dim2"); farr.deserialize(um, &dds, false); - farr.value(fdb); + farr.value(fdb.data()); CPPUNIT_ASSERT(farr.length() == arr->length()); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db, farr.length() * sizeof(dods_byte))); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), farr.length() * sizeof(dods_byte))); TestSequence fseq("fseq"); fseq.add_var(f64); @@ -309,15 +306,15 @@ class marshT : public CppUnit::TestFixture { BaseTypeRow *row = fseq.row_value(i); CPPUNIT_ASSERT(row); CPPUNIT_ASSERT(row->size() == 3); - Float64 *f64_p = dynamic_cast((*row)[0]); + auto *f64_p = dynamic_cast((*row)[0]); CPPUNIT_ASSERT(f64_p); CPPUNIT_ASSERT(f64_p->value() == f64->value()); - Array *arr_p = dynamic_cast((*row)[1]); + auto *arr_p = dynamic_cast((*row)[1]); CPPUNIT_ASSERT(arr_p); - arr_p->value(fdb); + arr_p->value(fdb.data()); CPPUNIT_ASSERT(arr_p->length() == arr->length()); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db, arr_p->length() * sizeof(dods_byte))); - Sequence *seq_p = dynamic_cast((*row)[2]); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), arr_p->length() * sizeof(dods_byte))); + auto *seq_p = dynamic_cast((*row)[2]); CPPUNIT_ASSERT(seq_p); unsigned int num_rows_sub = seq_p->number_of_rows(); CPPUNIT_ASSERT(num_rows == 4); @@ -325,10 +322,10 @@ class marshT : public CppUnit::TestFixture { BaseTypeRow *row_sub = seq_p->row_value(j); CPPUNIT_ASSERT(row_sub); CPPUNIT_ASSERT(row_sub->size() == 2); - UInt16 *ui16_p = dynamic_cast((*row_sub)[0]); + auto *ui16_p = dynamic_cast((*row_sub)[0]); CPPUNIT_ASSERT(ui16_p); CPPUNIT_ASSERT(ui16_p->value() == ui16->value()); - Url *url_p = dynamic_cast((*row_sub)[1]); + auto *url_p = dynamic_cast((*row_sub)[1]); CPPUNIT_ASSERT(url_p); CPPUNIT_ASSERT(url_p->value() == url->value()); } From 1fd405be992b065ab4128ed250fe65817a5514a3 Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Mon, 26 Jan 2026 13:19:26 -0700 Subject: [PATCH 02/11] More fixes for RCReaderTest --- unit-tests/RCReaderTest.cc | 42 ++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/unit-tests/RCReaderTest.cc b/unit-tests/RCReaderTest.cc index 160fb4273..63051e07c 100644 --- a/unit-tests/RCReaderTest.cc +++ b/unit-tests/RCReaderTest.cc @@ -22,28 +22,24 @@ // // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112. +#include "config.h" + #include -#include -#include "config.h" #ifdef HAVE_UNISTD_H #include #endif -#include -#include - #include #include #include #include #include -#include // #define DODS_DEBUG #include "RCReader.h" -#include "debug.h" + #include "run_tests_cppunit.h" #include "test_config.h" @@ -55,16 +51,14 @@ static char dods_conf_ev[1024] = ""; namespace libdap { class RCReaderTest : public TestFixture { -private: RCReader *rcr; -protected: public: RCReaderTest() : rcr(RCReader::instance()) {} - void setUp() {} + void setUp() override {} - void tearDown() {} + void tearDown() override {} /** Put values in an environment variable. This should be used only * for the env var 'DODS_CONF' and should never pass in values longer @@ -74,7 +68,7 @@ class RCReaderTest : public TestFixture { * so any value passed in from the heap that might be freed or from the * stack that could be popped will cause a memory access error. */ - void my_putenv(const string &value) { + static void my_putenv(const string &value) { strncpy(dods_conf_ev, value.c_str(), 1024); ; putenv(dods_conf_ev); @@ -100,12 +94,12 @@ class RCReaderTest : public TestFixture { void check_env_var_test1() { my_putenv("DODS_CONF="); - CPPUNIT_ASSERT(rcr->check_env_var("DODS_CONF") == ""); + CPPUNIT_ASSERT(rcr->check_env_var("DODS_CONF").empty()); } void check_env_var_test2() { my_putenv("DODS_CONF=Nothing_sensible"); - CPPUNIT_ASSERT(rcr->check_env_var("DODS_CONF") == ""); + CPPUNIT_ASSERT(rcr->check_env_var("DODS_CONF").empty()); } void check_env_var_test3() { @@ -142,7 +136,7 @@ class RCReaderTest : public TestFixture { // Create the file. string rc = string(cwd) + string("/.dodsrc"); CPPUNIT_ASSERT(rcr->check_env_var("DODS_CONF") == rc); - struct stat stat_info; + struct stat stat_info {}; CPPUNIT_ASSERT(stat(rc.c_str(), &stat_info) == 0 && S_ISREG(stat_info.st_mode)); remove(rc.c_str()); } @@ -155,7 +149,7 @@ class RCReaderTest : public TestFixture { if (*home.rbegin() != '/') home += "/"; - RCReader *reader = RCReader::instance(); + const RCReader *reader = RCReader::instance(); rcr->loadRC(); CPPUNIT_ASSERT(reader->d_rc_file_path == home + string(".dodsrc")); DBG(cerr << "Cache root: " << reader->get_dods_cache_root() << endl); @@ -225,11 +219,11 @@ class RCReaderTest : public TestFixture { CPPUNIT_ASSERT(reader->get_proxy_server_host() == "proxy.local.org"); CPPUNIT_ASSERT(reader->get_proxy_server_port() == 80); - CPPUNIT_ASSERT(reader->get_proxy_server_userpw() == ""); + CPPUNIT_ASSERT(reader->get_proxy_server_userpw().empty()); } void proxy_test3() { - string rc = (string) "DODS_CONF=" + TEST_SRC_DIR + "/rcreader-testsuite/test3.rc"; + const string rc = static_cast("DODS_CONF=") + TEST_SRC_DIR + "/rcreader-testsuite/test3.rc"; DBG(cerr << "rc: " << rc << endl); my_putenv(rc); @@ -238,7 +232,7 @@ class RCReaderTest : public TestFixture { CPPUNIT_ASSERT(!"initialize_instance() should throw Error."); } catch (const Error &e) { DBG(cerr << e.get_error_message() << endl); - CPPUNIT_ASSERT(e.get_error_message() != ""); + CPPUNIT_ASSERT(!e.get_error_message().empty()); } } @@ -248,7 +242,7 @@ class RCReaderTest : public TestFixture { my_putenv(rc); try { - RCReader *reader = RCReader::instance(); + const RCReader *reader = RCReader::instance(); rcr->loadRC(); DBG(cerr << "RC path: " << reader->d_rc_file_path << endl); CPPUNIT_ASSERT(reader->d_rc_file_path == (string)TEST_SRC_DIR + "/rcreader-testsuite/test4.rc"); @@ -263,7 +257,7 @@ class RCReaderTest : public TestFixture { CPPUNIT_ASSERT(reader->get_proxy_server_userpw() == "jimg:test"); } catch (Error &e) { DBG(cerr << e.get_error_message() << endl); - CPPUNIT_ASSERT(e.get_error_message() != ""); + CPPUNIT_ASSERT(!e.get_error_message().empty()); } } @@ -288,14 +282,14 @@ class RCReaderTest : public TestFixture { CPPUNIT_ASSERT(reader->get_proxy_server_userpw() == "jimg:test"); } catch (Error &e) { DBG(cerr << e.get_error_message() << endl); - CPPUNIT_ASSERT(e.get_error_message() != ""); + CPPUNIT_ASSERT(!e.get_error_message().empty()); } } // This simple test checks to see that the VALIDATE_SSL parameter is // read correctly. void validate_ssl_test() { - string rc = (string) "DODS_CONF=" + TEST_SRC_DIR + "/rcreader-testsuite/dodssrc_ssl_1"; + string rc = static_cast("DODS_CONF=") + TEST_SRC_DIR + "/rcreader-testsuite/dodssrc_ssl_1"; DBG(cerr << "rc: " << rc << endl); my_putenv(rc); @@ -311,7 +305,7 @@ class RCReaderTest : public TestFixture { // string object) because the code casts away the const-ness of the // char* returned by c_str() and putenv does odd stuff with it. There's // nothing good about using env vars... - rc = (string) "DODS_CONF=" + TEST_SRC_DIR + "/rcreader-testsuite/dodssrc_ssl_2"; + rc = static_cast("DODS_CONF=") + TEST_SRC_DIR + "/rcreader-testsuite/dodssrc_ssl_2"; DBG(cerr << "rc: " << rc << endl); my_putenv(rc); From ab8d2811afe5ae165c31cf234472f1c6a53240c4 Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Mon, 26 Jan 2026 13:36:56 -0700 Subject: [PATCH 03/11] Fixed warnings in MarshallerTest --- unit-tests/MarshallerTest.cc | 87 ++++++++++++++++++++---------------- unit-tests/marshT.cc | 2 - 2 files changed, 48 insertions(+), 41 deletions(-) diff --git a/unit-tests/MarshallerTest.cc b/unit-tests/MarshallerTest.cc index 05d0c3593..a8874896f 100644 --- a/unit-tests/MarshallerTest.cc +++ b/unit-tests/MarshallerTest.cc @@ -355,11 +355,11 @@ class MarshallerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(farr.length() == arr->length()); - dods_byte fdb[farr.length() * sizeof(dods_byte)]; - farr.value(fdb); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), farr.length() * sizeof(dods_byte))); + vector fdb(farr.length() * sizeof(dods_byte)); + farr.value(fdb.data()); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), farr.length() * sizeof(dods_byte))); } catch (Error &e) { - string err = "failed:" + e.get_error_message(); + const string err = "failed:" + e.get_error_message(); CPPUNIT_FAIL(err.c_str()); } } @@ -410,11 +410,11 @@ class MarshallerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(bt); Array *fsarr_p = dynamic_cast(bt); CPPUNIT_ASSERT(fsarr_p); - dods_byte fdb[fsarr_p->length() * sizeof(dods_byte)]; - fsarr_p->value(fdb); + vector fdb(fsarr_p->length() * sizeof(dods_byte)); + fsarr_p->value(fdb.data()); CPPUNIT_ASSERT(fsarr_p->length() == arr->length()); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), fsarr_p->length() * sizeof(dods_byte))); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), fsarr_p->length() * sizeof(dods_byte))); } catch (Error &e) { string err = "failed:" + e.get_error_message(); CPPUNIT_FAIL(err.c_str()); @@ -475,9 +475,11 @@ class MarshallerTest : public CppUnit::TestFixture { // Check the values in the array CPPUNIT_ASSERT(tg.get_array()->length() == arr->length()); - dods_byte fdb[tg.get_array()->length() * sizeof(dods_byte)]; - tg.get_array()->value(fdb); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), tg.get_array()->length() * sizeof(dods_byte))); + vector fdb(tg.get_array()->length() * sizeof(dods_byte)); + ; + tg.get_array()->value(fdb.data()); + CPPUNIT_ASSERT( + !memcmp((void *)fdb.data(), (void *)db.data(), tg.get_array()->length() * sizeof(dods_byte))); // Should test the map values here, but skip that for now... } catch (Error &e) { @@ -516,7 +518,8 @@ class MarshallerTest : public CppUnit::TestFixture { FILE *ff = fopen("seq_test.file", "r"); XDRFileUnMarshaller um(ff); - dods_byte fdb[arr->length() * sizeof(dods_byte)]; + vector fdb(arr->length() * sizeof(dods_byte)); + ; TestSequence seq("seq"); seq.add_var(f64); @@ -542,9 +545,9 @@ class MarshallerTest : public CppUnit::TestFixture { Array *arr_p = dynamic_cast((*row)[1]); CPPUNIT_ASSERT(arr_p); - arr_p->value(fdb); + arr_p->value(fdb.data()); CPPUNIT_ASSERT(arr_p->length() == arr->length()); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), arr_p->length() * sizeof(dods_byte))); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), arr_p->length() * sizeof(dods_byte))); Sequence *seq_p = dynamic_cast((*row)[2]); CPPUNIT_ASSERT(seq_p); unsigned int num_rows_sub = seq_p->number_of_rows(); @@ -677,9 +680,10 @@ class MarshallerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(farr.length() == arr->length()); - dods_byte fdb[arr->length() * sizeof(dods_byte)]; - farr.value(fdb); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), farr.length() * sizeof(dods_byte))); + vector fdb(arr->length() * sizeof(dods_byte)); + ; + farr.value(fdb.data()); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), farr.length() * sizeof(dods_byte))); } catch (Error &e) { string err = "failed:" + e.get_error_message(); CPPUNIT_FAIL(err.c_str()); @@ -1024,9 +1028,10 @@ class MarshallerTest : public CppUnit::TestFixture { Array *fsarr_p = dynamic_cast(bt); CPPUNIT_ASSERT(fsarr_p); CPPUNIT_ASSERT(fsarr_p->length() == arr->length()); - dods_byte fdb[fsarr_p->length() * sizeof(dods_byte)]; - fsarr_p->value(fdb); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), fsarr_p->length() * sizeof(dods_byte))); + vector fdb(fsarr_p->length() * sizeof(dods_byte)); + ; + fsarr_p->value(fdb.data()); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), fsarr_p->length() * sizeof(dods_byte))); } catch (Error &e) { string err = "failed:" + e.get_error_message(); CPPUNIT_FAIL(err.c_str()); @@ -1091,9 +1096,11 @@ class MarshallerTest : public CppUnit::TestFixture { // Check the values in the array CPPUNIT_ASSERT(tg.get_array()->length() == arr->length()); - dods_byte fdb[tg.get_array()->length() * sizeof(dods_byte)]; - tg.get_array()->value(fdb); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), tg.get_array()->length() * sizeof(dods_byte))); + vector fdb(tg.get_array()->length() * sizeof(dods_byte)); + ; + tg.get_array()->value(fdb.data()); + CPPUNIT_ASSERT( + !memcmp((void *)fdb.data(), (void *)db.data(), tg.get_array()->length() * sizeof(dods_byte))); } catch (Error &e) { string err = "failed:" + e.get_error_message(); CPPUNIT_FAIL(err.c_str()); @@ -1133,7 +1140,8 @@ class MarshallerTest : public CppUnit::TestFixture { FILE *sf = fopen("seq_test.strm", "r"); XDRFileUnMarshaller um(sf); #endif - dods_byte fdb[arr->length() * sizeof(dods_byte)]; + vector fdb(arr->length() * sizeof(dods_byte)); + ; TestSequence seq("seq"); seq.add_var(f64); @@ -1160,9 +1168,9 @@ class MarshallerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(f64_p->value() == f64->value()); Array *arr_p = dynamic_cast((*row)[1]); CPPUNIT_ASSERT(arr_p); - arr_p->value(fdb); + arr_p->value(fdb.data()); CPPUNIT_ASSERT(arr_p->length() == arr->length()); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), arr_p->length() * sizeof(dods_byte))); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), arr_p->length() * sizeof(dods_byte))); Sequence *seq_p = dynamic_cast((*row)[2]); CPPUNIT_ASSERT(seq_p); unsigned int num_rows_sub = seq_p->number_of_rows(); @@ -1263,22 +1271,23 @@ class MarshallerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(farr.length() == arr->length()); - dods_byte fdb[arr->length() * sizeof(dods_byte)]; - farr.value(fdb); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), farr.length() * sizeof(dods_byte))); + vector fdb(arr->length() * sizeof(dods_byte)); + ; + farr.value(fdb.data()); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), farr.length() * sizeof(dods_byte))); // now get three more arrays of the same size farr.deserialize(um, &dds, false); - farr.value(fdb); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), farr.length() * sizeof(dods_byte))); + farr.value(fdb.data()); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), farr.length() * sizeof(dods_byte))); farr.deserialize(um, &dds, false); - farr.value(fdb); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), farr.length() * sizeof(dods_byte))); + farr.value(fdb.data()); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), farr.length() * sizeof(dods_byte))); farr.deserialize(um, &dds, false); - farr.value(fdb); - CPPUNIT_ASSERT(!memcmp((void *)fdb, (void *)db.data(), farr.length() * sizeof(dods_byte))); + farr.value(fdb.data()); + CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), farr.length() * sizeof(dods_byte))); } catch (Error &e) { string err = "failed:" + e.get_error_message(); CPPUNIT_FAIL(err.c_str()); @@ -1402,14 +1411,14 @@ class MarshallerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(farr.length() == arr->length()); - dods_float32 fd_32[arr->length() * sizeof(dods_float32)]; - farr.value(fd_32); - CPPUNIT_ASSERT(!memcmp((void *)fd_32, (void *)d_f32.data(), farr.length() * sizeof(dods_float32))); + vector fd_32(arr->length() * sizeof(dods_float32)); + farr.value(fd_32.data()); + CPPUNIT_ASSERT(!memcmp((void *)fd_32.data(), (void *)d_f32.data(), farr.length() * sizeof(dods_float32))); // now get three more arrays of the same size farr.deserialize(um, &dds, false); - farr.value(fd_32); - CPPUNIT_ASSERT(!memcmp((void *)fd_32, (void *)d_f32.data(), farr.length() * sizeof(dods_byte))); + farr.value(fd_32.data()); + CPPUNIT_ASSERT(!memcmp((void *)fd_32.data(), (void *)d_f32.data(), farr.length() * sizeof(dods_byte))); } catch (Error &e) { string err = "failed:" + e.get_error_message(); CPPUNIT_FAIL(err.c_str()); diff --git a/unit-tests/marshT.cc b/unit-tests/marshT.cc index d294fd4e4..4bbcdd24d 100644 --- a/unit-tests/marshT.cc +++ b/unit-tests/marshT.cc @@ -270,8 +270,6 @@ class marshT : public CppUnit::TestFixture { CPPUNIT_ASSERT(bt); auto *fsarr_p = dynamic_cast(bt); CPPUNIT_ASSERT(fsarr_p); - // dods_byte fdb[fsarr_p->length() * sizeof(dods_byte)]; - // dods_byte db[arr->length() * sizeof(dods_byte)]; vector fdb(fsarr_p->length() * sizeof(dods_byte)); vector db(fsarr_p->length() * sizeof(dods_byte)); fsarr_p->value(fdb.data()); From cd2a29fcc56e6916b6fab01e6520e8d0818b3cf4 Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Mon, 26 Jan 2026 13:41:57 -0700 Subject: [PATCH 04/11] more fixes in MarshallerTest --- unit-tests/MarshallerTest.cc | 86 +++++++++++------------------------- 1 file changed, 27 insertions(+), 59 deletions(-) diff --git a/unit-tests/MarshallerTest.cc b/unit-tests/MarshallerTest.cc index a8874896f..9b1530b4d 100644 --- a/unit-tests/MarshallerTest.cc +++ b/unit-tests/MarshallerTest.cc @@ -1,21 +1,15 @@ + +#include "config.h" + #include #include #include #include -#include -#include - -#include "config.h" #ifdef HAVE_UNISTD_H #include #endif -#include -#include -// #define DODS_DEBUG 1 - -#include #include #include @@ -44,7 +38,6 @@ #include "debug.h" #include "run_tests_cppunit.h" -#include "test_config.h" int test_variable_sleep_interval = 0; // Used in Test* classes for testing timeouts. @@ -148,7 +141,7 @@ class MarshallerTest : public CppUnit::TestFixture { url_value = "http://dcz.gso.uri.edu/avhrr-archive/archive.html"; } - void setUp() { + void setUp() override { b = new TestByte("byte"); b->read(); @@ -225,41 +218,41 @@ class MarshallerTest : public CppUnit::TestFixture { s->set_send_p(true); } - void tearDown() { + void tearDown() override { delete b; - b = 0; + b = nullptr; delete i16; - i16 = 0; + i16 = nullptr; delete i32; - i32 = 0; + i32 = nullptr; delete ui16; - ui16 = 0; + ui16 = nullptr; delete ui32; - ui32 = 0; + ui32 = nullptr; delete f32; - f32 = 0; + f32 = nullptr; delete f64; - f64 = 0; + f64 = nullptr; delete str; - str = 0; + str = nullptr; delete url; - url = 0; + url = nullptr; delete ab; - ab = 0; + ab = nullptr; delete arr; - arr = 0; + arr = nullptr; delete a_f32; - ab = 0; + ab = nullptr; delete arr_f32; - arr_f32 = 0; + arr_f32 = nullptr; delete a_f64; - ab = 0; + ab = nullptr; delete arr_f64; - arr_f64 = 0; + arr_f64 = nullptr; delete s; - s = 0; + s = nullptr; } void simple_types_file_serialize_test() { @@ -408,7 +401,7 @@ class MarshallerTest : public CppUnit::TestFixture { BaseType *bt = fs.var("fsab"); CPPUNIT_ASSERT(bt); - Array *fsarr_p = dynamic_cast(bt); + auto *fsarr_p = dynamic_cast(bt); CPPUNIT_ASSERT(fsarr_p); vector fdb(fsarr_p->length() * sizeof(dods_byte)); fsarr_p->value(fdb.data()); @@ -539,16 +532,16 @@ class MarshallerTest : public CppUnit::TestFixture { BaseTypeRow *row = seq.row_value(i); CPPUNIT_ASSERT(row); CPPUNIT_ASSERT(row->size() == 3); - Float64 *f64_p = dynamic_cast((*row)[0]); + auto *f64_p = dynamic_cast((*row)[0]); CPPUNIT_ASSERT(f64_p); CPPUNIT_ASSERT(f64_p->value() == f64->value()); - Array *arr_p = dynamic_cast((*row)[1]); + auto *arr_p = dynamic_cast((*row)[1]); CPPUNIT_ASSERT(arr_p); arr_p->value(fdb.data()); CPPUNIT_ASSERT(arr_p->length() == arr->length()); CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), arr_p->length() * sizeof(dods_byte))); - Sequence *seq_p = dynamic_cast((*row)[2]); + auto *seq_p = dynamic_cast((*row)[2]); CPPUNIT_ASSERT(seq_p); unsigned int num_rows_sub = seq_p->number_of_rows(); CPPUNIT_ASSERT(num_rows == 4); @@ -556,10 +549,10 @@ class MarshallerTest : public CppUnit::TestFixture { BaseTypeRow *row_sub = seq_p->row_value(j); CPPUNIT_ASSERT(row_sub); CPPUNIT_ASSERT(row_sub->size() == 2); - UInt16 *ui16_p = dynamic_cast((*row_sub)[0]); + auto *ui16_p = dynamic_cast((*row_sub)[0]); CPPUNIT_ASSERT(ui16_p); CPPUNIT_ASSERT(ui16_p->value() == ui16->value()); - Url *url_p = dynamic_cast((*row_sub)[1]); + auto url_p = dynamic_cast((*row_sub)[1]); CPPUNIT_ASSERT(url_p); CPPUNIT_ASSERT(url_p->value() == url->value()); } @@ -823,13 +816,8 @@ class MarshallerTest : public CppUnit::TestFixture { void array_f32_stream_deserialize_test() { try { -#if 0 - ifstream strm( "a_test.strm", ios::in ); - XDRStreamUnMarshaller um( strm ); -#else FILE *sf = fopen("a_f32_test.file", "r"); XDRFileUnMarshaller um(sf); -#endif TestFloat32 fa_f32("a_f32"); TestArray farr("arr_f32", &fa_f32); farr.append_dim(5, "dim1"); @@ -908,13 +896,8 @@ class MarshallerTest : public CppUnit::TestFixture { void array_f64_stream_deserialize_test() { try { -#if 0 - ifstream strm( "a_test.strm", ios::in ); - XDRStreamUnMarshaller um( strm ); -#else FILE *sf = fopen("a_f64_test.file", "r"); XDRFileUnMarshaller um(sf); -#endif TestFloat64 fa_f64("a_f64"); TestArray farr("arr_f64", &fa_f64); farr.append_dim(5, "dim1"); @@ -992,13 +975,8 @@ class MarshallerTest : public CppUnit::TestFixture { void structure_stream_deserialize_test() { try { -#if 0 - ifstream strm( "struct_test.strm", ios::in ); - XDRStreamUnMarshaller um( strm ); -#else FILE *sf = fopen("struct_test.strm", "r"); XDRFileUnMarshaller um(sf); -#endif TestStructure fs("fs"); TestInt32 fsi32("fsi32"); fs.add_var(&fsi32); @@ -1070,13 +1048,8 @@ class MarshallerTest : public CppUnit::TestFixture { void grid_stream_deserialize_test() { try { -#if 0 - ifstream strm( "g_test.strm", ios::in ); - XDRStreamUnMarshaller um( strm ); -#else FILE *sf = fopen("g_test.strm", "r"); XDRFileUnMarshaller um(sf); -#endif TestGrid tg("grid1"); TestArray arr2("arr2", ab); arr2.append_dim(5, "dim1"); @@ -1133,13 +1106,8 @@ class MarshallerTest : public CppUnit::TestFixture { void sequence_stream_deserialize_test() { try { -#if 0 - ifstream strm( "seq_test.strm", ios::in ); - XDRStreamUnMarshaller um( strm ); -#else FILE *sf = fopen("seq_test.strm", "r"); XDRFileUnMarshaller um(sf); -#endif vector fdb(arr->length() * sizeof(dods_byte)); ; From ef80bfd15ac5f3f1d748d99c761598e975cc1546 Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Mon, 26 Jan 2026 14:19:55 -0700 Subject: [PATCH 05/11] more fixes in MarshallerTest --- unit-tests/MarshallerTest.cc | 69 ++++++++++++++---------------------- 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/unit-tests/MarshallerTest.cc b/unit-tests/MarshallerTest.cc index 9b1530b4d..7a257f11d 100644 --- a/unit-tests/MarshallerTest.cc +++ b/unit-tests/MarshallerTest.cc @@ -95,51 +95,45 @@ class MarshallerTest : public CppUnit::TestFixture { CPPUNIT_TEST(array_stream_put_vector_thread_test_4); CPPUNIT_TEST(array_stream_put_vector_thread_test_5); -#if 1 CPPUNIT_TEST(array_stream_serialize_part_thread_test); CPPUNIT_TEST(array_stream_serialize_part_thread_test_2); CPPUNIT_TEST(array_stream_serialize_part_thread_test_3); -#endif CPPUNIT_TEST_SUITE_END(); - TestByte *b; - TestInt16 *i16; - TestInt32 *i32; - TestUInt16 *ui16; - TestUInt32 *ui32; - TestFloat32 *f32; - TestFloat64 *f64; - TestStr *str; - TestUrl *url; + TestByte *b = nullptr; + TestInt16 *i16 = nullptr; + TestInt32 *i32 = nullptr; + TestUInt16 *ui16 = nullptr; + TestUInt32 *ui32 = nullptr; + TestFloat32 *f32 = nullptr; + TestFloat64 *f64 = nullptr; + TestStr *str = nullptr; + TestUrl *url = nullptr; vector db; - TestByte *ab; - TestArray *arr; + TestByte *ab = nullptr; + TestArray *arr = nullptr; vector d_f32; - TestFloat32 *a_f32; - TestArray *arr_f32; + TestFloat32 *a_f32 = nullptr; + TestArray *arr_f32 = nullptr; vector d_f64; - TestFloat64 *a_f64; - TestArray *arr_f64; + TestFloat64 *a_f64 = nullptr; + TestArray *arr_f64 = nullptr; - TestStructure *s; + TestStructure *s = nullptr; ConstraintEvaluator eval; TestTypeFactory ttf; DataDDS dds; string str_value, str2_value; - string url_value; + string url_value{"http://dcz.gso.uri.edu/avhrr-archive/archive.html"}; public: - MarshallerTest() - : b(0), i16(0), i32(0), ui16(0), ui32(0), f32(0), f64(0), str(0), url(0), ab(0), arr(0), a_f32(0), arr_f32(0), - a_f64(0), arr_f64(0), s(0), dds(&ttf, "dds") { - url_value = "http://dcz.gso.uri.edu/avhrr-archive/archive.html"; - } + MarshallerTest() : dds(&ttf, "dds") {} void setUp() override { b = new TestByte("byte"); @@ -595,13 +589,8 @@ class MarshallerTest : public CppUnit::TestFixture { void simple_types_stream_deserialize_test() { try { -#if 0 - ifstream strm( "st_test.strm", ios::in ); - XDRStreamUnMarshaller um( strm ); -#else FILE *sf = fopen("st_test.strm", "r"); XDRFileUnMarshaller um(sf); -#endif Byte fb("fb"); fb.deserialize(um, &dds, false); CPPUNIT_ASSERT(fb.value() == b->value()); @@ -658,13 +647,8 @@ class MarshallerTest : public CppUnit::TestFixture { void array_stream_deserialize_test() { try { -#if 0 - ifstream strm( "a_test.strm", ios::in ); - XDRStreamUnMarshaller um( strm ); -#else FILE *sf = fopen("a_test.strm", "r"); XDRFileUnMarshaller um(sf); -#endif TestByte fab("ab"); TestArray farr("arr", &fab); farr.append_dim(5, "dim1"); @@ -996,18 +980,17 @@ class MarshallerTest : public CppUnit::TestFixture { CPPUNIT_ASSERT(fsi32_p); CPPUNIT_ASSERT(fsi32_p->value() == i32->value()); - Str *fsstr_p = dynamic_cast(fs.var("fsstr")); + auto fsstr_p = dynamic_cast(fs.var("fsstr")); CPPUNIT_ASSERT(fsstr_p); DBG(cerr << "fsstr_p->value(): " << fsstr_p->value() << endl); CPPUNIT_ASSERT(fsstr_p->value().find("Silly test string:") != string::npos); BaseType *bt = fs.var("fsab"); CPPUNIT_ASSERT(bt); - Array *fsarr_p = dynamic_cast(bt); + auto *fsarr_p = dynamic_cast(bt); CPPUNIT_ASSERT(fsarr_p); CPPUNIT_ASSERT(fsarr_p->length() == arr->length()); vector fdb(fsarr_p->length() * sizeof(dods_byte)); - ; fsarr_p->value(fdb.data()); CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), fsarr_p->length() * sizeof(dods_byte))); } catch (Error &e) { @@ -1131,15 +1114,15 @@ class MarshallerTest : public CppUnit::TestFixture { BaseTypeRow *row = seq.row_value(i); CPPUNIT_ASSERT(row); CPPUNIT_ASSERT(row->size() == 3); - Float64 *f64_p = dynamic_cast((*row)[0]); + auto *f64_p = dynamic_cast((*row)[0]); CPPUNIT_ASSERT(f64_p); CPPUNIT_ASSERT(f64_p->value() == f64->value()); - Array *arr_p = dynamic_cast((*row)[1]); + auto *arr_p = dynamic_cast((*row)[1]); CPPUNIT_ASSERT(arr_p); arr_p->value(fdb.data()); CPPUNIT_ASSERT(arr_p->length() == arr->length()); CPPUNIT_ASSERT(!memcmp((void *)fdb.data(), (void *)db.data(), arr_p->length() * sizeof(dods_byte))); - Sequence *seq_p = dynamic_cast((*row)[2]); + auto *seq_p = dynamic_cast((*row)[2]); CPPUNIT_ASSERT(seq_p); unsigned int num_rows_sub = seq_p->number_of_rows(); CPPUNIT_ASSERT(num_rows == 4); @@ -1147,10 +1130,10 @@ class MarshallerTest : public CppUnit::TestFixture { BaseTypeRow *row_sub = seq_p->row_value(j); CPPUNIT_ASSERT(row_sub); CPPUNIT_ASSERT(row_sub->size() == 2); - UInt16 *ui16_p = dynamic_cast((*row_sub)[0]); + const auto *ui16_p = dynamic_cast((*row_sub)[0]); CPPUNIT_ASSERT(ui16_p); CPPUNIT_ASSERT(ui16_p->value() == ui16->value()); - Url *url_p = dynamic_cast((*row_sub)[1]); + const auto url_p = dynamic_cast((*row_sub)[1]); CPPUNIT_ASSERT(url_p); CPPUNIT_ASSERT(url_p->value() == url->value()); } @@ -1329,7 +1312,7 @@ class MarshallerTest : public CppUnit::TestFixture { throw InternalErr(__FILE__, __LINE__, "Implemented for numeric simple types only"); } } catch (Error &e) { - string err = "failed:" + e.get_error_message(); + const string err = "failed:" + e.get_error_message(); CPPUNIT_FAIL(err.c_str()); } From 69ff86ce7790a176fd6d5a5dd62446553c6d2caf Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Mon, 26 Jan 2026 15:11:07 -0700 Subject: [PATCH 06/11] Suppress warnings for a range of lines in XDRUtil.cc --- Array.cc | 2 +- CMakeLists.txt | 1 + D4Enum.cc | 2 +- D4Opaque.cc | 6 +----- D4Sequence.cc | 2 +- Int64.cc | 22 +--------------------- Int8.cc | 2 +- Sequence.cc | 4 ++-- Sequence.h | 4 ++-- UInt32.cc | 4 ++-- UInt64.cc | 16 +--------------- XDRUtils.cc | 7 ++++--- diagnostic_suppression.h | 25 +++++++++++++++++++++++++ 13 files changed, 43 insertions(+), 54 deletions(-) create mode 100644 diagnostic_suppression.h diff --git a/Array.cc b/Array.cc index c837369a9..36b3a6e9c 100644 --- a/Array.cc +++ b/Array.cc @@ -994,7 +994,7 @@ void Array::print_decl(FILE *out, string space, bool print_semi, bool constraint constrained, and FALSE otherwise. */ void Array::print_decl(ostream &out, string space, bool print_semi, bool constraint_info, bool constrained, - bool is_root_grp, bool array_member) { + bool is_root_grp, bool) { if (constrained && !send_p()) return; diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e8389453..6d27adcb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -160,6 +160,7 @@ set(DAP4_ONLY_SRC D4ParserSax2.cc D4BaseTypeFactory.cc D4Dimensions.cc D4EnumDefs.cc D4Group.cc DMR.cc D4Attributes.cc D4Enum.cc chunked_ostream.cc chunked_istream.cc D4Sequence.cc D4Maps.cc D4Opaque.cc D4AsyncUtil.cc D4RValue.cc D4FilterClause.cc + diagnostic_suppression.h ) set(CLIENT_SRC RCReader.cc Connect.cc D4Connect.cc util_mit.cc) diff --git a/D4Enum.cc b/D4Enum.cc index 969c78b87..fe4ecb673 100644 --- a/D4Enum.cc +++ b/D4Enum.cc @@ -87,7 +87,7 @@ void D4Enum::m_duplicate(const D4Enum &src) { * * @param attr AttrTable pointer, ignored by this method. */ -std::vector *D4Enum::transform_to_dap2(AttrTable *, bool show_shared_dims) { +std::vector *D4Enum::transform_to_dap2(AttrTable *, bool) { BaseType *btp; DBG(cerr << __func__ << "() - BEGIN" << endl;); diff --git a/D4Opaque.cc b/D4Opaque.cc index b0465bea7..24f9e3d98 100644 --- a/D4Opaque.cc +++ b/D4Opaque.cc @@ -116,11 +116,7 @@ bool D4Opaque::set_value(const dods_opaque &value) { @return The value. */ D4Opaque::dods_opaque D4Opaque::value() const { return d_buf; } -std::vector *D4Opaque::transform_to_dap2(AttrTable *, bool show_shared_dims) { - - DBG(cerr << __func__ << "() - Transform not implemented DAP4 Opaque type." << endl;); - return NULL; -} +std::vector *D4Opaque::transform_to_dap2(AttrTable *, bool) { return nullptr; } void D4Opaque::print_val(ostream &out, string space, bool print_decl_p, bool is_root_grp) { if (print_decl_p) diff --git a/D4Sequence.cc b/D4Sequence.cc index 4874bf532..8e0c9c097 100644 --- a/D4Sequence.cc +++ b/D4Sequence.cc @@ -453,7 +453,7 @@ void D4Sequence::print_val_by_rows(ostream &out, string space, bool print_decl_p out << ";\n"; } -void D4Sequence::print_val(ostream &out, string space, bool print_decl_p, bool is_root_grp) { +void D4Sequence::print_val(ostream &out, string space, bool print_decl_p, bool) { DBG(cerr << name() << " isa " << type_name() << endl); print_val_by_rows(out, space, print_decl_p, false); diff --git a/Int64.cc b/Int64.cc index 56f84f73e..ba715add4 100644 --- a/Int64.cc +++ b/Int64.cc @@ -51,13 +51,6 @@ #include "UInt64.h" #include "Url.h" -#if 0 -#include "Array.h" -#include "Grid.h" -#include "Sequence.h" -#include "Structure.h" -#endif - #include "D4StreamMarshaller.h" #include "D4StreamUnMarshaller.h" #include "DMR.h" @@ -211,20 +204,7 @@ bool Int64::d4_ops(BaseType *b, int op) { * * @return A pointer to the transformed variable */ -std::vector *Int64::transform_to_dap2(AttrTable *, bool show_shared_dims) { -#if 0 - BaseType *dest = this->ptr_duplicate(); - // convert the d4 attributes to a dap2 attribute table. - AttrTable *attrs = this->attributes()->get_AttrTable(); - attrs->set_name(name()); - dest->set_attr_table(*attrs); - dest->set_is_dap4(false); - // attrs->print(cerr,"",true); - return dest; -#endif - - return NULL; -} +std::vector *Int64::transform_to_dap2(AttrTable *, bool) { return nullptr; } /** * When send_p() is true a description of the instance is added to the inventory and true is returned. diff --git a/Int8.cc b/Int8.cc index ed6e21d27..397e97dc6 100644 --- a/Int8.cc +++ b/Int8.cc @@ -187,7 +187,7 @@ bool Int8::d4_ops(BaseType *b, int op) { * * @return A pointer to the transformed variable */ -std::vector *Int8::transform_to_dap2(AttrTable *parent_attr_table, bool show_shared_dims) { +std::vector *Int8::transform_to_dap2(AttrTable *parent_attr_table, bool) { vector *vec = BaseType::transform_to_dap2(parent_attr_table); if (vec->size() != 1) { ostringstream oss; diff --git a/Sequence.cc b/Sequence.cc index 6c0ad09e8..241313fdc 100644 --- a/Sequence.cc +++ b/Sequence.cc @@ -1109,11 +1109,11 @@ void Sequence::print_val_by_rows(ostream &out, string space, bool print_decl_p, out << ";\n"; } -void Sequence::print_val(FILE *out, string space, bool print_decl_p, bool is_root_grp) { +void Sequence::print_val(FILE *out, string space, bool print_decl_p, bool) { print_val_by_rows(out, space, print_decl_p, false); } -void Sequence::print_val(ostream &out, string space, bool print_decl_p, bool is_root_grp) { +void Sequence::print_val(ostream &out, string space, bool print_decl_p, bool) { print_val_by_rows(out, space, print_decl_p, false); } diff --git a/Sequence.h b/Sequence.h index 7dc81b516..ed491e505 100644 --- a/Sequence.h +++ b/Sequence.h @@ -218,12 +218,12 @@ class Sequence : public Constructor { sequence_values_stack_t &sequence_values_stack); public: - Sequence(const string &n); + explicit Sequence(const string &n); Sequence(const string &n, const string &d); Sequence(const Sequence &rhs); - virtual ~Sequence(); + ~Sequence() override; Sequence &operator=(const Sequence &rhs); diff --git a/UInt32.cc b/UInt32.cc index 716480562..97b62dc3f 100644 --- a/UInt32.cc +++ b/UInt32.cc @@ -199,7 +199,7 @@ bool UInt32::ops(BaseType *b, int op) { // Since the read method is virtual and implemented outside // libdap++ if we cannot read the data that is the problem // of the user or of whoever wrote the surrogate library - // implemeting read therefore it is an internal error. + // implementing read, therefore, it is an internal error. throw InternalErr(__FILE__, __LINE__, "This value was not read!"); } @@ -209,7 +209,7 @@ bool UInt32::ops(BaseType *b, int op) { // Since the read method is virtual and implemented outside // libdap++ if we cannot read the data that is the problem // of the user or of whoever wrote the surrogate library - // implemeting read therefore it is an internal error. + // implementing read, therefore, it is an internal error. throw InternalErr(__FILE__, __LINE__, "This value was not read!"); } diff --git a/UInt64.cc b/UInt64.cc index 608c105c2..17092ee7e 100644 --- a/UInt64.cc +++ b/UInt64.cc @@ -218,21 +218,7 @@ bool UInt64::d4_ops(BaseType *b, int op) { * * @return A pointer to the transformed variable */ -std::vector *UInt64::transform_to_dap2(AttrTable *, bool show_shared_dims) { - -#if 0 - BaseType *dest = this->ptr_duplicate(); - // convert the d4 attributes to a dap2 attribute table. - AttrTable *attrs = this->attributes()->get_AttrTable(); - attrs->set_name(name()); - dest->set_attr_table(*attrs); - dest->set_is_dap4(false); - // attrs->print(cerr,"",true); - return dest; -#endif - - return NULL; -} +std::vector *UInt64::transform_to_dap2(AttrTable *, bool) { return nullptr; } /** * When send_p() is true a description of the instance is added to the inventory and true is returned. diff --git a/XDRUtils.cc b/XDRUtils.cc index 848af9a25..f225025b1 100644 --- a/XDRUtils.cc +++ b/XDRUtils.cc @@ -35,6 +35,7 @@ #include "Str.h" #include "XDRUtils.h" #include "debug.h" +#include "diagnostic_suppression.h" using namespace libdap; @@ -135,7 +136,7 @@ namespace libdap { @return A C function used to encode data in the XDR format. */ xdrproc_t XDRUtils::xdr_coder(const Type &t) { - switch (t) { + A_cast_function_type_mismatch switch (t) { case dods_int16_c: return reinterpret_cast(XDR_INT16); case dods_uint16_c: @@ -148,6 +149,7 @@ xdrproc_t XDRUtils::xdr_coder(const Type &t) { return reinterpret_cast(XDR_FLOAT32); case dods_float64_c: return reinterpret_cast(XDR_FLOAT64); + case dods_byte_c: case dods_str_c: case dods_url_c: @@ -158,8 +160,7 @@ xdrproc_t XDRUtils::xdr_coder(const Type &t) { default: break; } - - return NULL; + A_Pop return nullptr; } } // namespace libdap diff --git a/diagnostic_suppression.h b/diagnostic_suppression.h new file mode 100644 index 000000000..1782bb3ec --- /dev/null +++ b/diagnostic_suppression.h @@ -0,0 +1,25 @@ +// +// Created by James Gallagher on 1/26/26. +// + +#ifndef LIBDAP_DIAGNOSTIC_SUPPRESSION_H +#define LIBDAP_DIAGNOSTIC_SUPPRESSION_H + +// Define a macro for convenience. To keep things simple, use a macro for +// each kind of warning. There should be few uses of this. jhrg 1/26/26 + +#ifdef __GNUC__ + +#define A_cast_function_type_mismatch \ + _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wcast-function-type-mismatch\"") + +#define A_Pop _Pragma("GCC diagnostic pop") + +#else +// Define them empty for other compilers (e.g., MSVC) if needed + +#define A_IgnoreUnused +#define A_Pop +#endif + +#endif // LIBDAP_DIAGNOSTIC_SUPPRESSION_H From e20850132e233c7bd4afae80da29d42b033a5101 Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Mon, 26 Jan 2026 15:12:20 -0700 Subject: [PATCH 07/11] Added reference for the warning suppression macro --- diagnostic_suppression.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/diagnostic_suppression.h b/diagnostic_suppression.h index 1782bb3ec..1c7a31dc9 100644 --- a/diagnostic_suppression.h +++ b/diagnostic_suppression.h @@ -7,6 +7,8 @@ // Define a macro for convenience. To keep things simple, use a macro for // each kind of warning. There should be few uses of this. jhrg 1/26/26 +// +// Based on https://nelkinda.com/blog/suppress-warnings-in-gcc-and-clang/ #ifdef __GNUC__ From f386c2a7e9062310a2fa4373a475027b19107927 Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Mon, 26 Jan 2026 16:39:16 -0700 Subject: [PATCH 08/11] Reinstate --- unit-tests/marshT.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/unit-tests/marshT.cc b/unit-tests/marshT.cc index 4bbcdd24d..408512673 100644 --- a/unit-tests/marshT.cc +++ b/unit-tests/marshT.cc @@ -1,14 +1,11 @@ -#include -#include -#include -#include - #include "config.h" + #ifdef HAVE_UNISTD_H #include #endif +#include #include #include @@ -31,6 +28,11 @@ #include "XDRFileUnMarshaller.h" #include "XDRStreamMarshaller.h" +#include +#include +#include +#include + #include "run_tests_cppunit.h" using std::cerr; From a3c6df75deb7e79f0cfab5ae75dcfac332ceb426 Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Tue, 27 Jan 2026 09:14:13 -0700 Subject: [PATCH 09/11] Reinstate in RCReaderTest --- unit-tests/RCReaderTest.cc | 1 + unit-tests/marshT.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/unit-tests/RCReaderTest.cc b/unit-tests/RCReaderTest.cc index 63051e07c..755cc7bd4 100644 --- a/unit-tests/RCReaderTest.cc +++ b/unit-tests/RCReaderTest.cc @@ -30,6 +30,7 @@ #include #endif +#include // Needed for Linux #include #include #include diff --git a/unit-tests/marshT.cc b/unit-tests/marshT.cc index 408512673..3a9614b7b 100644 --- a/unit-tests/marshT.cc +++ b/unit-tests/marshT.cc @@ -5,7 +5,7 @@ #include #endif -#include +#include // Needed for Linux #include #include From 03a2f95d45a0900df9c2902d52c0915ff43ee907 Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Tue, 27 Jan 2026 09:18:13 -0700 Subject: [PATCH 10/11] Reinstate in MarshallerTest --- unit-tests/MarshallerTest.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/unit-tests/MarshallerTest.cc b/unit-tests/MarshallerTest.cc index 7a257f11d..1946b7dd8 100644 --- a/unit-tests/MarshallerTest.cc +++ b/unit-tests/MarshallerTest.cc @@ -1,18 +1,19 @@ #include "config.h" -#include -#include -#include -#include - #ifdef HAVE_UNISTD_H #include #endif +#include // Needed for Linux #include #include +#include +#include +#include +#include + #include "TestArray.h" #include "TestByte.h" #include "TestFloat32.h" From ad4f7d43399c231adacfe7aec44011a0d7986897 Mon Sep 17 00:00:00 2001 From: James Gallagher Date: Tue, 27 Jan 2026 10:48:37 -0700 Subject: [PATCH 11/11] Added diagnostic_suppression.h to Makefile.am for distcheck --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 505889977..8fcb6bc3d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -202,7 +202,7 @@ DAP_HDR = AttrTable.h DAS.h DDS.h DataDDS.h DDXParserSAX2.h \ Grid.h UInt32.h Int16.h UInt16.h Float32.h BaseTypeFactory.h \ ObjectType.h EncodingType.h SignalHandler.h Error.h \ InternalErr.h util.h escaping.h parser.h debug.h dods-limits.h \ - dods-datatypes.h Type.h \ + dods-datatypes.h Type.h diagnostic_suppression.h \ util_mit.h expr.h Clause.h RValue.h ConstraintEvaluator.h \ ce_parser.h DapIndent.h DapObj.h XDRFileMarshaller.h \ Marshaller.h UnMarshaller.h XDRFileUnMarshaller.h \