Commit b919089f authored by Evan Lojewski's avatar Evan Lojewski Committed by Raptor Engineering Development Team

firmware: Enable clang-tidy and enforce braces around statements.

parent d73eae87
---
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,readability-*'
WarningsAsErrors: 'clang-diagnostic-*,clang-analyzer-*,-*,readability-braces-around-statements'
HeaderFilterRegex: ''
AnalyzeTemporaryDtors: false
FormatStyle: none
CheckOptions:
- key: cert-dcl16-c.NewSuffixes
value: 'L;LL;LU;LLU'
- key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField
value: '0'
- key: cert-str34-c.DiagnoseSignedUnsignedCharComparisons
value: '0'
- key: cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors
value: '1'
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: '1'
- key: google-readability-braces-around-statements.ShortStatementLines
value: '1'
- key: google-readability-function-size.StatementThreshold
value: '800'
- key: google-readability-namespace-comments.ShortNamespaceLines
value: '10'
- key: google-readability-namespace-comments.SpacesBeforeComments
value: '2'
- key: llvm-else-after-return.WarnOnConditionVariables
value: '0'
- key: llvm-else-after-return.WarnOnUnfixable
value: '0'
- key: llvm-qualified-auto.AddConstToQualified
value: '0'
- key: modernize-loop-convert.MaxCopySize
value: '16'
- key: modernize-loop-convert.MinConfidence
value: reasonable
- key: modernize-loop-convert.NamingStyle
value: CamelCase
- key: modernize-pass-by-value.IncludeStyle
value: llvm
- key: modernize-replace-auto-ptr.IncludeStyle
value: llvm
- key: modernize-use-nullptr.NullMacros
value: 'NULL'
- key: readability-braces-around-statements.ShortStatementLines
value: '0'
- key: readability-else-after-return.WarnOnConditionVariables
value: 'true'
- key: readability-else-after-return.WarnOnUnfixable
value: 'true'
- key: readability-function-size.BranchThreshold
value: '4294967295'
- key: readability-function-size.LineThreshold
value: '4294967295'
- key: readability-function-size.NestingThreshold
value: '4294967295'
- key: readability-function-size.ParameterThreshold
value: '4294967295'
- key: readability-function-size.StatementThreshold
value: '800'
- key: readability-function-size.VariableThreshold
value: '4294967295'
- key: readability-identifier-naming.AggressiveDependentMemberLookup
value: 'false'
- key: readability-identifier-naming.IgnoreFailedSplit
value: 'false'
- key: readability-identifier-naming.IgnoreMainLikeFunctions
value: 'false'
- key: readability-implicit-bool-conversion.AllowIntegerConditions
value: 'false'
- key: readability-implicit-bool-conversion.AllowPointerConditions
value: 'false'
- key: readability-inconsistent-declaration-parameter-name.IgnoreMacros
value: 'true'
- key: readability-inconsistent-declaration-parameter-name.Strict
value: 'false'
- key: readability-magic-numbers.IgnoreAllFloatingPointValues
value: 'false'
- key: readability-magic-numbers.IgnoreBitFieldsWidths
value: 'true'
- key: readability-magic-numbers.IgnorePowersOf2IntegerValues
value: 'false'
- key: readability-magic-numbers.IgnoredFloatingPointValues
value: '1.0;100.0;'
- key: readability-magic-numbers.IgnoredIntegerValues
value: '1;2;3;4;'
- key: readability-qualified-auto.AddConstToQualified
value: 'true'
- key: readability-redundant-declaration.IgnoreMacros
value: 'true'
- key: readability-redundant-member-init.IgnoreBaseInCopyConstructors
value: 'false'
- key: readability-redundant-smartptr-get.IgnoreMacros
value: 'true'
- key: readability-redundant-string-init.StringNames
value: '::std::basic_string'
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
value: 'false'
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
value: 'false'
- key: readability-simplify-subscript-expr.Types
value: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array'
- key: readability-static-accessed-through-instance.NameSpecifierNestingThreshold
value: '3'
- key: readability-uppercase-literal-suffix.IgnoreMacros
value: 'true'
- key: readability-uppercase-literal-suffix.NewSuffixes
value: ''
...
...@@ -70,6 +70,7 @@ project(firmware VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}) ...@@ -70,6 +70,7 @@ project(firmware VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
include(bootrom/cmake/clang-format.cmake) include(bootrom/cmake/clang-format.cmake)
include(bootrom/cmake/clang-analyzer.cmake) include(bootrom/cmake/clang-analyzer.cmake)
include(bootrom/cmake/clang-tidy.cmake)
include(bootrom/cmake/config.cmake) include(bootrom/cmake/config.cmake)
add_subdirectory(bootrom/utils) add_subdirectory(bootrom/utils)
...@@ -100,3 +101,4 @@ target_link_libraries(${PROJECT_NAME} PRIVATE libbase-nofloat) ...@@ -100,3 +101,4 @@ target_link_libraries(${PROJECT_NAME} PRIVATE libbase-nofloat)
target_compile_definitions(${PROJECT_NAME} PRIVATE "-DNO_FLINT") # Disable linting target_compile_definitions(${PROJECT_NAME} PRIVATE "-DNO_FLINT") # Disable linting
format_target_sources(${PROJECT_NAME}) format_target_sources(${PROJECT_NAME})
enable_clang_tidy(${PROJECT_NAME})
...@@ -85,7 +85,8 @@ static int access_fsi_mem(uint8_t slave_id, uint32_t address, fsi_data_length_t ...@@ -85,7 +85,8 @@ static int access_fsi_mem(uint8_t slave_id, uint32_t address, fsi_data_length_t
// Wait for operation to complete // Wait for operation to complete
while (!(read_openfsi_register(OPENFSIMASTER_BASE, FSI_MASTER_REG_STATUS) & (FSI_MASTER_CTL_CYCLE_START_MASK << FSI_MASTER_CTL_CYCLE_START_SHIFT))) while (!(read_openfsi_register(OPENFSIMASTER_BASE, FSI_MASTER_REG_STATUS) & (FSI_MASTER_CTL_CYCLE_START_MASK << FSI_MASTER_CTL_CYCLE_START_SHIFT)))
; {
}
// Read status register // Read status register
word = read_openfsi_register(OPENFSIMASTER_BASE, FSI_MASTER_REG_STATUS); word = read_openfsi_register(OPENFSIMASTER_BASE, FSI_MASTER_REG_STATUS);
...@@ -148,7 +149,8 @@ static int initialize_fsi_master(void) ...@@ -148,7 +149,8 @@ static int initialize_fsi_master(void)
// Wait for any running operation(s) to complete // Wait for any running operation(s) to complete
while (read_openfsi_register(OPENFSIMASTER_BASE, FSI_MASTER_REG_STATUS) & (FSI_MASTER_CTL_CYCLE_START_MASK << FSI_MASTER_CTL_CYCLE_START_SHIFT)) while (read_openfsi_register(OPENFSIMASTER_BASE, FSI_MASTER_REG_STATUS) & (FSI_MASTER_CTL_CYCLE_START_MASK << FSI_MASTER_CTL_CYCLE_START_SHIFT))
; {
}
// Set up ACK to CMD turnaround delay and enable CRC protection / enhanced // Set up ACK to CMD turnaround delay and enable CRC protection / enhanced
// error recovery // error recovery
...@@ -194,7 +196,10 @@ int run_pre_ipl_fixups(void) ...@@ -194,7 +196,10 @@ int run_pre_ipl_fixups(void)
// Configure SBE to pre-IPL state // Configure SBE to pre-IPL state
if (access_cfam(IBM_POWER9_SLAVE_ID, IBM_POWER9_LL_MODE_REG, FSI_DATA_LENGTH_WORD, FSI_DIRECTION_READ, &word)) if (access_cfam(IBM_POWER9_SLAVE_ID, IBM_POWER9_LL_MODE_REG, FSI_DATA_LENGTH_WORD, FSI_DIRECTION_READ, &word))
{
goto fail; goto fail;
}
word &= ~(0x1 << 31); // Clear SBE IPL start flag word &= ~(0x1 << 31); // Clear SBE IPL start flag
word &= ~(0x1 << 29); // Run SCAN0 and CLOCKSTART during IPL word &= ~(0x1 << 29); // Run SCAN0 and CLOCKSTART during IPL
word &= ~(0x1 << 28); // Clear SBE start prevention flag word &= ~(0x1 << 28); // Clear SBE start prevention flag
......
...@@ -77,7 +77,8 @@ void isr(uint64_t vec) ...@@ -77,7 +77,8 @@ void isr(uint64_t vec)
irq_unhandled_vector = vec; irq_unhandled_vector = vec;
irq_unhandled_vector_valid = 1; irq_unhandled_vector_valid = 1;
while (1) while (1)
; {
}
} }
void isr_dec(void) void isr_dec(void)
......
...@@ -131,7 +131,9 @@ static char *readstr(void) ...@@ -131,7 +131,9 @@ static char *readstr(void)
return s; return s;
default: default:
if (ptr >= (sizeof(s) - 1)) if (ptr >= (sizeof(s) - 1))
{
break; break;
}
putsnonl(c); putsnonl(c);
s[ptr] = c[0]; s[ptr] = c[0];
ptr++; ptr++;
...@@ -863,11 +865,17 @@ static void process_host_to_bmc_ipmi_bt_transactions(void) ...@@ -863,11 +865,17 @@ static void process_host_to_bmc_ipmi_bt_transactions(void)
((1 << LPC_ADDRESS_BITS) - 1); ((1 << LPC_ADDRESS_BITS) - 1);
hiomap_config.active_device_id = ipmi_bt_current_request.data[6]; hiomap_config.active_device_id = ipmi_bt_current_request.data[6];
if (ipmi_bt_current_request.data[0] == HIOMAP_CMD_CREATE_RD_WIN) if (ipmi_bt_current_request.data[0] == HIOMAP_CMD_CREATE_RD_WIN)
{
hiomap_config.window_type = HIOMAP_WINDOW_TYPE_READ; hiomap_config.window_type = HIOMAP_WINDOW_TYPE_READ;
}
else if (ipmi_bt_current_request.data[0] == HIOMAP_CMD_CREATE_WR_WIN) else if (ipmi_bt_current_request.data[0] == HIOMAP_CMD_CREATE_WR_WIN)
{
hiomap_config.window_type = HIOMAP_WINDOW_TYPE_WRITE; hiomap_config.window_type = HIOMAP_WINDOW_TYPE_WRITE;
}
else else
{
hiomap_config.window_type = HIOMAP_WINDOW_INACTIVE; hiomap_config.window_type = HIOMAP_WINDOW_INACTIVE;
}
// Sanitize input // Sanitize input
switch (hiomap_config.protocol_version) switch (hiomap_config.protocol_version)
...@@ -2062,16 +2070,26 @@ static void console_service(void) ...@@ -2062,16 +2070,26 @@ static void console_service(void)
str = readstr(); str = readstr();
if (str == NULL) if (str == NULL)
{
return; return;
}
token = get_token(&str); token = get_token(&str);
if (strcmp(token, "help") == 0) if (strcmp(token, "help") == 0)
{
help(); help();
}
else if (strcmp(token, "reboot") == 0) else if (strcmp(token, "reboot") == 0)
{
reboot(); reboot();
}
else if (strcmp(token, "ipl") == 0) else if (strcmp(token, "ipl") == 0)
{
start_ipl(0); start_ipl(0);
}
else if (strcmp(token, "sbe_status") == 0) else if (strcmp(token, "sbe_status") == 0)
{
get_sbe_status(); get_sbe_status();
}
else if (strcmp(token, "mr") == 0) else if (strcmp(token, "mr") == 0)
{ {
if (*str) if (*str)
...@@ -2209,9 +2227,13 @@ static void console_service(void) ...@@ -2209,9 +2227,13 @@ static void console_service(void)
} }
} }
else if (strcmp(token, "console") == 0) else if (strcmp(token, "console") == 0)
{
attach_to_host_console(); attach_to_host_console();
}
else if (strcmp(token, "") != 0) else if (strcmp(token, "") != 0)
{
printf("%s: command not found\n", token); printf("%s: command not found\n", token);
}
prompt(); prompt();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment