From 491c39a4ed48cdf598b8a4fd8707ef1af0850b20 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Fri, 16 Dec 2022 18:57:49 +0100 Subject: libtar: simplify padd_file function We have an "append_sparse" function in libio, with a fallback, so use that. Signed-off-by: David Oberhollenzer --- lib/tar/padd_file.c | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/lib/tar/padd_file.c b/lib/tar/padd_file.c index 6a1ca05..053ff1e 100644 --- a/lib/tar/padd_file.c +++ b/lib/tar/padd_file.c @@ -8,32 +8,12 @@ #include "tar/tar.h" #include "tar/format.h" -#include -#include - int padd_file(ostream_t *fp, sqfs_u64 size) { size_t padd_sz = size % TAR_RECORD_SIZE; - int status = -1; - sqfs_u8 *buffer; if (padd_sz == 0) return 0; - padd_sz = TAR_RECORD_SIZE - padd_sz; - - buffer = calloc(1, padd_sz); - if (buffer == NULL) - goto fail_errno; - - if (ostream_append(fp, buffer, padd_sz)) - goto out; - - status = 0; -out: - free(buffer); - return status; -fail_errno: - perror("padding output file to block size"); - goto out; + return ostream_append_sparse(fp, TAR_RECORD_SIZE - padd_sz); } -- cgit v1.2.3