[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] domain: add ASSERT to help static analysis tools
commit caa221791d4214445f2913f51a3230cc5644ab8d Author: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> AuthorDate: Fri Nov 17 10:21:52 2023 +0100 Commit: Stefano Stabellini <stefano.stabellini@xxxxxxx> CommitDate: Tue Nov 28 19:12:53 2023 -0800 domain: add ASSERT to help static analysis tools Static analysis tools may detect a possible null pointer dereference of 'config'. This ASSERT helps them in detecting that such a condition is not possible given that only real domains can enter this branch, which are guaranteeed to have a non-NULL config at this point, but this information is not inferred by the tool. Checking that the condition given in the assertion holds via testing is the means to protect release builds, where the assertion expands to effectively nothing. Suggested-by: Julien Grall <julien@xxxxxxx> Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> Acked-by: Stefano Stabellini <sstabellini@xxxxxxxxxx> --- xen/common/domain.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/xen/common/domain.c b/xen/common/domain.c index f15c2f1e95..cd2ca6d49a 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -700,6 +700,13 @@ struct domain *domain_create(domid_t domid, if ( !is_idle_domain(d) ) { + /* + * The assertion helps static analysis tools infer that config cannot + * be NULL in this branch, which in turn means that it can be safely + * dereferenced. Therefore, this assertion is not redundant. + */ + ASSERT(config); + watchdog_domain_init(d); init_status |= INIT_watchdog; -- generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |