From 67d9fde94c88d188b5873d9eab0cadcb2cc2e35c Mon Sep 17 00:00:00 2001 From: "Jose M. Guisado" Date: Tue, 27 Sep 2022 17:56:19 +0200 Subject: replace posix_fallocate with fallocate posix_fallocate does not return -1 for an error case. Replace posix_fallocate for fallocate which does return -1 when something goes wrong. See fallocate(2): On success, fallocate() returns zero. On error, -1 is returned and errno is set to indicate the error. --- src/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 969e287..298112d 100644 --- a/src/main.c +++ b/src/main.c @@ -7,6 +7,7 @@ * (at your option) any later version. */ +#define _GNU_SOURCE #include #include #include @@ -273,7 +274,7 @@ static int tip_client_head_hdr(struct tip_client *cli) return -1; } - if (posix_fallocate(cli->fd, 0, cli->content_len) < 0) { + if (fallocate(cli->fd, 0, 0, cli->content_len) < 0) { syslog(LOG_ERR, "failed to allocate room for file %s: %s", filename, strerror(errno)); return -1; -- cgit v1.2.3-18-g5258