From fc418cc7825b75bd1212a60001704d5cc8bab5f3 Mon Sep 17 00:00:00 2001 From: timoxd7 Date: Wed, 26 Mar 2025 13:35:33 +0100 Subject: [PATCH 1/2] fix(nvs_flash): removed usage of 'using namepsace std' in a header file --- components/nvs_flash/src/nvs_cxx_api.cpp | 2 ++ components/nvs_flash/src/nvs_pagemanager.cpp | 2 ++ components/nvs_flash/src/nvs_partition_manager.cpp | 2 ++ components/nvs_flash/src/nvs_types.hpp | 4 +--- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/nvs_flash/src/nvs_cxx_api.cpp b/components/nvs_flash/src/nvs_cxx_api.cpp index b315fecdf1..09d76dffbe 100644 --- a/components/nvs_flash/src/nvs_cxx_api.cpp +++ b/components/nvs_flash/src/nvs_cxx_api.cpp @@ -17,6 +17,8 @@ #include "nvs_handle_locked.hpp" #include "nvs_platform.hpp" +using namespace std; + namespace nvs { std::unique_ptr open_nvs_handle_from_partition(const char *partition_name, diff --git a/components/nvs_flash/src/nvs_pagemanager.cpp b/components/nvs_flash/src/nvs_pagemanager.cpp index 9bbe32c98a..5b5dbe21f5 100644 --- a/components/nvs_flash/src/nvs_pagemanager.cpp +++ b/components/nvs_flash/src/nvs_pagemanager.cpp @@ -5,6 +5,8 @@ */ #include "nvs_pagemanager.hpp" +using namespace std; + namespace nvs { esp_err_t PageManager::load(Partition *partition, uint32_t baseSector, uint32_t sectorCount) diff --git a/components/nvs_flash/src/nvs_partition_manager.cpp b/components/nvs_flash/src/nvs_partition_manager.cpp index f267aa668f..8a7e0c6ed0 100644 --- a/components/nvs_flash/src/nvs_partition_manager.cpp +++ b/components/nvs_flash/src/nvs_partition_manager.cpp @@ -12,6 +12,8 @@ #include "nvs_encrypted_partition.hpp" #endif // ! LINUX_TARGET +using namespace std; + namespace nvs { NVSPartitionManager* NVSPartitionManager::instance = nullptr; diff --git a/components/nvs_flash/src/nvs_types.hpp b/components/nvs_flash/src/nvs_types.hpp index 5eda9abcd9..1761fa0354 100644 --- a/components/nvs_flash/src/nvs_types.hpp +++ b/components/nvs_flash/src/nvs_types.hpp @@ -15,8 +15,6 @@ #include "compressed_enum_table.hpp" #include "string.h" -using namespace std; - namespace nvs { @@ -97,7 +95,7 @@ public: void getKey(char* dst, size_t dstSize) { - strncpy(dst, key, min(dstSize, sizeof(key))); + strncpy(dst, key, std::min(dstSize, sizeof(key))); dst[dstSize-1] = 0; } From be6e24370fff08bc3e02c4c1037fcc389f648ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Rohl=C3=ADnek?= Date: Thu, 27 Mar 2025 15:11:06 +0100 Subject: [PATCH 2/2] fix(storage/nvf_flash): fixup additions from PR --- .../host_test/nvs_host_test/main/test_nvs.cpp | 2 ++ .../nvs_host_test/main/test_nvs_cxx_api.cpp | 2 ++ .../nvs_host_test/main/test_nvs_handle.cpp | 2 ++ .../main/test_nvs_initialization.cpp | 2 ++ .../nvs_host_test/main/test_nvs_storage.cpp | 2 ++ .../main/test_partition_manager.cpp | 2 ++ components/nvs_flash/src/nvs_cxx_api.cpp | 18 +++++------------- tools/ci/check_copyright_ignore.txt | 1 - 8 files changed, 17 insertions(+), 14 deletions(-) diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp index 431e889203..9792238c33 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs.cpp @@ -20,6 +20,8 @@ #include "test_fixtures.hpp" #include "spi_flash_mmap.h" +using namespace std; + #define TEST_ESP_ERR(rc, res) CHECK((rc) == (res)) #define TEST_ESP_OK(rc) CHECK((rc) == ESP_OK) diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_cxx_api.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_cxx_api.cpp index d4ebef3a35..e8a4539698 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_cxx_api.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_cxx_api.cpp @@ -11,6 +11,8 @@ #include "test_fixtures.hpp" #include +using namespace std; + TEST_CASE("NVSHandleSimple CXX api open invalid arguments", "[nvs cxx]") { const uint32_t NVS_FLASH_SECTOR = 6; diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_handle.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_handle.cpp index dae567d446..be08abe12f 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_handle.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_handle.cpp @@ -12,6 +12,8 @@ #include #include +using namespace std; + #define TEMPORARILY_DISABLED(x) TEST_CASE("NVSHandleSimple closes its reference in PartitionManager", "[partition_mgr]") diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_initialization.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_initialization.cpp index 5250f8cde7..1d06c5b7a5 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_initialization.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_initialization.cpp @@ -11,6 +11,8 @@ #include #include "esp_partition.h" +using namespace std; + TEST_CASE("nvs_flash_init_partition_ptr fails due to nullptr arg", "[nvs_custom_part]") { uint8_t *p_part_desc_addr_start; diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_storage.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_storage.cpp index 769c661260..977ba13f0b 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_storage.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_nvs_storage.cpp @@ -10,6 +10,8 @@ #include "test_fixtures.hpp" #include +using namespace std; + TEST_CASE("Storage iterator recognizes blob with VerOffset::VER_1_OFFSET", "[nvs_storage]") { const uint32_t NVS_FLASH_SECTOR = 6; diff --git a/components/nvs_flash/host_test/nvs_host_test/main/test_partition_manager.cpp b/components/nvs_flash/host_test/nvs_host_test/main/test_partition_manager.cpp index 4c995eaeec..aa825d71b5 100644 --- a/components/nvs_flash/host_test/nvs_host_test/main/test_partition_manager.cpp +++ b/components/nvs_flash/host_test/nvs_host_test/main/test_partition_manager.cpp @@ -11,6 +11,8 @@ #include "nvs_test_api.h" #include "test_fixtures.hpp" +using namespace std; + TEST_CASE("Partition manager initializes storage", "[partition_mgr]") { const uint32_t NVS_FLASH_SECTOR = 6; diff --git a/components/nvs_flash/src/nvs_cxx_api.cpp b/components/nvs_flash/src/nvs_cxx_api.cpp index 09d76dffbe..ed4b128d44 100644 --- a/components/nvs_flash/src/nvs_cxx_api.cpp +++ b/components/nvs_flash/src/nvs_cxx_api.cpp @@ -1,16 +1,8 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "nvs_partition_manager.hpp" #include "nvs_handle.hpp" #include "nvs_handle_simple.hpp" diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index d509047b3c..d422dc84f8 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -486,7 +486,6 @@ components/mbedtls/port/include/sha256_alt.h components/mbedtls/port/include/sha512_alt.h components/mbedtls/port/sha/parallel_engine/sha.c components/nvs_flash/include/nvs_handle.hpp -components/nvs_flash/src/nvs_cxx_api.cpp components/nvs_flash/src/nvs_encrypted_partition.hpp components/nvs_flash/src/nvs_item_hash_list.cpp components/nvs_flash/src/nvs_pagemanager.hpp