x86/mm: Simplify expression in set_gpfn_from_mfn()
PATCH 1/1 x86/mm: Simplify expression in set_gpfn_from_mfn()
Coverity points out that the "d &&" is redundant.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
--- xen/arch/x86/x86_64/mm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/x86/x86_64/mm.c +1 -1
@@ -1336,7 +1336,7 @@ void set_gpfn_from_mfn(unsigned long mfn, unsigned long pfn) {const struct domain *d =page_get_owner (mfn_to_page (_mfn (mfn))); -if ( d && (d == dom_cow) ) +if ( d == dom_cow ) entry =SHARED_M2P_ENTRY ; }
Signature · 1 line
2.11.0
Quoted 1 line · Andrew Cooper
Coverity points out that the "d &&" is redundant.
How can it know that ...
xen/arch/x86/x86_64/mm.c void set_gpfn_from_mfn(unsigned long mfn, unsigned long pfn) · line 1339
Quoted 8 lines
xen/arch/x86/x86_64/mm.c +1
-1@@ -1336,7 +1336,7 @@ void set_gpfn_from_mfn(unsigned long mfn, unsigned long pfn) {const struct domain *d =page_get_owner (mfn_to_page (_mfn (mfn))); -if ( d && (d == dom_cow) ) +if ( d == dom_cow )
... dom_cow is not NULL (in which case the new expression is wrong when d also is). I actually think Coverity has spotted the issue when dom_cow is #define-d to NULL, in which case the original expression degenerates to "d && !d".
If the purpose of the extra check is more obvious that way, we could check dom_cow to be non-NULL (instead of d), but I'm afraid this may not silence Coverity.
Jan