Skip to content

Commit 0414a02

Browse files
authored
Merge pull request #1961 from CEED/jeremy/fortran-string-bug
Clang-Tidy in CI Fix
2 parents 2986ee2 + 79eb6d2 commit 0414a02

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

.gitlab-ci.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ noether-asan:
4848
- make -k -j$((NPROC_CPU / NPROC_POOL)) BACKENDS="$BACKENDS_CPU" JUNIT_BATCH="memcheck" junit realsearch=%
4949
# Clang-tidy
5050
- echo "-------------- clang-tidy ----------" && clang-tidy --version
51-
- TIDY_OPTS="-fix-errors" make -j$NPROC_CPU tidy && git diff --color=always --exit-code
51+
- TIDY_OPTS="-fix-errors -warnings-as-errors=" make -j$NPROC_CPU tidy
5252
# Report status
5353
- touch .SUCCESS
5454
artifacts:
@@ -284,7 +284,7 @@ noether-cuda:
284284
- make -k -j$((NPROC_GPU / NPROC_POOL)) BACKENDS="$BACKENDS_GPU" JUNIT_BATCH="cuda" junit search=dealii DEAL_II_DIR=$DEAL_II_DIR
285285
# Clang-tidy
286286
- echo "-------------- clang-tidy ----------" && clang-tidy --version
287-
- TIDY_OPTS="-fix-errors" make -j$NPROC_CPU tidy && git diff --color=always --exit-code
287+
- TIDY_OPTS="-fix-errors -warnings-as-errors=" make -j$NPROC_CPU tidy
288288
# Report status
289289
- touch .SUCCESS
290290
after_script:
@@ -351,7 +351,7 @@ noether-cuda:
351351
# - make -k -j$((NPROC_GPU / NPROC_POOL)) BACKENDS="$BACKENDS_GPU" JUNIT_BATCH="hip" junit search="petsc fluids solids"
352352
# # Clang-tidy
353353
# - echo "-------------- clang-tidy ----------" && clang-tidy --version
354-
# - TIDY_OPTS="-fix-errors" make -j$NPROC_CPU tidy && git diff --color=always --exit-code
354+
# - TIDY_OPTS="-fix-errors -warnings-as-errors=" make -j$NPROC_CPU tidy
355355
# # Report status
356356
# - touch .SUCCESS
357357
# after_script:
@@ -402,7 +402,7 @@ noether-rocm:
402402
- make -j$NPROC_CPU
403403
# Clang-tidy
404404
- echo "-------------- clang-tidy ----------" && clang-tidy --version
405-
- TIDY_OPTS="-fix-errors" make -j$NPROC_CPU tidy && git diff --color=always --exit-code
405+
- TIDY_OPTS="-fix-errors -warnings-as-errors=" make -j$NPROC_CPU tidy
406406
# Report status
407407
- touch .SUCCESS
408408

interface/ceed-fortran.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ typedef size_t fortran_charlen_t;
4141
typedef int fortran_charlen_t;
4242
#endif
4343

44-
#define Splice(a, b) a##b
45-
4644
// Fortran strings are generally unterminated and the length is passed as an
4745
// extra argument after all the normal arguments. Some compilers (I only know
4846
// of Windows) place the length argument immediately after the string parameter
@@ -51,11 +49,13 @@ typedef int fortran_charlen_t;
5149
// We can't just NULL-terminate the string in-place because that could overwrite
5250
// other strings or attempt to write to read-only memory. This macro allocates
5351
// a string to hold the null-terminated version of the string that C expects.
54-
#define FIX_STRING(stringname) \
55-
char Splice(stringname, _c)[1024]; \
56-
if (Splice(stringname, _len) > 1023) *err = CeedError(NULL, 1, "Fortran string length too long %zd", (size_t)Splice(stringname, _len)); \
57-
strncpy(Splice(stringname, _c), stringname, Splice(stringname, _len)); \
58-
Splice(stringname, _c)[Splice(stringname, _len)] = 0;
52+
#define CEED_MAX_FORTRAN_STRING_LEN 1024
53+
#define FIX_STRING(stringname) \
54+
char stringname##_c[CEED_MAX_FORTRAN_STRING_LEN] = {'\0'}; \
55+
if (stringname##_len > CEED_MAX_FORTRAN_STRING_LEN - 1) { \
56+
*err = CeedError(NULL, 1, "Fortran string too long: %zd", (size_t)(stringname##_len)); \
57+
} \
58+
strncpy(stringname##_c, stringname, CeedIntMin(stringname##_len, CEED_MAX_FORTRAN_STRING_LEN - 1));
5959

6060
// -----------------------------------------------------------------------------
6161
// Ceed

0 commit comments

Comments
 (0)