Skip to content

Commit 1145bac

Browse files
authored
Misc clang-tidy auto fixes (project-chip#23445)
* Apply readability-redundant-control-flow,readability-redundant-string-init,readability-redundant-string-cstr on linux-x64-tests-clang * Apply readability-redundant-control-flow,readability-redundant-string-init,readability-redundant-string-cstr on linux-x64-all-clusters-clang * Apply readability-redundant-control-flow,readability-redundant-string-init,readability-redundant-string-cstr on linux-x64-chip-tool-clang * Apply modernize-use-bool-literals * apply performance-for-range-copy * apply readability-const-return-type * Fix compile * Fix compile * Added clang tidy checks as default and re-sorted the list * Fix 2 more items found by clang-tidy during CI * Mass-replace while(1) with while(true)
1 parent c9fdd12 commit 1145bac

File tree

72 files changed

+162
-164
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+162
-164
lines changed

.clang-tidy

+23-17
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,42 @@
11
---
22
Checks: >
3-
readability-else-after-return,
4-
modernize-use-nullptr,
53
bugprone-*,
6-
-bugprone-not-null-terminated-result,
7-
-bugprone-unused-return-value,
4+
modernize-use-bool-literals,
5+
modernize-use-nullptr,
6+
performance-for-range-copy,
7+
readability-const-return-type,
8+
readability-else-after-return,
9+
readability-redundant-control-flow,
10+
readability-redundant-string-cstr,
11+
readability-redundant-string-init,
812
-bugprone-branch-clone,
13+
-bugprone-copy-constructor-init,
914
-bugprone-easily-swappable-parameters,
10-
-bugprone-reserved-identifier,
11-
-bugprone-macro-parentheses,
1215
-bugprone-forward-declaration-namespace,
1316
-bugprone-forwarding-reference-overload,
14-
-bugprone-undelegated-constructor,
1517
-bugprone-implicit-widening-of-multiplication-result,
16-
-bugprone-narrowing-conversions,
18+
-bugprone-macro-parentheses,
1719
-bugprone-misplaced-widening-cast,
18-
-bugprone-suspicious-include,
20+
-bugprone-narrowing-conversions,
21+
-bugprone-not-null-terminated-result,
22+
-bugprone-reserved-identifier,
1923
-bugprone-signed-char-misuse,
20-
-bugprone-copy-constructor-init,
24+
-bugprone-suspicious-include,
25+
-bugprone-undelegated-constructor,
26+
-bugprone-unused-return-value,
2127
-clang-analyzer-core.CallAndMessage,
28+
-clang-analyzer-core.NonNullParamChecker,
2229
-clang-analyzer-core.NullDereference,
23-
-clang-analyzer-optin.cplusplus.UninitializedObject,
24-
-clang-analyzer-optin.performance,
25-
-clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,
26-
-clang-analyzer-deadcode.DeadStores,
2730
-clang-analyzer-cplusplus.Move,
28-
-clang-analyzer-optin.cplusplus.VirtualCall,
29-
-clang-analyzer-security.insecureAPI.strcpy,
31+
-clang-analyzer-deadcode.DeadStores,
3032
-clang-analyzer-nullability.NullablePassedToNonnull,
33+
-clang-analyzer-optin.cplusplus.UninitializedObject,
34+
-clang-analyzer-optin.cplusplus.VirtualCall,
35+
-clang-analyzer-optin.osx.cocoa.localizability.EmptyLocalizationContextChecker,
36+
-clang-analyzer-optin.performance,
3137
-clang-analyzer-optin.performance.Padding,
3238
-clang-analyzer-security.insecureAPI.rand,
33-
-clang-analyzer-core.NonNullParamChecker,
39+
-clang-analyzer-security.insecureAPI.strcpy,
3440
-clang-analyzer-unix.Malloc,
3541
-clang-diagnostic-implicit-int-conversion
3642
WarningsAsErrors: '*'

examples/all-clusters-app/all-clusters-common/include/static-supported-modes-manager.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class StaticSupportedModesManager : public chip::app::Clusters::ModeSelect::Supp
5454
public:
5555
static const StaticSupportedModesManager instance;
5656

57-
const SupportedModesManager::ModeOptionsProvider getModeOptionsProvider(EndpointId endpointId) const override;
57+
SupportedModesManager::ModeOptionsProvider getModeOptionsProvider(EndpointId endpointId) const override;
5858

5959
EmberAfStatus getModeOptionByMode(EndpointId endpointId, uint8_t mode, const ModeOptionStructType ** dataPtr) const override;
6060

examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const StaticSupportedModesManager::EndpointSpanPair
3939

4040
const StaticSupportedModesManager StaticSupportedModesManager::instance = StaticSupportedModesManager();
4141

42-
const SupportedModesManager::ModeOptionsProvider StaticSupportedModesManager::getModeOptionsProvider(EndpointId endpointId) const
42+
SupportedModesManager::ModeOptionsProvider StaticSupportedModesManager::getModeOptionsProvider(EndpointId endpointId) const
4343
{
4444
for (auto & endpointSpanPair : supportedOptionsByEndpoints)
4545
{

examples/all-clusters-app/cc13x2x7_26x2x7/main/AppTask.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ int AppTask::StartAppTask()
148148
if (sAppEventQueue == NULL)
149149
{
150150
PLAT_LOG("Failed to allocate app event queue");
151-
while (1)
151+
while (true)
152152
;
153153
}
154154

@@ -157,7 +157,7 @@ int AppTask::StartAppTask()
157157
pdPASS)
158158
{
159159
PLAT_LOG("Failed to create app task");
160-
while (1)
160+
while (true)
161161
;
162162
}
163163
return ret;
@@ -205,39 +205,39 @@ int AppTask::Init()
205205
if (ret != CHIP_NO_ERROR)
206206
{
207207
PLAT_LOG("PlatformMgr().InitChipStack() failed");
208-
while (1)
208+
while (true)
209209
;
210210
}
211211

212212
ret = ThreadStackMgr().InitThreadStack();
213213
if (ret != CHIP_NO_ERROR)
214214
{
215215
PLAT_LOG("ThreadStackMgr().InitThreadStack() failed");
216-
while (1)
216+
while (true)
217217
;
218218
}
219219

220220
ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
221221
if (ret != CHIP_NO_ERROR)
222222
{
223223
PLAT_LOG("ConnectivityMgr().SetThreadDeviceType() failed");
224-
while (1)
224+
while (true)
225225
;
226226
}
227227

228228
ret = PlatformMgr().StartEventLoopTask();
229229
if (ret != CHIP_NO_ERROR)
230230
{
231231
PLAT_LOG("PlatformMgr().StartEventLoopTask() failed");
232-
while (1)
232+
while (true)
233233
;
234234
}
235235

236236
ret = ThreadStackMgrImpl().StartThreadTask();
237237
if (ret != CHIP_NO_ERROR)
238238
{
239239
PLAT_LOG("ThreadStackMgr().StartThreadTask() failed");
240-
while (1)
240+
while (true)
241241
;
242242
}
243243

@@ -279,7 +279,7 @@ void AppTask::AppTaskMain(void * pvParameter)
279279

280280
sAppTask.Init();
281281

282-
while (1)
282+
while (true)
283283
{
284284
/* Task pend until we have stuff to do */
285285
if (xQueueReceive(sAppEventQueue, &event, portMAX_DELAY) == pdTRUE)

examples/all-clusters-app/cc13x2x7_26x2x7/main/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ uint32_t heapSize = TOTAL_ICALL_HEAP_SIZE;
5252
// ================================================================================
5353
extern "C" void vApplicationStackOverflowHook(void)
5454
{
55-
while (1)
55+
while (true)
5656
{
5757
;
5858
}
@@ -85,13 +85,13 @@ int main(void)
8585
{
8686
// can't log until the kernel is started
8787
// PLAT_LOG("GetAppTask().StartAppTask() failed");
88-
while (1)
88+
while (true)
8989
;
9090
}
9191

9292
vTaskStartScheduler();
9393

9494
// Should never get here.
95-
while (1)
95+
while (true)
9696
;
9797
}

examples/all-clusters-app/infineon/psoc6/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void appError(int err)
5959
{
6060
P6_LOG("!!!!!!!!!!!! App Critical Error: %d !!!!!!!!!!!", err);
6161
portDISABLE_INTERRUPTS();
62-
while (1)
62+
while (true)
6363
;
6464
}
6565

examples/all-clusters-app/nxp/mw320/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1027,7 +1027,7 @@ void task_main(void * param)
10271027
}
10281028
}
10291029

1030-
while (1)
1030+
while (true)
10311031
{
10321032
/* wait for interface up */
10331033
os_thread_sleep(os_msec_to_ticks(5000));
@@ -1131,7 +1131,7 @@ static void rst_args_lt(System::Layer * aSystemLayer, void * aAppState)
11311131

11321132
void task_test_main(void * param)
11331133
{
1134-
while (1)
1134+
while (true)
11351135
{
11361136
/* wait for interface up */
11371137
os_thread_sleep(os_msec_to_ticks(500));

examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/AppTask.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ int AppTask::StartAppTask()
148148
if (sAppEventQueue == NULL)
149149
{
150150
PLAT_LOG("Failed to allocate app event queue");
151-
while (1)
151+
while (true)
152152
;
153153
}
154154

@@ -157,7 +157,7 @@ int AppTask::StartAppTask()
157157
pdPASS)
158158
{
159159
PLAT_LOG("Failed to create app task");
160-
while (1)
160+
while (true)
161161
;
162162
}
163163
return ret;
@@ -205,39 +205,39 @@ int AppTask::Init()
205205
if (ret != CHIP_NO_ERROR)
206206
{
207207
PLAT_LOG("PlatformMgr().InitChipStack() failed");
208-
while (1)
208+
while (true)
209209
;
210210
}
211211

212212
ret = ThreadStackMgr().InitThreadStack();
213213
if (ret != CHIP_NO_ERROR)
214214
{
215215
PLAT_LOG("ThreadStackMgr().InitThreadStack() failed");
216-
while (1)
216+
while (true)
217217
;
218218
}
219219

220220
ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice);
221221
if (ret != CHIP_NO_ERROR)
222222
{
223223
PLAT_LOG("ConnectivityMgr().SetThreadDeviceType() failed");
224-
while (1)
224+
while (true)
225225
;
226226
}
227227

228228
ret = PlatformMgr().StartEventLoopTask();
229229
if (ret != CHIP_NO_ERROR)
230230
{
231231
PLAT_LOG("PlatformMgr().StartEventLoopTask() failed");
232-
while (1)
232+
while (true)
233233
;
234234
}
235235

236236
ret = ThreadStackMgrImpl().StartThreadTask();
237237
if (ret != CHIP_NO_ERROR)
238238
{
239239
PLAT_LOG("ThreadStackMgr().StartThreadTask() failed");
240-
while (1)
240+
while (true)
241241
;
242242
}
243243

@@ -279,7 +279,7 @@ void AppTask::AppTaskMain(void * pvParameter)
279279

280280
sAppTask.Init();
281281

282-
while (1)
282+
while (true)
283283
{
284284
/* Task pend until we have stuff to do */
285285
if (xQueueReceive(sAppEventQueue, &event, portMAX_DELAY) == pdTRUE)

examples/all-clusters-minimal-app/cc13x2x7_26x2x7/main/main.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ uint32_t heapSize = TOTAL_ICALL_HEAP_SIZE;
5252
// ================================================================================
5353
extern "C" void vApplicationStackOverflowHook(void)
5454
{
55-
while (1)
55+
while (true)
5656
{
5757
;
5858
}
@@ -85,13 +85,13 @@ int main(void)
8585
{
8686
// can't log until the kernel is started
8787
// PLAT_LOG("GetAppTask().StartAppTask() failed");
88-
while (1)
88+
while (true)
8989
;
9090
}
9191

9292
vTaskStartScheduler();
9393

9494
// Should never get here.
95-
while (1)
95+
while (true)
9696
;
9797
}

examples/all-clusters-minimal-app/infineon/psoc6/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void appError(int err)
5959
{
6060
P6_LOG("!!!!!!!!!!!! App Critical Error: %d !!!!!!!!!!!", err);
6161
portDISABLE_INTERRUPTS();
62-
while (1)
62+
while (true)
6363
;
6464
}
6565

examples/bridge-app/esp32/main/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span<const E
167167
{
168168
gDevices[index] = dev;
169169
EmberAfStatus ret;
170-
while (1)
170+
while (true)
171171
{
172172
dev->SetEndpointId(gCurrentEndpointId);
173173
ret =

examples/bridge-app/linux/main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ int AddDeviceEndpoint(Device * dev, EmberAfEndpointType * ep, const Span<const E
270270
{
271271
gDevices[index] = dev;
272272
EmberAfStatus ret;
273-
while (1)
273+
while (true)
274274
{
275275
// Todo: Update this to schedule the work rather than use this lock
276276
DeviceLayer::StackLock lock;
@@ -754,7 +754,7 @@ void * bridge_polling_thread(void * context)
754754
{
755755
bool light1_added = true;
756756
bool light2_added = false;
757-
while (1)
757+
while (true)
758758
{
759759
if (kbhit())
760760
{

examples/chef/esp32/main/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ extern "C" void app_main(void)
209209
xTaskCreate(&chip_shell_task, "chip_shell", 8192, NULL, 5, NULL);
210210
#endif /* CONFIG_ENABLE_CHIP_SHELL */
211211

212-
while (1)
212+
while (true)
213213
{
214214
vTaskDelay(100 / portTICK_PERIOD_MS);
215215
}

examples/chip-tool/commands/common/CHIPCommand.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ const chip::Credentials::AttestationTrustStore * CHIPCommand::sTrustStore = null
4848
chip::Credentials::GroupDataProviderImpl CHIPCommand::sGroupDataProvider{ kMaxGroupsPerFabric, kMaxGroupKeysPerFabric };
4949

5050
namespace {
51-
const CHIP_ERROR GetAttestationTrustStore(const char * paaTrustStorePath,
52-
const chip::Credentials::AttestationTrustStore ** trustStore)
51+
CHIP_ERROR GetAttestationTrustStore(const char * paaTrustStorePath, const chip::Credentials::AttestationTrustStore ** trustStore)
5352
{
5453
if (paaTrustStorePath == nullptr)
5554
{

examples/dynamic-bridge-app/linux/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ int AddDeviceEndpoint(Device * dev)
204204
{
205205
gDevices[index] = dev;
206206
EmberAfStatus ret;
207-
while (1)
207+
while (true)
208208
{
209209
// Todo: Update this to schedule the work rather than use this lock
210210
dev->SetEndpointId(gCurrentEndpointId);

examples/lighting-app/bouffalolab/bl602/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void appError(int err)
5151
{
5252
log_error("!!!!!!!!!!!! App Critical Error: %d !!!!!!!!!!!\r\n", err);
5353
portDISABLE_INTERRUPTS();
54-
while (1)
54+
while (true)
5555
;
5656
}
5757

0 commit comments

Comments
 (0)