From 2506e2c63eeddbfecf814fcd441bf65e6fdf3d87 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 16 Sep 2012 07:40:05 +0200 Subject: Handle posix_memalign return value This is nothing we could handle correctly (well, in the long run we should print and error message), but at least this silences a warning with _FORTIFY_SOURCE. --- src/fastd.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/fastd.h b/src/fastd.h index 8b96e14..dc69760 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -293,7 +293,9 @@ static inline size_t alignto(size_t l, size_t a) { static inline fastd_buffer fastd_buffer_alloc(size_t len, size_t head_space, size_t tail_space) { size_t base_len = head_space+len+tail_space; void *ptr; - posix_memalign(&ptr, 16, base_len); + if (posix_memalign(&ptr, 16, base_len)) + return (fastd_buffer){ .base = NULL, .base_len = 0, .data = NULL, .len = 0 }; + return (fastd_buffer){ .base = ptr, .base_len = base_len, .data = ptr+head_space, .len = len }; } -- cgit v1.2.3