Skip to content

Commit b47b58c

Browse files
authored
Clear actionable readability/modernize clang-tidy findings (project-chip#72569)
A whole-tree clang-tidy pass flagged a set of pure-style issues with no behavior change: - utf8.cpp: drop else-after-return throughout the UTF-8 parser state machine (readability-else-after-return). - WiFiPAFLayer.cpp: remove a redundant trailing return in a void function and an else-after-return. - transport/raw/WiFiPAF.{h,cpp} and Linux ConnectivityManagerImpl.cpp: drop redundant (void) parameter lists (modernize-redundant-void-arg); the canonical declarations already use ().
1 parent ace3ccc commit b47b58c

5 files changed

Lines changed: 20 additions & 46 deletions

File tree

src/lib/support/utf8.cpp

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -62,105 +62,81 @@ ParserState NextState(ParserState state, uint8_t value)
6262
{
6363
return ParserState::kFirstByte;
6464
}
65-
else if ((value >= 0xC2) && (value <= 0xDF))
65+
if ((value >= 0xC2) && (value <= 0xDF))
6666
{
6767
return ParserState::kExtraOneByte;
6868
}
69-
else if (value == 0xE0)
69+
if (value == 0xE0)
7070
{
7171
return ParserState::kSecondByte_A;
7272
}
73-
else if ((value >= 0xE1) && (value <= 0xEC))
73+
if ((value >= 0xE1) && (value <= 0xEC))
7474
{
7575
return ParserState::kExtraTwoBytes;
7676
}
77-
else if (value == 0xED)
77+
if (value == 0xED)
7878
{
7979
return ParserState::kSecondByte_B;
8080
}
81-
else if ((value >= 0xEE) && (value <= 0xEF))
81+
if ((value >= 0xEE) && (value <= 0xEF))
8282
{
8383
return ParserState::kExtraTwoBytes;
8484
}
85-
else if (value == 0xF0)
85+
if (value == 0xF0)
8686
{
8787
return ParserState::kSecondByte_C;
8888
}
89-
else if ((value >= 0xF1) && (value <= 0xF3))
89+
if ((value >= 0xF1) && (value <= 0xF3))
9090
{
9191
return ParserState::kExtraThreeBytes;
9292
}
93-
else if (value == 0xF4)
93+
if (value == 0xF4)
9494
{
9595
return ParserState::kSecondByte_D;
9696
}
97-
else
98-
{
99-
return ParserState::kInvalid;
100-
}
97+
return ParserState::kInvalid;
10198
case ParserState::kSecondByte_A:
10299
if (value >= 0xA0 && value <= 0xBF)
103100
{
104101
return ParserState::kExtraOneByte;
105102
}
106-
else
107-
{
108-
return ParserState::kInvalid;
109-
}
103+
return ParserState::kInvalid;
110104
case ParserState::kSecondByte_B:
111105
if (value >= 0x80 && value <= 0x9F)
112106
{
113107
return ParserState::kExtraOneByte;
114108
}
115-
else
116-
{
117-
return ParserState::kInvalid;
118-
}
109+
return ParserState::kInvalid;
119110
case ParserState::kSecondByte_C:
120111
if (value >= 0x90 && value <= 0xBF)
121112
{
122113
return ParserState::kExtraTwoBytes;
123114
}
124-
else
125-
{
126-
return ParserState::kInvalid;
127-
}
115+
return ParserState::kInvalid;
128116
case ParserState::kSecondByte_D:
129117
if (value >= 0x80 && value <= 0x8F)
130118
{
131119
return ParserState::kExtraTwoBytes;
132120
}
133-
else
134-
{
135-
return ParserState::kInvalid;
136-
}
121+
return ParserState::kInvalid;
137122
case ParserState::kExtraOneByte:
138123
if (value >= 0x80 && value <= 0xBF)
139124
{
140125
return ParserState::kFirstByte;
141126
}
142-
else
143-
{
144-
return ParserState::kInvalid;
145-
}
127+
return ParserState::kInvalid;
146128
case ParserState::kExtraTwoBytes:
147129
if (value >= 0x80 && value <= 0xBF)
148130
{
149131
return ParserState::kExtraOneByte;
150132
}
151-
else
152-
{
153-
return ParserState::kInvalid;
154-
}
133+
return ParserState::kInvalid;
155134
case ParserState::kExtraThreeBytes:
156135
if (value >= 0x80 && value <= 0xBF)
157136
{
158137
return ParserState::kExtraTwoBytes;
159138
}
160-
else
161-
{
162-
return ParserState::kInvalid;
163-
}
139+
return ParserState::kInvalid;
164140
default:
165141
return ParserState::kInvalid;
166142
}

src/platform/Linux/ConnectivityManagerImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event)
210210
#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFIPAF
211211
}
212212

213-
ConnectivityManagerImpl & ConnectivityMgrImpl(void)
213+
ConnectivityManagerImpl & ConnectivityMgrImpl()
214214
{
215215
return ConnectivityManagerImpl::GetDefaultInstance();
216216
}

src/transport/raw/WiFiPAF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ CHIP_ERROR WiFiPAFBase::WiFiPAFCloseSession(WiFiPAFSession & SessionInfo)
116116
return CHIP_NO_ERROR;
117117
}
118118

119-
bool WiFiPAFBase::WiFiPAFResourceAvailable(void)
119+
bool WiFiPAFBase::WiFiPAFResourceAvailable()
120120
{
121121
return DeviceLayer::ConnectivityMgr().WiFiPAFResourceAvailable();
122122
}

src/transport/raw/WiFiPAF.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class DLL_EXPORT WiFiPAFBase : public Base, public WiFiPAF::WiFiPAFLayerDelegate
6666
CHIP_ERROR WiFiPAFMessageReceived(WiFiPAF::WiFiPAFSession & RxInfo, System::PacketBufferHandle && buffer) override;
6767
CHIP_ERROR WiFiPAFMessageSend(WiFiPAF::WiFiPAFSession & TxInfo, System::PacketBufferHandle && msg) override;
6868
CHIP_ERROR WiFiPAFCloseSession(WiFiPAF::WiFiPAFSession & SessionInfo) override;
69-
bool WiFiPAFResourceAvailable(void) override;
69+
bool WiFiPAFResourceAvailable() override;
7070

7171
private:
7272
/**

src/wifipaf/WiFiPAFLayer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ void WiFiPAFLayer::CleanPafInfo(WiFiPAFSession & SessionInfo)
403403
SessionInfo.peer_id = kUndefinedWiFiPafSessionId;
404404
SessionInfo.nodeId = kUndefinedNodeId;
405405
SessionInfo.discriminator = UINT16_MAX;
406-
return;
407406
}
408407

409408
CHIP_ERROR WiFiPAFLayer::AddPafSession(PafInfoAccess accType, WiFiPAFSession & SessionInfo)
@@ -506,8 +505,7 @@ WiFiPAFSession * WiFiPAFLayer::GetPAFInfo(PafInfoAccess accType, WiFiPAFSession
506505
{
507506
if (pPafSession->id != kUndefinedWiFiPafSessionId)
508507
return pPafSession;
509-
else
510-
continue;
508+
continue;
511509
}
512510
switch (accType)
513511
{

0 commit comments

Comments
 (0)