From 6f47e72b2fdc6493effa5c99b8238b4b13c56618 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 15 May 2024 13:39:43 -0600 Subject: [PATCH] EXODUS: Fix some compiler warnings; see if that makes test run... --- .../exodus/test/testrd-field-metadata.c | 35 +++++++++++++++---- .../exodus/test/testwt-field-metadata.c | 1 + 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/packages/seacas/libraries/exodus/test/testrd-field-metadata.c b/packages/seacas/libraries/exodus/test/testrd-field-metadata.c index 80f23aea86..e268f12a0c 100644 --- a/packages/seacas/libraries/exodus/test/testrd-field-metadata.c +++ b/packages/seacas/libraries/exodus/test/testrd-field-metadata.c @@ -5,16 +5,28 @@ * * See packages/seacas/LICENSE for details */ +#undef NDEBUG #include "exodusII.h" #include #include #include -#define _GNU_SOURCE #include #define STRINGIFY(x) #x #define TOSTRING(x) STRINGIFY(x) +char *my_strdup(const char *s) +{ + size_t slen = strlen(s); + char *result = malloc(slen + 1); + if (result == NULL) { + return NULL; + } + + memcpy(result, s, slen + 1); + return result; +} + char *my_strsep(char **stringp, const char *delim) { assert(delim != NULL); @@ -45,7 +57,7 @@ char *my_strsep(char **stringp, const char *delim) static char *get_type_name(char *type_name, size_t which) { if (type_name != NULL && type_name[0] != '\0') { - char *string = strdup(type_name); + char *string = my_strdup(type_name); char *tofree = string; char *token = my_strsep(&string, ","); for (int i = 0; i < which; i++) { @@ -162,16 +174,20 @@ static void print_field_metadata(ex_field *field) static void print_full_field_names(ex_field *field) { + int component[EX_MAX_FIELD_NESTING]; if (field->nesting == 1) { for (int jj = 1; jj <= field->cardinality[0]; jj++) { - const char *name = ex_component_field_name(field, (int[]){jj}); + component[0] = jj; + const char *name = ex_component_field_name(field, component); printf("\t\tComponent %d, Full name = %s\n", jj, name); } } else if (field->nesting == 2) { for (int kk = 1; kk <= field->cardinality[1]; kk++) { for (int jj = 1; jj <= field->cardinality[0]; jj++) { - const char *name = ex_component_field_name(field, (int[]){jj, kk}); + component[0] = jj; + component[1] = kk; + const char *name = ex_component_field_name(field, component); printf("\t\tComponent %d %d, Full name = %s\n", jj, kk, name); } } @@ -180,7 +196,10 @@ static void print_full_field_names(ex_field *field) for (int ii = 1; ii <= field->cardinality[2]; ii++) { for (int kk = 1; kk <= field->cardinality[1]; kk++) { for (int jj = 1; jj <= field->cardinality[0]; jj++) { - const char *name = ex_component_field_name(field, (int[]){jj, kk, ii}); + component[0] = jj; + component[1] = kk; + component[2] = ii; + const char *name = ex_component_field_name(field, component); printf("\t\tComponent %d %d %d, Full name = %s\n", jj, kk, ii, name); } } @@ -191,7 +210,11 @@ static void print_full_field_names(ex_field *field) for (int ii = 1; ii <= field->cardinality[2]; ii++) { for (int kk = 1; kk <= field->cardinality[1]; kk++) { for (int jj = 1; jj <= field->cardinality[0]; jj++) { - const char *name = ex_component_field_name(field, (int[]){jj, kk, ii, mm}); + component[0] = jj; + component[1] = kk; + component[2] = ii; + component[3] = mm; + const char *name = ex_component_field_name(field, component); printf("\t\tComponent %d %d %d %d, Full name = %s\n", jj, kk, ii, mm, name); } } diff --git a/packages/seacas/libraries/exodus/test/testwt-field-metadata.c b/packages/seacas/libraries/exodus/test/testwt-field-metadata.c index a37e5d907e..b08d89420b 100644 --- a/packages/seacas/libraries/exodus/test/testwt-field-metadata.c +++ b/packages/seacas/libraries/exodus/test/testwt-field-metadata.c @@ -6,6 +6,7 @@ * See packages/seacas/LICENSE for details */ +#undef NDEBUG #include #include #include