Skip to content

Commit a693243

Browse files
committed
Simplify codes without unnecessary return variables
1 parent f32ad21 commit a693243

File tree

3 files changed

+11
-22
lines changed

3 files changed

+11
-22
lines changed

examples/chef/common/clusters/audio-output/AudioOutputManager.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -58,35 +58,31 @@ CHIP_ERROR AudioOutputManager::HandleGetOutputList(AttributeValueEncoder & aEnco
5858

5959
bool AudioOutputManager::HandleRenameOutput(const uint8_t & index, const chip::CharSpan & name)
6060
{
61-
bool audioOutputRenamed = false;
62-
6361
for (OutputInfoType & output : mOutputs)
6462
{
6563
if (output.index == index)
6664
{
67-
audioOutputRenamed = true;
6865
const size_t len = std::min(mNameLenMax, name.size());
6966
memcpy(mOutputName[index], name.data(), len);
7067
output.name = mOutputName[index];
71-
return audioOutputRenamed;
68+
return true;
7269
}
7370
}
74-
return audioOutputRenamed;
71+
72+
return false;
7573
}
7674

7775
bool AudioOutputManager::HandleSelectOutput(const uint8_t & index)
7876
{
79-
bool audioOutputSelected = false;
8077
for (OutputInfoType & output : mOutputs)
8178
{
8279
if (output.index == index)
8380
{
84-
audioOutputSelected = true;
8581
mCurrentOutput = index;
86-
return audioOutputSelected;
82+
return true;
8783
}
8884
}
8985

90-
return audioOutputSelected;
86+
return false;
9187
}
9288
#endif // MATTER_DM_PLUGIN_AUDIO_OUTPUT_SERVER

examples/chef/common/clusters/channel/ChannelManager.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
186186

187187
bool ChannelManager::HandleChangeChannelByNumber(const uint16_t & majorNumber, const uint16_t & minorNumber)
188188
{
189-
bool channelChanged = false;
190189
uint16_t index = 0;
191190
for (auto const & channel : mChannels)
192191
{
@@ -196,15 +195,14 @@ bool ChannelManager::HandleChangeChannelByNumber(const uint16_t & majorNumber, c
196195
// verify if channel changed by comparing values of current channel with the requested channel
197196
if (channel.minorNumber != mCurrentChannel.minorNumber || channel.majorNumber != mCurrentChannel.majorNumber)
198197
{
199-
channelChanged = true;
200198
mCurrentChannelIndex = index;
201199
mCurrentChannel = channel;
202-
return channelChanged;
200+
return true;
203201
}
204202
}
205203
index++;
206204
}
207-
return channelChanged;
205+
return false;
208206
}
209207

210208
bool ChannelManager::HandleSkipChannel(const int16_t & count)

examples/chef/common/clusters/media-input/MediaInputManager.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,16 @@ uint8_t MediaInputManager::HandleGetCurrentInput()
5656

5757
bool MediaInputManager::HandleSelectInput(const uint8_t index)
5858
{
59-
bool mediaInputSelected = false;
6059
for (InputInfoType & input : mInputs)
6160
{
6261
if (input.index == index)
6362
{
64-
mediaInputSelected = true;
6563
mCurrentInput = index;
66-
return mediaInputSelected;
64+
return true;
6765
}
6866
}
6967

70-
return mediaInputSelected;
68+
return false;
7169
}
7270

7371
bool MediaInputManager::HandleShowInputStatus()
@@ -92,20 +90,17 @@ bool MediaInputManager::HandleHideInputStatus()
9290

9391
bool MediaInputManager::HandleRenameInput(const uint8_t index, const chip::CharSpan & name)
9492
{
95-
bool mediaInputRenamed = false;
96-
9793
for (InputInfoType & input : mInputs)
9894
{
9995
if (input.index == index)
10096
{
101-
mediaInputRenamed = true;
10297
const size_t len = std::min(mNameLenMax, name.size());
10398
memcpy(mInputName[index], name.data(), len);
10499
input.name = mInputName[index];
105-
return mediaInputRenamed;
100+
return true;
106101
}
107102
}
108103

109-
return mediaInputRenamed;
104+
return false;
110105
}
111106
#endif // MATTER_DM_PLUGIN_MEDIA_INPUT_SERVER

0 commit comments

Comments
 (0)