Skip to content

Commit 9fd71b3

Browse files
authored
Format code
1 parent ef1fd2c commit 9fd71b3

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

src/kservice.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,29 +1028,41 @@ RTM_EXPORT(rt_free_align);
10281028
#ifndef RT_USING_CPU_FFS
10291029
#ifdef RT_USING_PUNY_FFS
10301030
int __rt_ffs(rt_int32_t value) {
1031+
int position = 1; // position start from 1
1032+
10311033
if (value == 0)
1034+
{
10321035
return 0; // 0 means no bit 1
1033-
1034-
int position = 1; // position start from 1
1035-
1036+
}
1037+
10361038
// search half range
1037-
if ((value & 0xFFFF) == 0) { // is lower 16bit 0
1039+
if ((value & 0xFFFF) == 0)
1040+
{
1041+
// is lower 16bit 0
10381042
position += 16;
10391043
value >>= 16;
10401044
}
1041-
if ((value & 0xFF) == 0) { // is lower 8bit 0
1045+
if ((value & 0xFF) == 0)
1046+
{
1047+
// is lower 8bit 0
10421048
position += 8;
10431049
value >>= 8;
10441050
}
1045-
if ((value & 0xF) == 0) { // is lower 4bit 0
1051+
if ((value & 0xF) == 0)
1052+
{
1053+
// is lower 4bit 0
10461054
position += 4;
10471055
value >>= 4;
10481056
}
1049-
if ((value & 0x3) == 0) { // is lower 2bit 0
1057+
if ((value & 0x3) == 0)
1058+
{
1059+
// is lower 2bit 0
10501060
position += 2;
10511061
value >>= 2;
10521062
}
1053-
if ((value & 0x1) == 0) { // is lower 1bit 0
1063+
if ((value & 0x1) == 0)
1064+
{
1065+
// is lower 1bit 0
10541066
position += 1;
10551067
}
10561068

0 commit comments

Comments
 (0)