Skip to content

Commit 558a178

Browse files
shiqinggdbkinder
authored andcommitted
doc: update coding guidelines
This patch updates some rules in coding guidelines. Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
1 parent 868778a commit 558a178

File tree

1 file changed

+47
-6
lines changed

1 file changed

+47
-6
lines changed

doc/developer-guides/coding_guidelines.rst

Lines changed: 47 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,6 +1575,47 @@ Compliant example::
15751575
}
15761576

15771577

1578+
ST-22: 'goto' statement shall not be used
1579+
==========================================
1580+
1581+
Compliant example::
1582+
1583+
uint32_t showcase(uint32_t param)
1584+
{
1585+
uint32_t ret;
1586+
1587+
if (param < 10U) {
1588+
ret = 10U;
1589+
} else {
1590+
ret = param;
1591+
/* do something */
1592+
}
1593+
1594+
return ret;
1595+
}
1596+
1597+
.. rst-class:: non-compliant-code
1598+
1599+
Non-compliant example::
1600+
1601+
uint32_t showcase(uint32_t param)
1602+
{
1603+
uint32_t ret;
1604+
1605+
if (param < 10U) {
1606+
ret = 10U;
1607+
goto done;
1608+
} else {
1609+
ret = param;
1610+
}
1611+
1612+
/* do something */
1613+
1614+
done:
1615+
return ret;
1616+
}
1617+
1618+
15781619

15791620
Expressions
15801621
***********
@@ -3240,18 +3281,18 @@ NC-07: Function pointer shall be named with suffix 'fn'
32403281

32413282
Compliant example::
32423283

3243-
struct firmware_operations firmware_sbl_ops = {
3244-
.init = sbl_init_fn,
3245-
.get_rsdp = sbl_get_rsdp_fn,
3284+
struct firmware_operations {
3285+
void (*init_fn)(void);
3286+
void *(*get_rsdp_fn)(void);
32463287
};
32473288

32483289
.. rst-class:: non-compliant-code
32493290

32503291
Non-compliant example::
32513292

3252-
struct firmware_operations firmware_sbl_ops = {
3253-
.init = sbl_init,
3254-
.get_rsdp = sbl_get_rsdp,
3293+
struct firmware_operations {
3294+
void (*init)(void);
3295+
void *(*get_rsdp)(void);
32553296
};
32563297

32573298

0 commit comments

Comments
 (0)