Re: mm/memory.c:3968:21: sparse: incorrect type in assignment (different base types)

From: Matthew Wilcox
Date: Thu Mar 14 2019 - 12:00:59 EST


On Thu, Mar 14, 2019 at 03:10:19PM +0530, Souptick Joarder wrote:
> > >> mm/memory.c:3968:21: sparse: incorrect type in assignment (different base types) @@ expected restricted vm_fault_t [usertype] ret @@ got e] ret @@
> > mm/memory.c:3968:21: expected restricted vm_fault_t [usertype] ret
> > mm/memory.c:3968:21: got int
>
> Looking into https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> hugetlb_fault() is converted to return vm_fault_t. Not sure, why sparse is
> still throwing warnings.

Because there are two definitions of hugetlb_fault():

$ git grep -wn hugetlb_fault
include/linux/hugetlb.h:108:vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
include/linux/hugetlb.h:206:#define hugetlb_fault(mm, vma, addr, flags) ({ BUG(); 0; })