]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
xen: explicit casts when DECLARE_BOUNDS cannot be used certifications-11
authorStefano Stabellini <sstabellini@kernel.org>
Tue, 5 Mar 2019 22:29:51 +0000 (14:29 -0800)
committerStefano Stabellini <sstabellini@kernel.org>
Tue, 5 Mar 2019 22:29:51 +0000 (14:29 -0800)
Sometimes the static inline functions provided by DECLARE_BOUNDS cannot
be used. This patch uses explicit casts to uintptr_t in those cases.

M3CM: Rule-18.2: Subtraction between pointers shall only be applied to
pointers that address elements of the same array

https://wiki.sei.cmu.edu/confluence/display/c/ARR36-C.+Do+not+subtract+or+compare+two+pointers+that+do+not+refer+to+the+same+array

QAVerify: 2761
Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
CC: JBeulich@suse.com
CC: andrew.cooper3@citrix.com
xen/arch/x86/setup.c
xen/common/virtual_region.c

index 2ac7f625465532010797a974ae86ad1f73672655..cb45b68f3fda3028a8d6014f6abd66c15de1933c 100644 (file)
@@ -976,7 +976,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
          * respective reserve_e820_ram() invocation below.
          */
         mod[mbi->mods_count].mod_start = virt_to_mfn(_stext);
-        mod[mbi->mods_count].mod_end = __2M_rwdata_end - _stext;
+        mod[mbi->mods_count].mod_end = (uintptr_t)__2M_rwdata_end -
+                                       (uintptr_t) _stext;
     }
 
     modules_headroom = bzimage_headroom(bootstrap_map(mod), mod->mod_end);
index aa23918bce43af1600c497c413f22ac5abb800b7..87ef33a8323cdcf9c6cb4b3ccec45b651ee9b1db 100644 (file)
@@ -119,7 +119,9 @@ void __init setup_virtual_regions(const struct exception_table_entry *start,
         const struct bug_frame *s;
 
         s = bug_frames[i - 1];
-        sz = bug_frames[i] - s;
+        /* bug_frame[i] and s are pointers to different objects. */
+        sz = ((uintptr_t)bug_frames[i] - (uintptr_t)s) /
+             sizeof(struct bug_frame);
 
         core.frame[i - 1].n_bugs = sz;
         core.frame[i - 1].bugs = s;