Use the libkmod-file-xz.c as reference, keeping similar variable names
so it's easy to share code.
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/262
int kmod_file_load_zlib(struct kmod_file *file)
{
_cleanup_free_ unsigned char *p = NULL;
- int err = 0;
+ int ret = 0;
off_t did = 0, total = 0;
gzFile gzf;
int gzfd;
if (did == total) {
void *tmp = realloc(p, total + READ_STEP);
if (tmp == NULL) {
- err = -errno;
+ ret = -errno;
goto error;
}
total += READ_STEP;
ERR(file->ctx, "gzip: %s\n", gz_errmsg);
/* gzip might not set errno here */
- err = gzerr == Z_ERRNO ? -errno : -EINVAL;
+ ret = gzerr == Z_ERRNO ? -errno : -EINVAL;
goto error;
}
did += r;
error:
gzclose(gzf); /* closes the gzfd */
- return err;
+ return ret;
}