diff --git a/.lintrunner.toml b/.lintrunner.toml index 4b27e2583bd..4e2db413bee 100644 --- a/.lintrunner.toml +++ b/.lintrunner.toml @@ -744,6 +744,11 @@ is_formatter = true [[linter]] code = 'CPP_BANNED_FUNCTIONS' include_patterns = [ + 'backends/arm/**/*.c', + 'backends/arm/**/*.cc', + 'backends/arm/**/*.cpp', + 'backends/arm/**/*.h', + 'backends/arm/**/*.hpp', 'examples/arm/**/*.c', 'examples/arm/**/*.cc', 'examples/arm/**/*.cpp', diff --git a/backends/arm/runtime/EthosUBackend_Cortex_A.cpp b/backends/arm/runtime/EthosUBackend_Cortex_A.cpp index 5da0996fb19..af2328125af 100644 --- a/backends/arm/runtime/EthosUBackend_Cortex_A.cpp +++ b/backends/arm/runtime/EthosUBackend_Cortex_A.cpp @@ -323,6 +323,8 @@ Error invoke_linux_driver( } } // namespace +// Used by EthosUBackend.cpp through EthosUBackend_Internal.h. +// cppcheck-suppress unusedFunction PlatformState* platform_init( ArrayRef specs, MemoryAllocator* allocator) { @@ -335,10 +337,14 @@ PlatformState* platform_init( return state; } +// Used by EthosUBackend.cpp through EthosUBackend_Internal.h. +// cppcheck-suppress unusedFunction void platform_destroy(PlatformState* state) { delete state; } +// Used by EthosUBackend.cpp through EthosUBackend_Internal.h. +// cppcheck-suppress unusedFunction Error platform_execute( BackendExecutionContext& /*context*/, const ExecutionHandle* execution_handle, diff --git a/backends/arm/runtime/VGFBackend.cpp b/backends/arm/runtime/VGFBackend.cpp index ec44f348ce8..ffd2f03ee4b 100644 --- a/backends/arm/runtime/VGFBackend.cpp +++ b/backends/arm/runtime/VGFBackend.cpp @@ -1063,4 +1063,4 @@ VkResult vkml_allocate_basics( } // namespace vgf } // namespace backends -} // namespace executorch \ No newline at end of file +} // namespace executorch diff --git a/backends/arm/runtime/VGFNeuralStatistics.cpp b/backends/arm/runtime/VGFNeuralStatistics.cpp index 414eaa6f0f0..f99924ab227 100644 --- a/backends/arm/runtime/VGFNeuralStatistics.cpp +++ b/backends/arm/runtime/VGFNeuralStatistics.cpp @@ -489,6 +489,8 @@ std::string serialize_vgf_neural_statistics_collection( return out.str(); } +// Used by vgf_neural_statistics_test.cpp through VGFNeuralStatistics.h. +// cppcheck-suppress unusedFunction std::string make_vgf_neural_statistics_unavailable_metadata( const std::string& reason) { VgfNeuralStatisticsCollection collection; @@ -498,6 +500,8 @@ std::string make_vgf_neural_statistics_unavailable_metadata( return serialize_vgf_neural_statistics_collection(collection); } +// Used by VGFSetup.cpp and tests through VGFNeuralStatistics.h. +// cppcheck-suppress unusedFunction std::string collect_vgf_neural_statistics_metadata( VkDevice device, const std::vector& segments) { @@ -510,15 +514,19 @@ std::string collect_vgf_neural_statistics_metadata( collect_vgf_neural_statistics(device, segments)); } +// Used by vgf_neural_statistics_test.cpp through VGFNeuralStatistics.h. +// cppcheck-suppress unusedFunction void set_vgf_neural_statistics_collector_for_test( VgfNeuralStatisticsCollectorForTest collector) { test_collector_storage() = std::move(collector); } +// Used by vgf_neural_statistics_test.cpp through VGFNeuralStatistics.h. +// cppcheck-suppress unusedFunction void reset_vgf_neural_statistics_collector_for_test() { test_collector_storage() = nullptr; } } // namespace vgf } // namespace backends -} // namespace executorch \ No newline at end of file +} // namespace executorch diff --git a/backends/arm/scripts/banned_functions.json b/backends/arm/scripts/banned_functions.json index e906eef9030..5cadbbbe474 100644 --- a/backends/arm/scripts/banned_functions.json +++ b/backends/arm/scripts/banned_functions.json @@ -9,99 +9,45 @@ "replacements": ["fgets"] }, { - "names": ["memcpy"], - "replacements": ["memcpy_s"] + "names": ["atof"], + "replacements": ["strtod"] }, { - "names": ["wmemcpy"], - "replacements": ["wmemcpy_s"] + "names": ["atoi", "atol", "atoll"], + "replacements": ["strtol", "strtoll", "strtoul", "strtoull"] }, { - "names": ["memmove"], - "replacements": ["memmove_s"] + "names": ["rewind"], + "replacements": ["See SEI CERT MSC24-C: https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/recommendations/miscellaneous-msc/msc24-c/"] }, { - "names": ["wmemmove"], - "replacements": ["wmemmove_s"] + "names": ["setbuf"], + "replacements": ["setvbuf"] }, { "names": ["readdir_r"], "replacements": ["readdir"] }, - { - "names": ["scanf", "wscanf", "_tscanf", "sscanf", "swscanf", "_stscanf"], - "replacements": ["fgets"] - }, { "names": [ "strcat", - "wcscat", - "_tcscat", - "_mbscat", - "StrCat", - "lstrcat", - "lStrCatBuff", - "_tccat", - "_mbccat", - "_ftcscat", - "strncat", - "wcsncat", - "_tcsncat", - "_mbsncat", - "_mbsnbcat", - "StrCatN", - "StrNCat", - "lstrncat", - "lstrcatn" + "wcscat" ], - "replacements": ["strcat_s", "strncat_s"] + "replacements": ["See SEI CERT STR31-C: https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/characters-and-strings-str/str31-c/"] }, { "names": [ "strcpy", - "wcscpy", - "_tcscpy", - "_mbscpy", - "StrCpy", - "lstrcpy", - "_tccpy", - "_mbccpy", - "_ftcscpy", - "strncpy", - "wcsncpy", - "_tcsncpy", - "_mbsncpy", - "_mbsnbcpy", - "StrCpyN", - "StrNCpy", - "lstrcpyn" + "wcscpy" ], - "replacements": ["strcpy_s", "strncpy_s"] - }, - { - "names": ["strlen"], - "replacements": ["strnlen_s"] - }, - { - "names": ["wcslen"], - "replacements": ["wcsnlen_s"] - }, - { - "names": ["strtok", "_tcstok", "wcstok", "_mbstok"], - "replacements": ["strtok_s"] + "replacements": ["See SEI CERT STR31-C: https://cmu-sei.github.io/secure-coding-standards/sei-cert-c-coding-standard/rules/characters-and-strings-str/str31-c/"] }, { "names": [ - "wsprintf", "sprintf", - "swprintf", - "_stprintf", - "wvsprintf", - "vsprintf", - "_vstprintf", - "vswprintf" + "vsprintf" ], - "replacements": ["snprintf", "snprintf_s"] + "replacements": ["snprintf", "vsnprintf"] } ] } diff --git a/backends/arm/scripts/banned_functions.json.license b/backends/arm/scripts/banned_functions.json.license index 31207b7febd..74fec505a2d 100644 --- a/backends/arm/scripts/banned_functions.json.license +++ b/backends/arm/scripts/banned_functions.json.license @@ -1,5 +1,7 @@ SPDX-FileCopyrightText: Copyright 2026 Arm Limited and/or its affiliates SPDX-License-Identifier: MIT -File copied from https://github.com/justinchuby/lintrunner-adapters/ which has an MIT license. -File permalink: https://github.com/justinchuby/lintrunner-adapters/blob/772e5936d9b02814e29e12ca1355d33b029688c2/examples/adapters/cpp_banned_functions_linter/example_banned_functions.json +Derived from the MIT-licensed example at: +https://github.com/justinchuby/lintrunner-adapters/blob/772e5936d9b02814e29e12ca1355d33b029688c2/examples/adapters/cpp_banned_functions_linter/example_banned_functions.json + +Modified for the ExecuTorch Arm backend.