From: Kern Sibbald Date: Sun, 23 Jul 2017 12:41:31 +0000 (+0200) Subject: Use Bacula in place of Libz variables so we can build with/without libz and lzo X-Git-Tag: Release-9.0.2~2 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ec806c17d43d3b118ffe6c431313b96f7c5442bb;p=bacula%2Fbacula Use Bacula in place of Libz variables so we can build with/without libz and lzo --- diff --git a/bacula/src/filed/backup.c b/bacula/src/filed/backup.c index 02c907b983..f76ff867ca 100644 --- a/bacula/src/filed/backup.c +++ b/bacula/src/filed/backup.c @@ -1030,10 +1030,10 @@ static bool setup_compression(bctx_t &bctx) if ((bctx.ff_pkt->flags & FO_COMPRESS) && bctx.ff_pkt->Compress_algo == COMPRESS_GZIP) { if ((bctx.ff_pkt->flags & FO_SPARSE) || (bctx.ff_pkt->flags & FO_OFFSETS)) { - bctx.cbuf = (Bytef *)jcr->compress_buf + OFFSET_FADDR_SIZE; + bctx.cbuf = (unsigned char *)jcr->compress_buf + OFFSET_FADDR_SIZE; bctx.max_compress_len = jcr->compress_buf_size - OFFSET_FADDR_SIZE; } else { - bctx.cbuf = (Bytef *)jcr->compress_buf; + bctx.cbuf = (unsigned char *)jcr->compress_buf; bctx.max_compress_len = jcr->compress_buf_size; /* set max length */ } bctx.wbuf = jcr->compress_buf; /* compressed output here */ @@ -1062,12 +1062,12 @@ static bool setup_compression(bctx_t &bctx) if ((bctx.ff_pkt->flags & FO_COMPRESS) && bctx.ff_pkt->Compress_algo == COMPRESS_LZO1X) { if ((bctx.ff_pkt->flags & FO_SPARSE) || (bctx.ff_pkt->flags & FO_OFFSETS)) { - bctx.cbuf = (Bytef *)jcr->compress_buf + OFFSET_FADDR_SIZE; - bctx.cbuf2 = (Bytef *)jcr->compress_buf + OFFSET_FADDR_SIZE + sizeof(comp_stream_header); + bctx.cbuf = (unsigned char *)jcr->compress_buf + OFFSET_FADDR_SIZE; + bctx.cbuf2 = (unsigned char *)jcr->compress_buf + OFFSET_FADDR_SIZE + sizeof(comp_stream_header); bctx.max_compress_len = jcr->compress_buf_size - OFFSET_FADDR_SIZE; } else { - bctx.cbuf = (Bytef *)jcr->compress_buf; - bctx.cbuf2 = (Bytef *)jcr->compress_buf + sizeof(comp_stream_header); + bctx.cbuf = (unsigned char *)jcr->compress_buf; + bctx.cbuf2 = (unsigned char *)jcr->compress_buf + sizeof(comp_stream_header); bctx.max_compress_len = jcr->compress_buf_size; /* set max length */ } bctx.ch.magic = COMPRESS_LZO1X; @@ -1076,8 +1076,6 @@ static bool setup_compression(bctx_t &bctx) bctx.cipher_input = (uint8_t *)jcr->compress_buf; /* encrypt compressed data */ } #endif -#else - bctx.max_compress_len = 0; #endif return true; } @@ -1154,7 +1152,7 @@ static bool do_libz_compression(bctx_t &bctx) if (bctx.ff_pkt->flags & FO_COMPRESS && bctx.ff_pkt->Compress_algo == COMPRESS_GZIP && jcr->pZLIB_compress_workset) { Dmsg3(400, "cbuf=0x%x rbuf=0x%x len=%u\n", bctx.cbuf, bctx.rbuf, sd->msglen); - ((z_stream*)jcr->pZLIB_compress_workset)->next_in = (Bytef *)bctx.rbuf; + ((z_stream*)jcr->pZLIB_compress_workset)->next_in = (unsigned char *)bctx.rbuf; ((z_stream*)jcr->pZLIB_compress_workset)->avail_in = sd->msglen; ((z_stream*)jcr->pZLIB_compress_workset)->next_out = bctx.cbuf; ((z_stream*)jcr->pZLIB_compress_workset)->avail_out = bctx.max_compress_len; diff --git a/bacula/src/filed/backup.h b/bacula/src/filed/backup.h index 1fe96b6501..1718849146 100644 --- a/bacula/src/filed/backup.h +++ b/bacula/src/filed/backup.h @@ -48,12 +48,19 @@ struct bctx_t { uint32_t encrypted_len; /* Compression variables */ -#if defined(HAVE_LIBZ) || defined(HAVE_LZO) - uLong compress_len; - uLong max_compress_len; - Bytef *cbuf; - Bytef *cbuf2; -#endif + /* These are the same as used by libz, but I find it very + * uncomfortable to define variables like this rather than + * specifying a number of bits. Defining them here allows us + * to have code that compiles with and without libz and lzo. + * + * uLong == unsigned long int + * Bytef == unsigned char + */ + unsigned long int max_compress_len; + unsigned long int compress_len; + unsigned char *cbuf; + unsigned char *cbuf2; + #ifdef HAVE_LZO comp_stream_header ch; #endif