Skip to content

Commit 94b752d

Browse files
ndrs-pstnashif
authored andcommitted
lib: smf: use while (true) in get_child_of for better clarity
Replace the condition-less `for` loop (`;;`) in `get_child_of` with a `while (true)` loop and remove the redundant `return NULL;` at the end, which is never reached. This change aims to enhance readability since `while (true)` is better suited for this scenario. Signed-off-by: Pisit Sawangvonganan <[email protected]>
1 parent f371ea4 commit 94b752d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/smf/smf.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,19 @@ static bool share_paren(const struct smf_state *test_state, const struct smf_sta
3636
static const struct smf_state *get_child_of(const struct smf_state *states,
3737
const struct smf_state *parent)
3838
{
39-
for (const struct smf_state *tmp = states;; tmp = tmp->parent) {
39+
const struct smf_state *tmp = states;
40+
41+
while (true) {
4042
if (tmp->parent == parent) {
4143
return tmp;
4244
}
4345

4446
if (tmp->parent == NULL) {
4547
return NULL;
4648
}
47-
}
4849

49-
return NULL;
50+
tmp = tmp->parent;
51+
}
5052
}
5153

5254
static const struct smf_state *get_last_of(const struct smf_state *states)

0 commit comments

Comments
 (0)