mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-22 13:37:10 +00:00
doc: update coding guidelines
This patch updates some rules in coding guidelines. Tracked-On: #861 Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
This commit is contained in:
parent
868778a68b
commit
558a178841
@ -1575,6 +1575,47 @@ Compliant example::
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ST-22: 'goto' statement shall not be used
|
||||||
|
==========================================
|
||||||
|
|
||||||
|
Compliant example::
|
||||||
|
|
||||||
|
uint32_t showcase(uint32_t param)
|
||||||
|
{
|
||||||
|
uint32_t ret;
|
||||||
|
|
||||||
|
if (param < 10U) {
|
||||||
|
ret = 10U;
|
||||||
|
} else {
|
||||||
|
ret = param;
|
||||||
|
/* do something */
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
.. rst-class:: non-compliant-code
|
||||||
|
|
||||||
|
Non-compliant example::
|
||||||
|
|
||||||
|
uint32_t showcase(uint32_t param)
|
||||||
|
{
|
||||||
|
uint32_t ret;
|
||||||
|
|
||||||
|
if (param < 10U) {
|
||||||
|
ret = 10U;
|
||||||
|
goto done;
|
||||||
|
} else {
|
||||||
|
ret = param;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* do something */
|
||||||
|
|
||||||
|
done:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Expressions
|
Expressions
|
||||||
***********
|
***********
|
||||||
@ -3240,18 +3281,18 @@ NC-07: Function pointer shall be named with suffix 'fn'
|
|||||||
|
|
||||||
Compliant example::
|
Compliant example::
|
||||||
|
|
||||||
struct firmware_operations firmware_sbl_ops = {
|
struct firmware_operations {
|
||||||
.init = sbl_init_fn,
|
void (*init_fn)(void);
|
||||||
.get_rsdp = sbl_get_rsdp_fn,
|
void *(*get_rsdp_fn)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
.. rst-class:: non-compliant-code
|
.. rst-class:: non-compliant-code
|
||||||
|
|
||||||
Non-compliant example::
|
Non-compliant example::
|
||||||
|
|
||||||
struct firmware_operations firmware_sbl_ops = {
|
struct firmware_operations {
|
||||||
.init = sbl_init,
|
void (*init)(void);
|
||||||
.get_rsdp = sbl_get_rsdp,
|
void *(*get_rsdp)(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user