Re: [PATCH] selftests/mm: Replace obsolete memalign() with posix_memalign()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 12 Apr 2023 21:27:51 -0400 Deming Wang <wangdeming@xxxxxxxxxx> wrote:

> memalign() is obsolete according to its manpage.
> 
> Replace memalign() with posix_memalign().
> 
> As a pointer is passed into posix_memalign(),initialize *map to
> NULL,to silence a warning about the function's return value being
> used as uninitialized (which is not valid anyway because the
> error is properly checked before map is returned).
> 

The patch you sent doesn't do this?

> --- a/tools/testing/selftests/mm/soft-dirty.c
> +++ b/tools/testing/selftests/mm/soft-dirty.c
> @@ -80,9 +80,9 @@ static void test_hugepage(int pagemap_fd, int pagesize)
>  	int i, ret;
>  	size_t hpage_len = read_pmd_pagesize();
>  
> -	map = memalign(hpage_len, hpage_len);
> -	if (!map)
> -		ksft_exit_fail_msg("memalign failed\n");
> +	ret = posix_memalign((void **)(&map), hpage_len, hpage_len);
> +	if (ret < 0)
> +		ksft_exit_fail_msg("posix_memalign failed\n");
>  
>  	ret = madvise(map, hpage_len, MADV_HUGEPAGE);
>  	if (ret)




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux