[PATCH v3 10/11] xfsprogs: replace obsolete memalign with posix_memalign
Dave Chinner
david at fromorbit.com
Wed Aug 5 17:57:03 CDT 2015
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 at fromorbit.com
More information about the xfs
mailing list