diff mbox series

[2/2] MIPS: Make virt_addr_valid() return bool

Message ID 20190528170444.1557-2-paul.burton@mips.com (mailing list archive)
State Mainlined
Commit 31875a5432248e7b0fff2f4f4e8cd96e5d82ceb0
Headers show
Series [1/2] MIPS: Bounds check virt_addr_valid | expand

Commit Message

Paul Burton May 28, 2019, 5:05 p.m. UTC
virt_addr_valid() really returns a boolean value, but currently uses an
integer to represent it. Switch to the bool type to make it clearer that
we really are returning a true or false value.

Signed-off-by: Paul Burton <paul.burton@mips.com>
---

 arch/mips/include/asm/page.h | 2 +-
 arch/mips/mm/mmap.c          | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

Comments

Philippe Mathieu-Daudé May 29, 2019, 12:39 p.m. UTC | #1
On 5/28/19 7:05 PM, Paul Burton wrote:
> virt_addr_valid() really returns a boolean value, but currently uses an
> integer to represent it. Switch to the bool type to make it clearer that
> we really are returning a true or false value.
> 
> Signed-off-by: Paul Burton <paul.burton@mips.com>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> ---
> 
>  arch/mips/include/asm/page.h | 2 +-
>  arch/mips/mm/mmap.c          | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
> index 6b31c93b5eaa..a25643d258cb 100644
> --- a/arch/mips/include/asm/page.h
> +++ b/arch/mips/include/asm/page.h
> @@ -249,7 +249,7 @@ static inline int pfn_valid(unsigned long pfn)
>  #define virt_to_pfn(kaddr)   	PFN_DOWN(virt_to_phys((void *)(kaddr)))
>  #define virt_to_page(kaddr)	pfn_to_page(virt_to_pfn(kaddr))
>  
> -extern int __virt_addr_valid(const volatile void *kaddr);
> +extern bool __virt_addr_valid(const volatile void *kaddr);
>  #define virt_addr_valid(kaddr)						\
>  	__virt_addr_valid((const volatile void *) (kaddr))
>  
> diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
> index 7755a1fad05a..50ee7213b432 100644
> --- a/arch/mips/mm/mmap.c
> +++ b/arch/mips/mm/mmap.c
> @@ -201,12 +201,12 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
>  	return ret;
>  }
>  
> -int __virt_addr_valid(const volatile void *kaddr)
> +bool __virt_addr_valid(const volatile void *kaddr)
>  {
>  	unsigned long vaddr = (unsigned long)vaddr;
>  
>  	if ((vaddr < PAGE_OFFSET) || (vaddr >= MAP_BASE))
> -		return 0;
> +		return false;
>  
>  	return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
>  }
>
diff mbox series

Patch

diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
index 6b31c93b5eaa..a25643d258cb 100644
--- a/arch/mips/include/asm/page.h
+++ b/arch/mips/include/asm/page.h
@@ -249,7 +249,7 @@  static inline int pfn_valid(unsigned long pfn)
 #define virt_to_pfn(kaddr)   	PFN_DOWN(virt_to_phys((void *)(kaddr)))
 #define virt_to_page(kaddr)	pfn_to_page(virt_to_pfn(kaddr))
 
-extern int __virt_addr_valid(const volatile void *kaddr);
+extern bool __virt_addr_valid(const volatile void *kaddr);
 #define virt_addr_valid(kaddr)						\
 	__virt_addr_valid((const volatile void *) (kaddr))
 
diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
index 7755a1fad05a..50ee7213b432 100644
--- a/arch/mips/mm/mmap.c
+++ b/arch/mips/mm/mmap.c
@@ -201,12 +201,12 @@  unsigned long arch_randomize_brk(struct mm_struct *mm)
 	return ret;
 }
 
-int __virt_addr_valid(const volatile void *kaddr)
+bool __virt_addr_valid(const volatile void *kaddr)
 {
 	unsigned long vaddr = (unsigned long)vaddr;
 
 	if ((vaddr < PAGE_OFFSET) || (vaddr >= MAP_BASE))
-		return 0;
+		return false;
 
 	return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
 }