xfs
[Top] [All Lists]

Re: [PATCH v3 10/11] xfsprogs: replace obsolete memalign with posix_mema

To: Jan Tulak <jtulak@xxxxxxxxxx>
Subject: Re: [PATCH v3 10/11] xfsprogs: replace obsolete memalign with posix_memalign
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Thu, 6 Aug 2015 08:57:03 +1000
Cc: xfs@xxxxxxxxxxx, hch@xxxxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1438612789-17486-11-git-send-email-jtulak@xxxxxxxxxx>
References: <1438612789-17486-1-git-send-email-jtulak@xxxxxxxxxx> <1438612789-17486-11-git-send-email-jtulak@xxxxxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Mon, Aug 03, 2015 at 04:39:48PM +0200, Jan Tulak wrote:
> Memalign from <malloc.h> was marked obsolete in favor of a posix
> variant from <stdlib.h>. So replace all calls and remove <malloc.h>
> includes. This also enhances support on other posix platforms,
> which doesn't have <malloc.h>.
> 
> Because posix_memalign returns any error as a return code, not in
> errno, change relevant checks in code (and add a missing one).
....
> @@ -74,12 +74,18 @@ libxfs_device_zero(struct xfs_buftarg *btp, xfs_daddr_t 
> start, uint len)
>       ssize_t         zsize, bytes;
>       char            *z;
>       int             fd;
> +     int ret;
>  
>       zsize = min(BDSTRAT_SIZE, BBTOB(len));
> -     if ((z = memalign(libxfs_device_alignment(), zsize)) == NULL) {
> +     ret = posix_memalign(
> +                                             (void **)&z,
> +                                             libxfs_device_alignment(),
> +                                             zsize
> +                                     );

Unusual function call formatting. Please use the form the rest of
the code uses. i.e:

        ret = posix_memalign((void **)&z, libxfs_device_alignment(), zsize);

(same for the rest of the patch).

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>