Cleanup pointer casting in code to use macros.

This commit is contained in:
Moinak Ghosh 2013-09-22 20:11:15 +05:30
parent 38c0869f5c
commit fa78621cbf
9 changed files with 82 additions and 76 deletions

View file

@ -249,7 +249,7 @@ valouti32(bsize_t x, u_char *buf)
{
int32_t val;
val = x;
*((int32_t *)buf) = htonl(val);
I32_P(buf) = htonl(val);
}
bsize_t

View file

@ -69,7 +69,7 @@ __FBSDID("$FreeBSD: src/usr.bin/bsdiff/bspatch/bspatch.c,v 1.1 2005/08/06 01:59:
static int32_t
valini32(u_char *buf)
{
return ntohl(*((int32_t *)buf));
return ntohl(I32_P(buf));
}
bsize_t

View file

@ -53,13 +53,13 @@ zero_rle_encode(const void *ibuf, const unsigned int ilen,
* We have a run of zeroes. Count them and store only the count.
*/
while (pos1 < (ilen - sz) && count < (COUNT_MAX - sz)) {
val = *((uint64_t *)(ib+pos1));
val = U64_P(ib+pos1);
if (val) break;
pos1 += sizeof (val); count += sizeof (val);
}
for (;pos1<ilen && ib[pos1]==0 && count<COUNT_MAX; pos1++) ++count;
count |= ZERO_MASK;
*((unsigned short *)(ob + pos2)) = htons(count);
U16_P(ob + pos2) = htons(count);
pos2 += 2;
if (pos2 > *olen) break;
} else {
@ -82,7 +82,7 @@ zero_rle_encode(const void *ibuf, const unsigned int ilen,
ob[pos2++] = ib[pos1++];
++count;
}
*((unsigned short *)(ob + pos3)) = htons(count);
U16_P(ob + pos3) = htons(count);
}
}
*olen = pos2;
@ -105,7 +105,7 @@ zero_rle_decode(const void* ibuf, unsigned int ilen,
pos2 = 0;
pos1 = 0;
for (; pos1<ilen && pos2<*olen;) {
count = ntohs(*((unsigned short *)(ib + pos1)));
count = ntohs(U16_P(ib + pos1));
pos1 += 2;
if (count & ZERO_MASK) {
count &= DATA_MASK;

View file

@ -782,16 +782,16 @@ init_crypto(crypto_ctx_t *cctx, uchar_t *pwd, int pwd_len, int crypto_alg,
} else {
uint64_t v;
v = tp.tv_sec * 1000UL + tp.tv_nsec;
*((uint64_t *)&sb[b]) = v;
U64_P(&sb[b]) = v;
b += 8;
}
*((uint32_t *)&sb[b]) = rand();
U32_P(&sb[b]) = rand();
b += 4;
*((uint32_t *)&sb[b]) = getpid();
U32_P(&sb[b]) = getpid();
b += 4;
compute_checksum(&sb[b], CKSUM_SHA256, sb, b, 0, 0);
b = 8 + 4;
*((uint32_t *)&sb[b]) = rand();
U32_P(&sb[b]) = rand();
compute_checksum(salt, CKSUM_SHA256, &sb[b], 32 + 4, 0, 0);
}
}
@ -825,7 +825,7 @@ init_crypto(crypto_ctx_t *cctx, uchar_t *pwd, int pwd_len, int crypto_alg,
memcpy(cctx->salt, salt, saltlen);
if (crypto_alg == CRYPTO_ALG_AES) {
if (aes_init(actx, cctx->salt, saltlen, pwd, pwd_len, *((uint64_t *)nonce),
if (aes_init(actx, cctx->salt, saltlen, pwd, pwd_len, U64_P(nonce),
enc_dec) != 0) {
fprintf(stderr, "Failed to initialize AES context\n");
return (-1);

View file

@ -128,7 +128,7 @@ delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int
int rv;
hdr_ovr = 0;
*((uint64_t *)dst) = LE64(srclen);
U64_P(dst) = LE64(srclen);
dst += MAIN_HDR;
rv = delta2_encode_real(src, srclen, dst, dstlen, rle_thresh, 1, &hdr_ovr);
if (rv == -1)
@ -147,7 +147,7 @@ delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int
dstend = dst + *dstlen;
slen = srclen;
pending = 0;
*((uint64_t *)dstpos) = LE64(srclen);
U64_P(dstpos) = LE64(srclen);
dstpos += MAIN_HDR;
lastdst = dstpos;
lastsrc = srcpos;
@ -178,7 +178,7 @@ delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int
} else {
if (pending) {
pending &= MSB_SETZERO_MASK;
*((uint64_t *)lastdst) = LE64(pending);
U64_P(lastdst) = LE64(pending);
lastdst += sizeof (uint64_t);
memcpy(lastdst, lastsrc, pending);
pending = 0;
@ -194,7 +194,7 @@ delta2_encode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen, int
}
if (pending) {
pending &= MSB_SETZERO_MASK;
*((uint64_t *)lastdst) = LE64(pending);
U64_P(lastdst) = LE64(pending);
lastdst += sizeof (uint64_t);
if (lastdst + pending > dstend) {
DEBUG_STAT_EN(fprintf(stderr, "No Delta\n"));
@ -248,7 +248,7 @@ delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen
sval |= (sval - 1);
val = 0;
for (cnt = 0; cnt < (srclen - sizeof (cnt)); cnt += st1) {
vl2 = *((uint64_t *)pos);
vl2 = U64_P(pos);
vl2 = LE64(vl2);
vl2 &= sval;
vld2 = vl2 - vl1;
@ -314,7 +314,7 @@ delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen
pos = src;
pos2 = dst;
vl2 = *((uint64_t *)pos);
vl2 = U64_P(pos);
vl2 = LE64(vl2);
val = stride;
val = ((val << 3) - 1);
@ -324,7 +324,7 @@ delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen
sval = vl2;
for (cnt = 0; cnt < (srclen - sizeof (cnt)); cnt += stride) {
vl2 = *((uint64_t *)pos);
vl2 = U64_P(pos);
vl2 = LE64(vl2);
vl2 &= val;
vld2 = vl2 - vl1;
@ -337,7 +337,7 @@ delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen
*/
if (gtot1 > 0) {
gtot1 &= MSB_SETZERO_MASK;
*((uint64_t *)pos2) = LE64(gtot1);
U64_P(pos2) = LE64(gtot1);
pos2 += sizeof (uint64_t);
DEBUG_STAT_EN(*hdr_ovr += LIT_HDR);
memcpy(pos2, pos - (gtot1+snum), gtot1);
@ -353,11 +353,11 @@ delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen
gtot2 = stride;
gtot2 <<= MSB_SHIFT;
gtot2 |= (snum & MSB_SETZERO_MASK);
*((uint64_t *)pos2) = LE64(gtot2);
U64_P(pos2) = LE64(gtot2);
pos2 += sizeof (uint64_t);
*((uint64_t *)pos2) = LE64(sval);
U64_P(pos2) = LE64(sval);
pos2 += sizeof (uint64_t);
*((uint64_t *)pos2) = LE64(vld1);
U64_P(pos2) = LE64(vld1);
pos2 += sizeof (uint64_t);
DEBUG_STAT_EN(*hdr_ovr += DELTA_HDR);
} else {
@ -379,7 +379,7 @@ delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen
if (snum > rle_thresh) {
if (gtot1 > 0) {
gtot1 &= MSB_SETZERO_MASK;
*((uint64_t *)pos2) = LE64(gtot1);
U64_P(pos2) = LE64(gtot1);
pos2 += sizeof (uint64_t);
DEBUG_STAT_EN(*hdr_ovr += LIT_HDR);
memcpy(pos2, pos - (gtot1+snum), gtot1);
@ -389,18 +389,18 @@ delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen
gtot2 = stride;
gtot2 <<= MSB_SHIFT;
gtot2 |= (snum & MSB_SETZERO_MASK);
*((uint64_t *)pos2) = LE64(gtot2);
U64_P(pos2) = LE64(gtot2);
pos2 += sizeof (uint64_t);
*((uint64_t *)pos2) = LE64(sval);
U64_P(pos2) = LE64(sval);
pos2 += sizeof (uint64_t);
*((uint64_t *)pos2) = LE64(vld1);
U64_P(pos2) = LE64(vld1);
pos2 += sizeof (uint64_t);
DEBUG_STAT_EN(*hdr_ovr += DELTA_HDR);
} else if (last_encode) {
gtot1 += snum;
gtot1 &= MSB_SETZERO_MASK;
*((uint64_t *)pos2) = LE64(gtot1);
U64_P(pos2) = LE64(gtot1);
pos2 += sizeof (uint64_t);
DEBUG_STAT_EN(*hdr_ovr += LIT_HDR);
memcpy(pos2, pos - gtot1, gtot1);
@ -418,7 +418,7 @@ delta2_encode_real(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen
* literal run.
*/
val &= MSB_SETZERO_MASK;
*((uint64_t *)pos2) = LE64(val);
U64_P(pos2) = LE64(val);
pos2 += sizeof (uint64_t);
for (cnt = 0; cnt < val; cnt++) {
*pos2 = *pos;
@ -447,7 +447,7 @@ delta2_decode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen)
DEBUG_STAT_EN(strt = get_wtime_millis());
last = pos + srclen;
olen = LE64(*((uint64_t *)pos));
olen = LE64(U64_P(pos));
if (*dstlen < olen) {
fprintf(stderr, "DELTA2 Decode: Destination buffer too small.\n");
return (-1);
@ -457,7 +457,7 @@ delta2_decode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen)
pos += MAIN_HDR;
while (pos < last) {
val = *((uint64_t *)pos);
val = U64_P(pos);
val = LE64(val);
flags = (val >> MSB_SHIFT) & 0xff;
@ -480,9 +480,9 @@ delta2_decode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen)
stride = flags;
rcnt = val & MSB_SETZERO_MASK;
pos += sizeof (rcnt);
sval = LE64(*((uint64_t *)pos));
sval = LE64(U64_P(pos));
pos += sizeof (sval);
delta = LE64(*((uint64_t *)pos));
delta = LE64(U64_P(pos));
pos += sizeof (delta);
if (out + rcnt > *dstlen) {
fprintf(stderr, "DELTA2 Decode(delta): Destination buffer overflow. Corrupt data.\n");
@ -500,7 +500,7 @@ delta2_decode(uchar_t *src, uint64_t srclen, uchar_t *dst, uint64_t *dstlen)
*/
for (cnt = 0; cnt < rcnt/stride; cnt++) {
val = (sval & vl);
*((uint64_t *)pos1) = LE64(val);
U64_P(pos1) = LE64(val);
out += stride;
sval += delta;
pos1 += stride;

View file

@ -288,7 +288,7 @@ preproc_compress(pc_ctx_t *pctx, compress_func_ptr cmp_func, void *src, uint64_t
}
*dest = type;
*((uint64_t *)(dest + 1)) = htonll(srclen);
U64_P(dest + 1) = htonll(srclen);
_dstlen = srclen;
DEBUG_STAT_EN(strt = get_wtime_millis());
result = cmp_func(src, srclen, dest+9, &_dstlen, level, chdr, data);
@ -328,7 +328,7 @@ preproc_decompress(pc_ctx_t *pctx, compress_func_ptr dec_func, void *src, uint64
++sorc;
--srclen;
if (type & PREPROC_COMPRESSED) {
*dstlen = ntohll(*((uint64_t *)(sorc)));
*dstlen = ntohll(U64_P(sorc));
sorc += 8;
srclen -= 8;
DEBUG_STAT_EN(strt = get_wtime_millis());
@ -482,7 +482,7 @@ redo:
*/
uint32_t crc1, crc2;
crc1 = htonl(*((uint32_t *)(tdat->compressed_chunk + pctx->cksum_bytes)));
crc1 = htonl(U32_P(tdat->compressed_chunk + pctx->cksum_bytes));
memset(tdat->compressed_chunk + pctx->cksum_bytes, 0, pctx->mac_bytes);
crc2 = lzma_crc32((uchar_t *)&tdat->len_cmp_be, sizeof (tdat->len_cmp_be), 0);
crc2 = lzma_crc32(tdat->compressed_chunk,
@ -927,7 +927,7 @@ start_decompress(pc_ctx_t *pctx, const char *filename, const char *to_filename)
}
if (pctx->encrypt_type == CRYPTO_ALG_AES) {
*((uint64_t *)nonce) = ntohll(*((uint64_t *)n1));
U64_P(nonce) = ntohll(U64_P(n1));
} else if (pctx->encrypt_type == CRYPTO_ALG_SALSA20) {
deserialize_checksum(nonce, n1, noncelen);
@ -1641,7 +1641,7 @@ plain_index:
if (type & CHSIZE_MASK)
crc = lzma_crc32(tdat->cmp_seg + tdat->len_cmp - ORIGINAL_CHUNKSZ,
ORIGINAL_CHUNKSZ, crc);
*((uint32_t *)mac_ptr) = htonl(crc);
U32_P(mac_ptr) = htonl(crc);
}
sem_post(&tdat->cmp_done_sem);
@ -2122,7 +2122,7 @@ start_compress(pc_ctx_t *pctx, const char *filename, uint64_t chunksize, int lev
serialize_checksum(pctx->crypto_ctx.salt, pos, pctx->crypto_ctx.saltlen);
pos += pctx->crypto_ctx.saltlen;
if (pctx->encrypt_type == CRYPTO_ALG_AES) {
*((uint64_t *)pos) = htonll(*((uint64_t *)crypto_nonce(&(pctx->crypto_ctx))));
U64_P(pos) = htonll(U64_P(crypto_nonce(&(pctx->crypto_ctx))));
pos += 8;
} else if (pctx->encrypt_type == CRYPTO_ALG_SALSA20) {
@ -2168,7 +2168,7 @@ start_compress(pc_ctx_t *pctx, const char *filename, uint64_t chunksize, int lev
* Compute header CRC32 and store that. Only archive version 5 and above.
*/
uint32_t crc = lzma_crc32(cread_buf, pos - cread_buf, 0);
*((uint32_t *)cread_buf) = htonl(crc);
U32_P(cread_buf) = htonl(crc);
if (Write(compfd, cread_buf, sizeof (uint32_t)) != sizeof (uint32_t)) {
perror("Write ");
COMP_BAIL;

View file

@ -328,8 +328,8 @@ db_segcache_write(archive_config_t *cfg, int tid, uchar_t *buf, uint32_t len, ui
int64_t w;
uchar_t hdr[SEGCACHE_HDR_SZ];
*((uint32_t *)(hdr)) = blknum;
*((uint64_t *)(hdr + 4)) = file_offset;
U32_P(hdr) = blknum;
U64_P(hdr + 4) = file_offset;
w = Write(cfg->seg_fd_w, hdr, sizeof (hdr));
if (w < sizeof (hdr)) {
@ -382,8 +382,8 @@ db_segcache_map(archive_config_t *cfg, int tid, uint32_t *blknum, uint64_t *offs
adj = *offset % cfg->pagesize;
if (*offset == cfg->seg_fd_r[tid].cache_offset && cfg->seg_fd_r[tid].mapping) {
hdr = (uchar_t *)(cfg->seg_fd_r[tid].mapping) + adj;
*blknum = *((uint32_t *)(hdr));
*offset = *((uint64_t *)(hdr + 4));
*blknum = U32_P(hdr);
*offset = U64_P(hdr + 4);
*blocks = hdr + SEGCACHE_HDR_SZ;
return (0);
}
@ -416,8 +416,8 @@ db_segcache_map(archive_config_t *cfg, int tid, uint32_t *blknum, uint64_t *offs
cfg->seg_fd_r[tid].cache_offset = *offset;
hdr = mapbuf + adj;
*blknum = *((uint32_t *)(hdr));
*offset = *((uint64_t *)(hdr + 4));
*blknum = U32_P(hdr);
*offset = U64_P(hdr + 4);
*blocks = hdr + SEGCACHE_HDR_SZ;
dummy = *(hdr + SEGCACHE_HDR_SZ);
@ -486,7 +486,7 @@ db_lookup_insert_s(archive_config_t *cfg, uchar_t *sim_cksum, int interval,
* there is no need to re-hash the keys here.
*/
if (cfg->similarity_cksum_sz == 8) {
htab_entry = *((uint32_t *)sim_cksum);
htab_entry = U32_P(sim_cksum);
} else {
htab_entry = XXH32(sim_cksum, cfg->similarity_cksum_sz, 0);
}
@ -509,7 +509,7 @@ db_lookup_insert_s(archive_config_t *cfg, uchar_t *sim_cksum, int interval,
// The following two cases are for Segmented Dedupe approximate matching
} else if (cfg->similarity_cksum_sz == 8) {// Fast path for 64-bit keys
while (ent) {
if (*((uint64_t *)sim_cksum) == *((uint64_t *)ent->cksum)) {
if (U64_P(sim_cksum) == U64_P(ent->cksum)) {
return (ent);
}
pent = &(ent->next);

View file

@ -792,7 +792,7 @@ process_blocks:
* First entry in table is the original file offset where this
* data segment begins.
*/
*((uint64_t *)g_dedupe_idx) = LE64(ctx->file_offset);
U64_P(g_dedupe_idx) = LE64(ctx->file_offset);
g_dedupe_idx += (RABIN_ENTRY_SIZE * 2);
dedupe_index_sz += 2;
matchlen = 0;
@ -825,7 +825,7 @@ process_blocks:
* Block was added to index. Merge this block.
*/
if (length + ctx->g_blocks[i].length >= RABIN_MAX_BLOCK_SIZE) {
*((uint32_t *)g_dedupe_idx) = LE32(length);
U32_P(g_dedupe_idx) = LE32(length);
g_dedupe_idx += RABIN_ENTRY_SIZE;
length = 0;
dedupe_index_sz++;
@ -839,7 +839,7 @@ process_blocks:
/*
* Write pending accumulated block length value.
*/
*((uint32_t *)g_dedupe_idx) = LE32(length);
U32_P(g_dedupe_idx) = LE32(length);
g_dedupe_idx += RABIN_ENTRY_SIZE;
length = 0;
dedupe_index_sz++;
@ -848,10 +848,10 @@ process_blocks:
/*
* Add a reference entry to the dedupe array.
*/
*((uint32_t *)g_dedupe_idx) = LE32((he->item_size | RABIN_INDEX_FLAG) &
U32_P(g_dedupe_idx) = LE32((he->item_size | RABIN_INDEX_FLAG) &
CLEAR_SIMILARITY_FLAG);
g_dedupe_idx += RABIN_ENTRY_SIZE;
*((uint64_t *)g_dedupe_idx) = LE64(he->item_offset);
U64_P(g_dedupe_idx) = LE64(he->item_offset);
g_dedupe_idx += (RABIN_ENTRY_SIZE * 2);
matchlen += he->item_size;
dedupe_index_sz += 3;
@ -867,7 +867,7 @@ process_blocks:
* Write final pending block length value (if any).
*/
if (length > 0) {
*((uint32_t *)g_dedupe_idx) = LE32(length);
U32_P(g_dedupe_idx) = LE32(length);
g_dedupe_idx += RABIN_ENTRY_SIZE;
length = 0;
dedupe_index_sz++;
@ -948,7 +948,7 @@ process_blocks:
tgt += cfg->chunk_cksum_sz;
}
}
*((uint32_t *)src) = blks;
U32_P(src) = blks;
src += sizeof (blks);
blks = j+i;
@ -965,14 +965,14 @@ process_blocks:
tgt = seg_heap;
sub_i = 0;
*((uint64_t *)sim_ck) = 0;
U64_P(sim_ck) = 0;
a = 0;
for (j = 0; j < length && sub_i < cfg->sub_intervals;) {
b = *((uint64_t *)tgt);
b = U64_P(tgt);
tgt += sizeof (uint64_t);
j += sizeof (uint64_t);
if (b != a) {
*((uint64_t *)sim_ck) = b;
U64_P(sim_ck) = b;
sim_ck += sizeof (uint64_t);
a = b;
sub_i++;
@ -1013,9 +1013,9 @@ process_blocks:
hash_entry_t *he = NULL;
he = db_lookup_insert_s(cfg, sim_ck, 0, seg_offset, 0, 1);
if (he) {
*((uint64_t *)tgt) = he->item_offset;
U64_P(tgt) = he->item_offset;
} else {
*((uint64_t *)tgt) = UINT64_MAX;
U64_P(tgt) = UINT64_MAX;
}
sim_ck += cfg->similarity_cksum_sz;
tgt += cfg->similarity_cksum_sz;
@ -1034,9 +1034,9 @@ process_blocks:
*/
sim_ck = tgt;
for (j=0; j < sub_i; j++) {
if (off1 != *((uint64_t *)sim_ck) && *((uint64_t *)sim_ck) != UINT64_MAX) {
off1 = *((uint64_t *)sim_ck);
*((uint64_t *)tgt) = off1;
if (off1 != U64_P(sim_ck) && U64_P(sim_ck) != UINT64_MAX) {
off1 = U64_P(sim_ck);
U64_P(tgt) = off1;
tgt += cfg->similarity_cksum_sz;
k++;
}
@ -1058,7 +1058,7 @@ process_blocks:
*/
src = sim_offsets;
for (i=0; i<blknum;) {
blks = *((uint32_t *)src) + i;
blks = U32_P(src) + i;
src += sizeof (blks);
/*
@ -1120,7 +1120,7 @@ process_blocks:
* Load segment metadata from disk and perform identity deduplication
* with the segment chunks.
*/
offset = *((uint64_t *)sim_ck);
offset = U64_P(sim_ck);
if (db_segcache_map(cfg, ctx->id, &o_blks, &offset,
(uchar_t **)&seg_blocks) == -1) {
fprintf(stderr, "** Segment cache mmap failed.\n");
@ -1181,7 +1181,7 @@ next_ent:
* Block was added to index. Merge this block.
*/
if (length + ctx->g_blocks[i].length > RABIN_MAX_BLOCK_SIZE) {
*((uint32_t *)g_dedupe_idx) = LE32(length);
U32_P(g_dedupe_idx) = LE32(length);
g_dedupe_idx += RABIN_ENTRY_SIZE;
length = 0;
dedupe_index_sz++;
@ -1195,7 +1195,7 @@ next_ent:
/*
* Write pending accumulated block length value.
*/
*((uint32_t *)g_dedupe_idx) = LE32(length);
U32_P(g_dedupe_idx) = LE32(length);
g_dedupe_idx += RABIN_ENTRY_SIZE;
length = 0;
dedupe_index_sz++;
@ -1203,9 +1203,9 @@ next_ent:
/*
* Add a reference entry to the dedupe array.
*/
*((uint32_t *)g_dedupe_idx) = LE32(ctx->g_blocks[i].length);
U32_P(g_dedupe_idx) = LE32(ctx->g_blocks[i].length);
g_dedupe_idx += RABIN_ENTRY_SIZE;
*((uint64_t *)g_dedupe_idx) = LE64(ctx->g_blocks[i].offset);
U64_P(g_dedupe_idx) = LE64(ctx->g_blocks[i].offset);
g_dedupe_idx += (RABIN_ENTRY_SIZE * 2);
matchlen += (ctx->g_blocks[i].length & RABIN_INDEX_VALUE);
dedupe_index_sz += 3;
@ -1216,7 +1216,7 @@ next_ent:
* Write final pending block length value (if any).
*/
if (length > 0) {
*((uint32_t *)g_dedupe_idx) = LE32(length);
U32_P(g_dedupe_idx) = LE32(length);
g_dedupe_idx += RABIN_ENTRY_SIZE;
length = 0;
dedupe_index_sz++;
@ -1246,7 +1246,7 @@ next_ent:
* Now copy the block data;
*/
for (i=0; i<blknum-2;) {
length = LE32(*((uint32_t *)g_dedupe_idx));
length = LE32(U32_P(g_dedupe_idx));
g_dedupe_idx += RABIN_ENTRY_SIZE;
++i;
@ -1483,7 +1483,7 @@ dedupe_done:
uint64_t *entries;
DEBUG_STAT_EN(uint64_t sz);
DEBUG_STAT_EN(sz = *size);
*((uint32_t *)cbuf) = htonl(blknum);
U32_P(cbuf) = htonl(blknum);
cbuf += sizeof (uint32_t);
entries = (uint64_t *)cbuf;
entries[0] = htonll(*size);
@ -1524,7 +1524,7 @@ parse_dedupe_hdr(uchar_t *buf, uint32_t *blknum, uint64_t *dedupe_index_sz,
{
uint64_t *entries;
*blknum = ntohl(*((uint32_t *)(buf)));
*blknum = ntohl(U32_P(buf));
buf += sizeof (uint32_t);
entries = (uint64_t *)buf;
@ -1561,14 +1561,14 @@ dedupe_decompress(dedupe_context_t *ctx, uchar_t *buf, uint64_t *size)
blknum &= CLEAR_GLOBAL_FLAG;
g_dedupe_idx = buf + RABIN_HDR_SIZE;
offset = LE64(*((uint64_t *)g_dedupe_idx));
offset = LE64(U64_P(g_dedupe_idx));
g_dedupe_idx += (RABIN_ENTRY_SIZE * 2);
blknum -= 2;
src1 = buf + RABIN_HDR_SIZE + dedupe_index_sz;
sem_wait(ctx->index_sem);
for (blk=0; blk<blknum;) {
len = LE32(*((uint32_t *)g_dedupe_idx));
len = LE32(U32_P(g_dedupe_idx));
g_dedupe_idx += RABIN_ENTRY_SIZE;
++blk;
flag = len & RABIN_INDEX_FLAG;
@ -1585,7 +1585,7 @@ dedupe_decompress(dedupe_context_t *ctx, uchar_t *buf, uint64_t *size)
src1 += len;
sz += len;
} else {
pos1 = LE64(*((uint64_t *)g_dedupe_idx));
pos1 = LE64(U64_P(g_dedupe_idx));
g_dedupe_idx += (RABIN_ENTRY_SIZE * 2);
blk += 2;

View file

@ -151,6 +151,12 @@ typedef int32_t bsize_t;
#endif
#define BYTES_TO_MB(x) ((x) / (1024 * 1024))
#define U64_P(x) *((uint64_t *)(x))
#define U32_P(x) *((uint32_t *)(x))
#define U16_P(x) *((uint16_t *)(x))
#define I64_P(x) *((int64_t *)(x))
#define I32_P(x) *((int32_t *)(x))
#define I16_P(x) *((int16_t *)(x))
/*
* Public checksum properties. CKSUM_MAX_BYTES must be updated if a