diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml old mode 100644 new mode 100755 index 89ef5b9..b6ca960 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@v4 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: cpp config-file: ./.github/codeql/codeql-config.yml @@ -31,7 +31,7 @@ jobs: ./tests/codeql/test_compilers_c++17.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:cpp" upload: False @@ -48,7 +48,7 @@ jobs: # output: sarif-results/${{matrix.language}}.sarif - name: Upload results - uses: github/codeql-action/upload-sarif@v2 + uses: github/codeql-action/upload-sarif@v3 with: sarif_file: sarif-results/cpp.sarif @@ -65,22 +65,22 @@ jobs: uses: actions/checkout@v4 - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: python config-file: ./.github/codeql/codeql-config.yml - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 with: category: "/language:python" upload: False output: sarif-results - name: Upload results - uses: github/codeql-action/upload-sarif@v2 + uses: github/codeql-action/upload-sarif@v3 with: sarif_file: sarif-results/python.sarif diff --git a/src/fcelib/fcelib_fcetypes.h b/src/fcelib/fcelib_fcetypes.h index 404ed5c..be3fc78 100644 --- a/src/fcelib/fcelib_fcetypes.h +++ b/src/fcelib/fcelib_fcetypes.h @@ -233,7 +233,7 @@ struct FceHeader3 { }; static -const char *kFce3PartsNames[kFceLibImplementedFce3Parts] = { +const char *kFce3PartsNames[FCELIB_UTIL_Fce3PartsImplemented] = { "high body", /* car.fce */ "left front wheel", "right front wheel", @@ -351,7 +351,7 @@ struct FceHeader4 { }; static -const char *kFce4HiBodyParts[kFceLibNumFce4HiBodyParts] = { +const char *kFce4HiBodyParts[FCELIB_UTIL_Fce4PartsHighBody] = { ":HB", /* car.fce */ ":OT", ":OL", @@ -1626,7 +1626,7 @@ void FCELIB_FCETYPES_PrintHeaderFce3(const void *header, const int fce_size) printf("Parts:\n" "Idx Verts Triags (PartPos) Description Name\n"); - for (i = 0; i < FCELIB_UTIL_Min(kFceLibImplementedFce3Parts, hdr.NumParts); ++i) + for (i = 0; i < FCELIB_UTIL_Min(FCELIB_UTIL_Fce3PartsImplemented, hdr.NumParts); ++i) { printf(" %2d %5d %5d %5d %5d (%9f, %9f, %9f) %20s %s\n", i, @@ -1641,7 +1641,7 @@ void FCELIB_FCETYPES_PrintHeaderFce3(const void *header, const int fce_size) verts += hdr.PNumVertices[i]; triags += hdr.PNumTriangles[i]; } - for (i = FCELIB_UTIL_Min(kFceLibImplementedFce3Parts, hdr.NumParts); i < FCELIB_UTIL_Min(64, hdr.NumParts); ++i) + for (i = FCELIB_UTIL_Min(FCELIB_UTIL_Fce3PartsImplemented, hdr.NumParts); i < FCELIB_UTIL_Min(64, hdr.NumParts); ++i) { printf(" %2d %5d %5d %5d %5d (%9f, %9f, %9f) %20s %s\n", i, diff --git a/src/fcelib/fcelib_types.h b/src/fcelib/fcelib_types.h index 5b9b278..fd00ab6 100644 --- a/src/fcelib/fcelib_types.h +++ b/src/fcelib/fcelib_types.h @@ -27,8 +27,6 @@ added at the end. Many operations are carried out on index arrays. - Array elements (parts, triags, verts) are accessed in constant time at first. - Once an index array has been flagged as dirty, access is of linear complexity. **/ #ifndef FCELIB_TYPES_H_ @@ -119,7 +117,11 @@ struct FcelibMesh { FcelibTriangle **triangles; /* may contain NULL elements */ FcelibVertex **vertices; /* may contain NULL elements */ +#ifdef __cplusplus + void (*release)(struct FcelibMesh*) = NULL; +#else void (*release)(struct FcelibMesh*); +#endif }; #ifdef __cplusplus @@ -187,13 +189,15 @@ void FCELIB_TYPES_FreeMesh(FcelibMesh *mesh) FcelibMesh *FCELIB_TYPES_InitMesh(FcelibMesh *mesh) { #ifndef FCELIB_PYTHON_BINDINGS -#ifdef __cplusplus - if (mesh->release == &FCELIB_TYPES_FreeMesh) + if (mesh->release && mesh->release == &FCELIB_TYPES_FreeMesh) mesh->release(mesh); -#endif #endif +#ifdef __cplusplus + *mesh = {}; +#else memset(mesh, 0, sizeof(*mesh)); +#endif mesh->hdr.NumArts = 1; mesh->release = &FCELIB_TYPES_FreeMesh; return mesh; @@ -799,7 +803,7 @@ void FCELIB_TYPES_PrintMeshInfo(const FcelibMesh *mesh) mesh->parts[mesh->hdr.Parts[i]]->PNumVertices, mesh->parts[mesh->hdr.Parts[i]]->PNumTriangles, mesh->parts[mesh->hdr.Parts[i]]->PartPos.x, mesh->parts[mesh->hdr.Parts[i]]->PartPos.y, mesh->parts[mesh->hdr.Parts[i]]->PartPos.z, - j < kFceLibImplementedFce3Parts ? kFce3PartsNames[j] : "", + j < FCELIB_UTIL_Fce3PartsImplemented ? kFce3PartsNames[j] : "", mesh->parts[mesh->hdr.Parts[i]]->PartName); verts += mesh->parts[mesh->hdr.Parts[i]]->PNumVertices; diff --git a/src/fcelib/fcelib_util.h b/src/fcelib/fcelib_util.h index 063489c..b192204 100644 --- a/src/fcelib/fcelib_util.h +++ b/src/fcelib/fcelib_util.h @@ -26,8 +26,8 @@ #include #include -#define kFceLibImplementedFce3Parts 13 -#define kFceLibNumFce4HiBodyParts 18 +#define FCELIB_UTIL_Fce3PartsImplemented 13 +#define FCELIB_UTIL_Fce4PartsHighBody 18 /* Represent FCE dummies (light/fx objects) Mainly used for OBJ output, hence kTrianglesDiamond has 1-based indexes. */ @@ -115,7 +115,7 @@ int FCELIB_UTIL_StrIsInArray(char *str, const char **arr) { int retv = 0; int i; - for (i = 0; i < kFceLibNumFce4HiBodyParts; ++i) + for (i = 0; i < FCELIB_UTIL_Fce4PartsHighBody; ++i) { if (strncmp(str, arr[i], 64) == 0) { diff --git a/tests/codeql/test_compilers_c++17.sh b/tests/codeql/test_compilers_c++17.sh index 1233460..6633b3c 100755 --- a/tests/codeql/test_compilers_c++17.sh +++ b/tests/codeql/test_compilers_c++17.sh @@ -15,8 +15,8 @@ DEST="fcec-OpAddHelperPart${VERSION}" # compiler-specific MINGWFLAGS="-fPIE -s -O2 -Xlinker --no-insert-timestamp" # -fstack-clash-protection -Wl,-pie -GCCFLAGS="-fPIE -pie -fstack-clash-protection -fstack-protector-strong -D_FORTIFY_SOURCE=2 -s -O2" -CPPFLAGS="-D_GLIBCXX_ASSERTIONS -fPIE -pie -fstack-clash-protection -fstack-protector-strong -D_FORTIFY_SOURCE=2 -s -O2" +GCCFLAGS="-fPIE -pie -fstack-clash-protection -fstack-protector-strong -D_FORTIFY_SOURCE=2" # -s -O2 +CPPFLAGS="-D_GLIBCXX_ASSERTIONS -fPIE -pie -fstack-clash-protection -fstack-protector-strong -D_FORTIFY_SOURCE=2" # -s -O2 # debug GCCDEBUGFLAGS="-pedantic-errors -g -Wall -Wextra -Wstack-protector -fasynchronous-unwind-tables" # -fsanitize=leak