Skip to content

Commit

Permalink
Revert "Silence compiler warnings with the clamunrar code"
Browse files Browse the repository at this point in the history
This reverts commit ff909fb.
  • Loading branch information
Shawn Webb committed Sep 8, 2014
1 parent ec187e3 commit ddc55da
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 46 deletions.
21 changes: 9 additions & 12 deletions libclamunrar/unrar.c
Expand Up @@ -31,7 +31,6 @@
#include <stdlib.h>
#include <string.h>

#include "libclamav/clamav.h"
#include "libclamunrar/unrar.h"
#include "libclamunrar/unrarppm.h"
#include "libclamunrar/unrarvm.h"
Expand All @@ -44,7 +43,7 @@
#ifdef RAR_HIGH_DEBUG
#define rar_dbgmsg printf
#else
static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
static void rar_dbgmsg(const char* fmt,...){}
#endif

static void insert_old_dist(unpack_data_t *unpack_data, unsigned int distance)
Expand Down Expand Up @@ -124,7 +123,7 @@ int rar_unp_read_buf(int fd, unpack_data_t *unpack_data)
data_size = unpack_data->read_top;
}
/* RAR2 depends on us only reading upto the end of the current compressed file */
if (unpack_data->pack_size < (unsigned int)(((MAX_BUF_SIZE-data_size)&~0xf))) {
if (unpack_data->pack_size < ((MAX_BUF_SIZE-data_size)&~0xf)) {
read_size = unpack_data->pack_size;
} else {
read_size = (MAX_BUF_SIZE-data_size)&~0xf;
Expand Down Expand Up @@ -219,7 +218,7 @@ static void unp_write_buf(unpack_data_t *unpack_data)
struct UnpackFilter *flt, *next_filter;
struct rarvm_prepared_program *prg, *next_prg;
uint8_t *filtered_data;
size_t i, j;
int i, j;

rar_dbgmsg("in unp_write_buf\n");
written_border = unpack_data->wr_ptr;
Expand Down Expand Up @@ -396,9 +395,8 @@ static int read_tables(int fd, unpack_data_t *unpack_data)
uint8_t bit_length[BC];
unsigned char table[HUFF_TABLE_SIZE];
unsigned int bit_field;
int length, zero_count, number, n;
int i, length, zero_count, number, n;
const int table_size=HUFF_TABLE_SIZE;
size_t i;

rar_dbgmsg("in read_tables Offset=%ld in_addr=%d read_top=%d\n", lseek(fd, 0, SEEK_CUR),
unpack_data->in_addr, unpack_data->read_top);
Expand Down Expand Up @@ -541,11 +539,10 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte,
unsigned char *vmcode, int code_size)
{
rarvm_input_t rarvm_input;
unsigned int filter_pos, new_filter, block_start, init_mask, cur_size, data_size;
unsigned int filter_pos, new_filter, block_start, init_mask, cur_size;
struct UnpackFilter *filter, *stack_filter;
int empty_count, stack_pos, vm_codesize, static_size;
int i, empty_count, stack_pos, vm_codesize, static_size, data_size;
unsigned char *vm_code, *global_data;
size_t i;

rar_dbgmsg("in add_vm_code first_byte=0x%x code_size=%d\n", first_byte, code_size);
rarvm_input.in_buf = vmcode;
Expand All @@ -565,7 +562,7 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte,
}
rar_dbgmsg("filter_pos = %u\n", filter_pos);
if (filter_pos > unpack_data->Filters.num_items ||
filter_pos > (unsigned int)(unpack_data->old_filter_lengths_size)) {
filter_pos > unpack_data->old_filter_lengths_size) {
rar_dbgmsg("filter_pos check failed\n");
return FALSE;
}
Expand Down Expand Up @@ -628,7 +625,7 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte,
if (first_byte & 0x20) {
stack_filter->block_length = rarvm_read_data(&rarvm_input);
} else {
stack_filter->block_length = filter_pos < (unsigned int)(unpack_data->old_filter_lengths_size) ?
stack_filter->block_length = filter_pos < unpack_data->old_filter_lengths_size ?
unpack_data->old_filter_lengths[filter_pos] : 0;
}
rar_dbgmsg("block_length=%u\n", stack_filter->block_length);
Expand Down Expand Up @@ -663,7 +660,7 @@ static int add_vm_code(unpack_data_t *unpack_data, unsigned int first_byte,
rar_dbgmsg("unrar: add_vm_code: rar_malloc failed for vm_code\n");
return FALSE;
}
for (i=0 ; i < (size_t)vm_codesize ; i++) {
for (i=0 ; i < vm_codesize ; i++) {
vm_code[i] = rarvm_getbits(&rarvm_input) >> 8;
rarvm_addbits(&rarvm_input, 8);
}
Expand Down
4 changes: 2 additions & 2 deletions libclamunrar/unrar15.c
Expand Up @@ -122,9 +122,9 @@ static void copy_string15(unpack_data_t *unpack_data, unsigned int distance,
static unsigned int decode_num(unpack_data_t *unpack_data, int num, unsigned int start_pos,
unsigned int *dec_tab, unsigned int *pos_tab)
{
unsigned int i;
int i;

for (num&=0xfff0, i=0 ; dec_tab[i] <= (unsigned int)num ; i++) {
for (num&=0xfff0, i=0 ; dec_tab[i] <= num ; i++) {
start_pos++;
}
rar_addbits(unpack_data, start_pos);
Expand Down
3 changes: 1 addition & 2 deletions libclamunrar/unrar20.c
Expand Up @@ -19,14 +19,13 @@
#include <stdio.h>
#include <string.h>

#include "libclamav/clamav.h"
#include "libclamunrar/unrar.h"
#include "libclamunrar/unrar20.h"

#ifdef RAR_HIGH_DEBUG
#define rar_dbgmsg printf
#else
static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
static void rar_dbgmsg(const char* fmt,...){}
#endif

void unpack_init_data20(int solid, unpack_data_t *unpack_data)
Expand Down
2 changes: 1 addition & 1 deletion libclamunrar/unrarfilter.c
Expand Up @@ -33,7 +33,7 @@ void rar_filter_array_init(rar_filter_array_t *filter_a)

void rar_filter_array_reset(rar_filter_array_t *filter_a)
{
size_t i;
int i;

if (!filter_a) {
return;
Expand Down
3 changes: 1 addition & 2 deletions libclamunrar/unrarhlp.c
Expand Up @@ -13,13 +13,12 @@
#include <stdio.h>
#include <stdlib.h>

#include "libclamav/clamav.h"
#include "libclamunrar/unrarhlp.h"

#ifdef RAR_HIGH_DEBUG
#define rar_dbgmsg printf
#else
static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
static void rar_dbgmsg(const char* fmt,...){}
#endif

#define RAR_MAX_ALLOCATION 184549376
Expand Down
7 changes: 3 additions & 4 deletions libclamunrar/unrarppm.c
Expand Up @@ -21,14 +21,13 @@
#include <stdio.h>
#include <string.h>

#include "libclamav/clamav.h"
#include "libclamunrar/unrar.h"
#include "libclamunrar/unrarppm.h"

#ifdef RAR_HIGH_DEBUG
#define rar_dbgmsg printf
#else
static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
static void rar_dbgmsg(const char* fmt,...){}
#endif

#define MAX_O 64
Expand Down Expand Up @@ -755,7 +754,7 @@ static void update1(ppm_data_t *ppm_data, struct state_tag *p, struct ppm_contex
static int ppm_decode_symbol1(ppm_data_t *ppm_data, struct ppm_context *context)
{
struct state_tag *p;
unsigned int i, hi_cnt, count;
int i, hi_cnt, count;

rar_dbgmsg("in ppm_decode_symbol1\n");
ppm_data->coder.scale = context->con_ut.u.summ_freq;
Expand Down Expand Up @@ -868,7 +867,7 @@ static struct see2_context_tag *make_esc_freq(ppm_data_t *ppm_data,

static int ppm_decode_symbol2(ppm_data_t *ppm_data, struct ppm_context *context)
{
unsigned int count, hi_cnt, i;
int count, hi_cnt, i;
struct see2_context_tag *psee2c;
struct state_tag *ps[256], **pps, *p;

Expand Down
38 changes: 18 additions & 20 deletions libclamunrar/unrarvm.c
Expand Up @@ -22,15 +22,14 @@
#include <stdio.h>
#include <string.h>

#include "libclamav/clamav.h"
#include "libclamunrar/unrar.h"
#include "libclamunrar/unrarvm.h"
#include "libclamunrar/unrarcmd.h"

#ifdef RAR_HIGH_DEBUG
#define rar_dbgmsg printf
#else
static void rar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
static void rar_dbgmsg(const char* fmt,...){}
#endif

#define VMCF_OP0 0
Expand Down Expand Up @@ -156,7 +155,7 @@ const uint32_t crc_tab[256]={
uint32_t rar_crc(uint32_t start_crc, void *addr, uint32_t size)
{
unsigned char *data;
uint32_t i;
int i;

data = addr;
#if WORDS_BIGENDIAN == 0
Expand Down Expand Up @@ -265,7 +264,7 @@ unsigned int rarvm_read_data(rarvm_input_t *rarvm_input)
static rarvm_standard_filters_t is_standard_filter(unsigned char *code, int code_size)
{
uint32_t code_crc;
uint32_t i;
int i;

struct standard_filter_signature
{
Expand Down Expand Up @@ -341,12 +340,11 @@ static void filter_itanium_setbits(unsigned char *data, unsigned int bit_field,
static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_filters_t filter_type)
{
unsigned char *data, cmp_byte2, cur_byte, *src_data, *dest_data;
int channels, border, width, PosR;
int i, j, data_size, channels, src_pos, dest_pos, border, width, PosR;
int op_type, cur_channel, byte_count, start_pos, pa, pb, pc;
unsigned int file_offset, cur_pos, predicted, data_size, src_pos, dest_pos;
unsigned int file_offset, cur_pos, predicted;
int32_t offset, addr;
const int file_size=0x1000000;
unsigned int i, j;

switch(filter_type) {
case VMSF_E8:
Expand Down Expand Up @@ -433,7 +431,7 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil
}
for (cur_channel=0 ; cur_channel < channels ; cur_channel++) {
unsigned char prev_byte = 0;
for (dest_pos=data_size+cur_channel ; dest_pos<(unsigned int)border ; dest_pos+=channels) {
for (dest_pos=data_size+cur_channel ; dest_pos<border ; dest_pos+=channels) {
rarvm_data->mem[dest_pos] = (prev_byte -= rarvm_data->mem[src_pos++]);
}
}
Expand Down Expand Up @@ -477,7 +475,7 @@ static void execute_standard_filter(rarvm_data_t *rarvm_data, rarvm_standard_fil
dest_data[i] = prev_byte = (unsigned char)(predicted-*(src_data++));
}
}
for (i=PosR,border=data_size-2 ; i < (unsigned int)border ; i+=3) {
for (i=PosR,border=data_size-2 ; i < border ; i+=3) {
unsigned char g=dest_data[i+1];
dest_data[i] += g;
dest_data[i+2] += g;
Expand Down Expand Up @@ -651,13 +649,13 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data,
break;
case VM_JZ:
if ((rarvm_data->Flags & VM_FZ) != 0) {
SET_IP((int)GET_VALUE(FALSE, op1));
SET_IP(GET_VALUE(FALSE, op1));
continue;
}
break;
case VM_JNZ:
if ((rarvm_data->Flags & VM_FZ) == 0) {
SET_IP((int)GET_VALUE(FALSE, op1));
SET_IP(GET_VALUE(FALSE, op1));
continue;
}
break;
Expand All @@ -684,7 +682,7 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data,
SET_VALUE(FALSE, op1, GET_VALUE(FALSE, op1)-1);
break;
case VM_JMP:
SET_IP((int)GET_VALUE(FALSE, op1));
SET_IP(GET_VALUE(FALSE, op1));
continue;
case VM_XOR:
result = UINT32(GET_VALUE(cmd->byte_mode, op1)^GET_VALUE(cmd->byte_mode, op2));
Expand All @@ -707,37 +705,37 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data,
break;
case VM_JS:
if ((rarvm_data->Flags & VM_FS) != 0) {
SET_IP((int)GET_VALUE(FALSE, op1));
SET_IP(GET_VALUE(FALSE, op1));
continue;
}
break;
case VM_JNS:
if ((rarvm_data->Flags & VM_FS) == 0) {
SET_IP((int)GET_VALUE(FALSE, op1));
SET_IP(GET_VALUE(FALSE, op1));
continue;
}
break;
case VM_JB:
if ((rarvm_data->Flags & VM_FC) != 0) {
SET_IP((int)GET_VALUE(FALSE, op1));
SET_IP(GET_VALUE(FALSE, op1));
continue;
}
break;
case VM_JBE:
if ((rarvm_data->Flags & (VM_FC|VM_FZ)) != 0) {
SET_IP((int)GET_VALUE(FALSE, op1));
SET_IP(GET_VALUE(FALSE, op1));
continue;
}
break;
case VM_JA:
if ((rarvm_data->Flags & (VM_FC|VM_FZ)) == 0) {
SET_IP((int)GET_VALUE(FALSE, op1));
SET_IP(GET_VALUE(FALSE, op1));
continue;
}
break;
case VM_JAE:
if ((rarvm_data->Flags & VM_FC) == 0) {
SET_IP((int)GET_VALUE(FALSE, op1));
SET_IP(GET_VALUE(FALSE, op1));
continue;
}
break;
Expand All @@ -755,7 +753,7 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data,
rarvm_data->R[7] -= 4;
SET_VALUE(FALSE, (unsigned int *)&rarvm_data->mem[rarvm_data->R[7] &
RARVM_MEMMASK], cmd-prepared_code+1);
SET_IP((int)GET_VALUE(FALSE, op1));
SET_IP(GET_VALUE(FALSE, op1));
continue;
case VM_NOT:
SET_VALUE(cmd->byte_mode, op1, ~GET_VALUE(cmd->byte_mode, op1));
Expand Down Expand Up @@ -862,7 +860,7 @@ static int rarvm_execute_code(rarvm_data_t *rarvm_data,
if (rarvm_data->R[7] >= RARVM_MEMSIZE) {
return TRUE;
}
SET_IP((int)GET_VALUE(FALSE, (unsigned int *)&rarvm_data->mem[rarvm_data->R[7] &
SET_IP(GET_VALUE(FALSE, (unsigned int *)&rarvm_data->mem[rarvm_data->R[7] &
RARVM_MEMMASK]));
rarvm_data->R[7] += 4;
continue;
Expand Down
4 changes: 1 addition & 3 deletions libclamunrar_iface/unrar_iface.c
Expand Up @@ -30,7 +30,6 @@
#include <unistd.h>
#endif

#include "libclamav/clamav.h"
#include "libclamunrar/unrar.h"

#include "unrar_iface.h"
Expand All @@ -53,7 +52,7 @@ static uint32_t unrar_endian_convert_32(uint32_t v)
#ifdef RAR_DEBUG_MODE
#define unrar_dbgmsg printf
#else
static void unrar_dbgmsg(const char* fmt,...){ UNUSEDPARAM(fmt); }
static void unrar_dbgmsg(const char* fmt,...){}
#endif

static void *read_header(int fd, header_type hdr_type)
Expand Down Expand Up @@ -396,7 +395,6 @@ int unrar_extract_next_prepare(unrar_state_t *state, const char *dirname)
int ofd;
unrar_metadata_t *new_metadata;

UNUSEDPARAM(dirname);

state->file_header = read_block(state->fd, FILE_HEAD);
if(!state->file_header)
Expand Down

0 comments on commit ddc55da

Please sign in to comment.