From 011382424b9bea9984f294a2cf7ec43f378c4e6c Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Fri, 3 Mar 2023 19:31:50 +0100 Subject: [PATCH 1/7] remove debug message from MemoryIOStream (used by public Importer::ReadFileFromMemory method) --- include/assimp/MemoryIOWrapper.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/assimp/MemoryIOWrapper.h b/include/assimp/MemoryIOWrapper.h index 77071e96f..1b986ff1b 100644 --- a/include/assimp/MemoryIOWrapper.h +++ b/include/assimp/MemoryIOWrapper.h @@ -150,7 +150,6 @@ public: // ------------------------------------------------------------------- /// @brief Tests for the existence of a file at the given path. bool Exists(const char* pFile) const override { - printf("Exists\n"); if (0 == strncmp( pFile, AI_MEMORYIO_MAGIC_FILENAME, AI_MEMORYIO_MAGIC_FILENAME_LENGTH ) ) { return true; } From 74c406dd262e3c92229760683ce814d12116ada5 Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Sat, 4 Mar 2023 14:27:58 +0100 Subject: [PATCH 2/7] add ci script to scan for unexpected printf statements --- .github/workflows/sanitizer.yml | 10 ++++++++++ scripts/scan_printf.sh | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100755 scripts/scan_printf.sh diff --git a/.github/workflows/sanitizer.yml b/.github/workflows/sanitizer.yml index 57d6e78f1..b23f4520f 100644 --- a/.github/workflows/sanitizer.yml +++ b/.github/workflows/sanitizer.yml @@ -57,3 +57,13 @@ jobs: - name: test run: cd build/bin && ./unit shell: bash + + job3: + name: printf-sanitizer + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: run scan_printf script + run: ./scripts/scan_printf.sh + shell: bash diff --git a/scripts/scan_printf.sh b/scripts/scan_printf.sh new file mode 100755 index 000000000..b507e6438 --- /dev/null +++ b/scripts/scan_printf.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +PATHS="include code" +FILTER_INCLUDE='\*.{c,cpp,h}' +FILTER_EXCLUDE="{include/assimp/Compiler/pstdint.h,code/AssetLib/M3D/m3d.h}" + +PATTERN='^\s*printf' + +grep \ + --include=\*.{c,cpp,h} \ + --exclude={include/assimp/Compiler/pstdint.h,code/AssetLib/M3D/m3d.h} \ + -rnw include code \ + -e '^\s*printf' + +if [ $? ] +then + echo "Debug statement(s) detected. Please remove, or manually add to exclude filter, if appropriate" + exit 1 +fi + From 1520aff68027047d3c86d64c26f6ee3148af3423 Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Sat, 4 Mar 2023 14:41:10 +0100 Subject: [PATCH 3/7] fix scan_printf script in linux bash --- scripts/scan_printf.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/scan_printf.sh b/scripts/scan_printf.sh index b507e6438..90ab7c870 100755 --- a/scripts/scan_printf.sh +++ b/scripts/scan_printf.sh @@ -1,14 +1,8 @@ -#!/bin/sh - -PATHS="include code" -FILTER_INCLUDE='\*.{c,cpp,h}' -FILTER_EXCLUDE="{include/assimp/Compiler/pstdint.h,code/AssetLib/M3D/m3d.h}" - -PATTERN='^\s*printf' +#!/bin/bash grep \ --include=\*.{c,cpp,h} \ - --exclude={include/assimp/Compiler/pstdint.h,code/AssetLib/M3D/m3d.h} \ + --exclude={pstdint,m3d}.h \ -rnw include code \ -e '^\s*printf' From 4fa433c8ff9839ac466c4c4bb333d7113db33d78 Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Sat, 4 Mar 2023 14:52:49 +0100 Subject: [PATCH 4/7] improve scan_printf ci script error message --- scripts/scan_printf.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scan_printf.sh b/scripts/scan_printf.sh index 90ab7c870..a71fab756 100755 --- a/scripts/scan_printf.sh +++ b/scripts/scan_printf.sh @@ -8,7 +8,7 @@ grep \ if [ $? ] then - echo "Debug statement(s) detected. Please remove, or manually add to exclude filter, if appropriate" + echo "Debug statement(s) detected. Please uncomment (using single-line comment), remove, or manually add to exclude filter, if appropriate" exit 1 fi From 2efd48dee2208a255ca4bfa3a821bfd3615e6924 Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Sat, 4 Mar 2023 14:53:48 +0100 Subject: [PATCH 5/7] disable another debug print message --- code/AssetLib/Ogre/OgreXmlSerializer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/Ogre/OgreXmlSerializer.cpp b/code/AssetLib/Ogre/OgreXmlSerializer.cpp index cd9d6dcc2..623f2961e 100644 --- a/code/AssetLib/Ogre/OgreXmlSerializer.cpp +++ b/code/AssetLib/Ogre/OgreXmlSerializer.cpp @@ -490,7 +490,7 @@ bool OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *me OgreXmlSerializer serializer(xmlParser.get()); XmlNode root = xmlParser->getRootNode(); if (std::string(root.name()) != nnSkeleton) { - printf("\nSkeleton is not a valid root: %s\n", root.name()); + // printf("\nSkeleton is not a valid root: %s\n", root.name()); for (auto &a : root.children()) { if (std::string(a.name()) == nnSkeleton) { root = a; From dcb89cf1070ed8cc7676f8f00cf8951906d5b2b6 Mon Sep 17 00:00:00 2001 From: Urs Hanselmann Date: Sat, 4 Mar 2023 15:00:43 +0100 Subject: [PATCH 6/7] fix scan_printf script error code handling --- scripts/scan_printf.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/scan_printf.sh b/scripts/scan_printf.sh index a71fab756..f8c902941 100755 --- a/scripts/scan_printf.sh +++ b/scripts/scan_printf.sh @@ -6,8 +6,7 @@ grep \ -rnw include code \ -e '^\s*printf' -if [ $? ] -then +if [ $? -eq 0 ]; then echo "Debug statement(s) detected. Please uncomment (using single-line comment), remove, or manually add to exclude filter, if appropriate" exit 1 fi From 44c2785663d38f79614138bfa87d91d0b0ad69c7 Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Tue, 7 Mar 2023 17:01:08 +0100 Subject: [PATCH 7/7] Make debug message more professional. --- code/AssetLib/Ogre/OgreXmlSerializer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/AssetLib/Ogre/OgreXmlSerializer.cpp b/code/AssetLib/Ogre/OgreXmlSerializer.cpp index 623f2961e..a8faaec34 100644 --- a/code/AssetLib/Ogre/OgreXmlSerializer.cpp +++ b/code/AssetLib/Ogre/OgreXmlSerializer.cpp @@ -490,7 +490,7 @@ bool OgreXmlSerializer::ImportSkeleton(Assimp::IOSystem *pIOHandler, MeshXml *me OgreXmlSerializer serializer(xmlParser.get()); XmlNode root = xmlParser->getRootNode(); if (std::string(root.name()) != nnSkeleton) { - // printf("\nSkeleton is not a valid root: %s\n", root.name()); + ASSIMP_LOG_VERBOSE_DEBUG("nSkeleton is not a valid root: ", root.name(), "."); for (auto &a : root.children()) { if (std::string(a.name()) == nnSkeleton) { root = a;