Skip to content

Commit 207199a

Browse files
committed
Merge branch 'refactor/nvs_header_cleanup' into 'master'
Cleanup of NVS copyright notices, header pragma once and NVS related constants See merge request espressif/esp-idf!42353
2 parents 69d2079 + 801091c commit 207199a

29 files changed

+92
-191
lines changed

components/nvs_flash/host_test/nvs_host_test/main/test_fixtures.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class PartitionEmulationFixture {
2929
esp_partition.erase_size = ESP_PARTITION_EMULATED_SECTOR_SIZE;
3030
esp_partition.type = ESP_PARTITION_TYPE_DATA;
3131
esp_partition.subtype = ESP_PARTITION_SUBTYPE_DATA_NVS;
32-
strncpy(esp_partition.label, partition_name, PART_NAME_MAX_SIZE);
32+
strncpy(esp_partition.label, partition_name, NVS_PART_NAME_MAX_SIZE);
3333
p_part = new (std::nothrow) nvs::NVSPartition(&esp_partition);
3434
REQUIRE(p_part != nullptr);
3535
}
@@ -186,7 +186,7 @@ class PartitionEmulationFixture2 : public PartitionEmulationFixture {
186186
esp_partition2.erase_size = ESP_PARTITION_EMULATED_SECTOR_SIZE;
187187
esp_partition2.type = ESP_PARTITION_TYPE_DATA;
188188
esp_partition2.subtype = ESP_PARTITION_SUBTYPE_DATA_NVS;
189-
strncpy(esp_partition2.label, partition_name2, PART_NAME_MAX_SIZE);
189+
strncpy(esp_partition2.label, partition_name2, NVS_PART_NAME_MAX_SIZE);
190190
p_part2 = new (std::nothrow) nvs::NVSPartition(&esp_partition2);
191191
REQUIRE(p_part2 != nullptr);
192192
}

components/nvs_flash/include/nvs.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
#ifndef ESP_NVS_H
7-
#define ESP_NVS_H
6+
#pragma once
87

98
#include <stdint.h>
109
#include <stddef.h>
@@ -802,5 +801,3 @@ void nvs_release_iterator(nvs_iterator_t iterator);
802801
#ifdef __cplusplus
803802
} // extern "C"
804803
#endif
805-
806-
#endif //ESP_NVS_H

components/nvs_flash/include/nvs_flash.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
#ifndef nvs_flash_h
7-
#define nvs_flash_h
6+
#pragma once
87

98
#ifdef __cplusplus
109
extern "C" {
@@ -325,6 +324,3 @@ esp_err_t nvs_flash_read_security_cfg_v2(nvs_sec_scheme_t *scheme_cfg, nvs_sec_c
325324
#ifdef __cplusplus
326325
}
327326
#endif
328-
329-
330-
#endif /* nvs_flash_h */

components/nvs_flash/include/nvs_handle.hpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
#ifndef NVS_HANDLE_HPP_
2-
#define NVS_HANDLE_HPP_
1+
/*
2+
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#pragma once
37

48
#include <string>
59
#include <memory>
@@ -307,5 +311,3 @@ esp_err_t NVSHandle::get_item(const char *key, T &value) {
307311
}
308312

309313
} // nvs
310-
311-
#endif // NVS_HANDLE_HPP_

components/nvs_flash/private_include/nvs_constants.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
#ifndef NVS_CONSTANTS_H
7-
#define NVS_CONSTANTS_H
8-
9-
#include "spi_flash_mmap.h" // for SPI_FLASH_SEC_SIZE
6+
#pragma once
107

118
// constants for the NVS to be used in the regular as well as bootloader implementations
129

@@ -18,7 +15,7 @@
1815
#define NVS_CONST_ESB_WRITTEN 0x1
1916
#define NVS_CONST_ESB_ERASED 0x2
2017

21-
#define NVS_CONST_PAGE_SIZE SPI_FLASH_SEC_SIZE
18+
#define NVS_CONST_PAGE_SIZE 4096 // Page size is by design assumed to be 4096 bytes
2219

2320
#define NVS_CONST_ENTRY_SIZE 32
2421
#define NVS_CONST_ENTRY_COUNT 126
@@ -32,6 +29,8 @@
3229

3330
#define NVS_CONST_NVS_VERSION 0xfe // Decrement to upgrade
3431

32+
#define NVS_ENCRYPT_BLOCK_SIZE 16 // Size of the encryption block in bytes
33+
3534
// Page States
3635
// All bits set, default state after flash erase. Page has not been initialized yet.
3736
#define NVS_CONST_PAGE_STATE_UNINITIALIZED 0xffffffff
@@ -64,5 +63,3 @@
6463
#define NVS_CONST_PAGE_HEADER_OFFSET 0
6564
#define NVS_CONST_PAGE_ENTRY_TABLE_OFFSET (NVS_CONST_PAGE_HEADER_OFFSET + 32)
6665
#define NVS_CONST_PAGE_ENTRY_DATA_OFFSET (NVS_CONST_PAGE_ENTRY_TABLE_OFFSET + 32)
67-
68-
#endif
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
#ifndef NVS_INTERNAL_H
7-
#define NVS_INTERNAL_H
6+
#pragma once
87

98
#if CONFIG_NVS_ASSERT_ERROR_CHECK
109
#define NVS_ASSERT_OR_RETURN(condition, retcode) assert(condition);
@@ -14,5 +13,3 @@
1413
return retcode; \
1514
}
1615
#endif // CONFIG_NVS_ASSERT_ERROR_CHECK
17-
18-
#endif // NVS_INTERNAL_H

components/nvs_flash/src/compressed_enum_table.hpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
7-
#ifndef compressed_enum_table_h
8-
#define compressed_enum_table_h
6+
#pragma once
97

108
#include <cstdint>
119
#include <cassert>
@@ -71,5 +69,3 @@ class CompressedEnumTable
7169
static const uint32_t VALUE_MASK = (1 << Nbits) - 1;
7270
uint32_t mData[WORD_COUNT];
7371
};
74-
75-
#endif /* compressed_enum_table_h */

components/nvs_flash/src/intrusive_list.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
6-
#ifndef intrusive_list_h
7-
#define intrusive_list_h
6+
#pragma once
87

98
#include <cassert>
109
#include <unordered_map>
@@ -251,6 +250,3 @@ class intrusive_list
251250
T* mLast = nullptr;
252251
size_t mSize = 0;
253252
};
254-
255-
256-
#endif /* intrusive_list_h */

components/nvs_flash/src/nvs_encrypted_partition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
14-
15-
#ifndef NVS_ENCRYPTED_PARTITION_HPP_
16-
#define NVS_ENCRYPTED_PARTITION_HPP_
17-
18-
#include "mbedtls/aes.h"
19-
#include "nvs_flash.h"
1+
/*
2+
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#pragma once
7+
8+
#include "mbedtls/aes.h" // For mbedtls_aes_xts_context
9+
#include "nvs_flash.h" // For nvs_sec_cfg_t
2010
#include "nvs_partition.hpp"
2111

2212
namespace nvs {
@@ -39,5 +29,3 @@ class NVSEncryptedPartition : public NVSPartition {
3929
};
4030

4131
} // nvs
42-
43-
#endif // NVS_ENCRYPTED_PARTITION_HPP_

0 commit comments

Comments
 (0)