[PATCH] fwts_mmap: fwts_page_size fix comparing size_t against -1

IvanHu ivan.hu at canonical.com
Mon Oct 29 17:34:39 UTC 2012


On 10/25/2012 06:27 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> sysconf returns a long and we need to compare this to -1
> rather than a size_t (which is always positive).
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
>   src/lib/src/fwts_mmap.c |    4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/src/fwts_mmap.c b/src/lib/src/fwts_mmap.c
> index c5acd26..58ab973 100644
> --- a/src/lib/src/fwts_mmap.c
> +++ b/src/lib/src/fwts_mmap.c
> @@ -33,12 +33,12 @@
>    */
>   size_t fwts_page_size(void)
>   {
> -	size_t page_size;
> +	long page_size;
>
>   	page_size = sysconf(_SC_PAGESIZE);
>
>   	/* If sysconf() returns -1, default it 4K */
> -	return page_size == -1 ? FWTS_DEFAULT_PAGE_SIZE : page_size;
> +	return (size_t)(page_size == -1 ? FWTS_DEFAULT_PAGE_SIZE : page_size);
>   }
>
>   /*
>

Acked-by: Ivan Hu <ivan.hu at canonical.com>




More information about the fwts-devel mailing list