diff options
author | Myung Bae <myungbae@us.ibm.com> | 2024-04-17 22:33:03 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2024-04-18 00:11:53 +0300 |
commit | 3e7374243ff53125f3a55c2d0b1927e89261b1f9 (patch) | |
tree | c18f5c4678f6fdc50ce4a455eefd15f4dcde14e1 | |
parent | f2caadcee107d537be6fdb8e04bcc975eaa594c6 (diff) | |
download | bmcweb-3e7374243ff53125f3a55c2d0b1927e89261b1f9.tar.xz |
Initialize schemas array with explicit size
Currently `update_schemas.py` generates a schema list definition like
redfish-core/include/schemas.hpp:
```
constexpr std::array schemas {
"AccountService",
"ActionInfo",
...
"OpenBMCAccountService",
};
```
However, if the number of schemas is more than the clang's default
max size, CI may fail.
The default is `-fbracket-depth=256`.
```
In file included from /usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/functional:65:
[1m/usr/bin/../lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/array:288:52: [0m [0;1;31mfatal error:
instantiating fold expression with 276 arguments exceeded expression nesting limit of 256
288 | -> array<enable_if_t<(is_same_v<_Tp, _Up> && ...), _Tp>, [0m
| [0;1;32m ~~~~~~~~~~~~~~~~~~~~~~~~^~~~
[0m [1m../redfish-core/include/schemas.hpp:17:26: [0m [0;1;30mnote:
while substituting deduced template arguments into function template '<deduction guide for array>' [with _Tp =
const char *, _Up = <const char *, const char *, const char *, const char *, const char *,
...
const char *>] [0m
17 | constexpr std::array schemas { [0m
| [0;1;32m ^
[0m1 error generated.
```
To avoid the failure, we can set the size explicitly like
```
constexpr std::array<std::string_view,277> schemas {
"AccountService",
...
```
Tested:
1) Remove `include_list` so that all possible schemas are to be used
2) Run with the fixed `scripts/update_schemas.py`
3) Compiles successfully
Change-Id: Ib68db9fd3be1b6dbe0c4b5cc0e9a4324966d759e
Signed-off-by: Myung Bae <myungbae@us.ibm.com>
-rw-r--r-- | redfish-core/include/schemas.hpp | 3 | ||||
-rwxr-xr-x | scripts/update_schemas.py | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/redfish-core/include/schemas.hpp b/redfish-core/include/schemas.hpp index 7302876572..99f6703a91 100644 --- a/redfish-core/include/schemas.hpp +++ b/redfish-core/include/schemas.hpp @@ -11,10 +11,11 @@ ***************************************************************/ // clang-format off #include <array> +#include <string_view> namespace redfish { - constexpr std::array schemas { + constexpr std::array<std::string_view,116> schemas { "AccountService", "ActionInfo", "AggregationService", diff --git a/scripts/update_schemas.py b/scripts/update_schemas.py index bf395799e3..2e8487ded2 100755 --- a/scripts/update_schemas.py +++ b/scripts/update_schemas.py @@ -356,10 +356,14 @@ with open(os.path.join(cpp_path, "schemas.hpp"), "w") as hpp_file: "{WARNING}\n" "// clang-format off\n" "#include <array>\n" + "#include <string_view>\n" "\n" "namespace redfish\n" "{{\n" - " constexpr std::array schemas {{\n".format(WARNING=WARNING) + " constexpr std::array<std::string_view,{SIZE}> schemas {{\n".format( + WARNING=WARNING, + SIZE=len(json_schema_files) + len(oem_schema_names), + ) ) for schema_file in json_schema_files: hpp_file.write(' "{}",\n'.format(schema_file)) |