From Joerg Sonnenberger: Fix a number of style gaffes,
including type puns and avoidable casts.
This commit is contained in:
parent
e44ad922b4
commit
72654d08e1
@ -253,10 +253,10 @@ static ssize_t
|
||||
read_ahead(struct archive_read *a, const void **p, size_t min)
|
||||
{
|
||||
struct private_data *state;
|
||||
int read_avail, was_avail, ret;
|
||||
size_t read_avail, was_avail;
|
||||
int ret;
|
||||
|
||||
state = (struct private_data *)a->compression_data;
|
||||
was_avail = -1;
|
||||
if (!a->client_reader) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
|
||||
"No read callback is registered? "
|
||||
@ -275,13 +275,14 @@ read_ahead(struct archive_read *a, const void **p, size_t min)
|
||||
= state->uncompressed_buffer_size - read_avail;
|
||||
}
|
||||
|
||||
while (was_avail < read_avail && /* Made some progress. */
|
||||
read_avail < (int)min && /* Haven't satisfied min. */
|
||||
read_avail < (int)state->uncompressed_buffer_size) { /* !full */
|
||||
while (read_avail < min && /* Haven't satisfied min. */
|
||||
read_avail < state->uncompressed_buffer_size) { /* !full */
|
||||
was_avail = read_avail;
|
||||
if ((ret = drive_decompressor(a, state)) != ARCHIVE_OK)
|
||||
return (ret);
|
||||
was_avail = read_avail;
|
||||
read_avail = state->stream.next_out - state->read_next;
|
||||
if (was_avail == read_avail) /* No progress? */
|
||||
break;
|
||||
}
|
||||
|
||||
*p = state->read_next;
|
||||
@ -346,12 +347,15 @@ drive_decompressor(struct archive_read *a, struct private_data *state)
|
||||
ssize_t ret;
|
||||
int decompressed, total_decompressed;
|
||||
char *output;
|
||||
const void *read_buf;
|
||||
|
||||
total_decompressed = 0;
|
||||
for (;;) {
|
||||
if (state->stream.avail_in == 0) {
|
||||
read_buf = state->stream.next_in;
|
||||
ret = (a->client_reader)(&a->archive, a->client_data,
|
||||
(const void **)&state->stream.next_in);
|
||||
&read_buf);
|
||||
state->stream.next_in = (void *)(uintptr_t)read_buf;
|
||||
if (ret < 0) {
|
||||
/*
|
||||
* TODO: Find a better way to handle
|
||||
|
@ -275,10 +275,10 @@ static ssize_t
|
||||
read_ahead(struct archive_read *a, const void **p, size_t min)
|
||||
{
|
||||
struct private_data *state;
|
||||
int read_avail, was_avail, ret;
|
||||
size_t read_avail;
|
||||
int ret;
|
||||
|
||||
state = (struct private_data *)a->compression_data;
|
||||
was_avail = -1;
|
||||
if (!a->client_reader) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
|
||||
"No read callback is registered? "
|
||||
@ -288,14 +288,14 @@ read_ahead(struct archive_read *a, const void **p, size_t min)
|
||||
|
||||
read_avail = state->next_out - state->read_next;
|
||||
|
||||
if (read_avail < (int)min && state->end_of_stream) {
|
||||
if (read_avail < min && state->end_of_stream) {
|
||||
if (state->end_of_stream == ARCHIVE_EOF)
|
||||
return (0);
|
||||
else
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (read_avail < (int)min) {
|
||||
if (read_avail < min) {
|
||||
memmove(state->uncompressed_buffer, state->read_next,
|
||||
read_avail);
|
||||
state->read_next = (unsigned char *)state->uncompressed_buffer;
|
||||
@ -303,7 +303,7 @@ read_ahead(struct archive_read *a, const void **p, size_t min)
|
||||
state->avail_out
|
||||
= state->uncompressed_buffer_size - read_avail;
|
||||
|
||||
while (read_avail < (int)state->uncompressed_buffer_size
|
||||
while (read_avail < state->uncompressed_buffer_size
|
||||
&& !state->end_of_stream) {
|
||||
if (state->stackp > state->stack) {
|
||||
*state->next_out++ = *--state->stackp;
|
||||
@ -465,12 +465,14 @@ getbits(struct archive_read *a, struct private_data *state, int n)
|
||||
0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff,
|
||||
0x1ff, 0x3ff, 0x7ff, 0xfff, 0x1fff, 0x3fff, 0x7fff, 0xffff
|
||||
};
|
||||
|
||||
const void *read_buf;
|
||||
|
||||
while (state->bits_avail < n) {
|
||||
if (state->avail_in <= 0) {
|
||||
read_buf = state->next_in;
|
||||
ret = (a->client_reader)(&a->archive, a->client_data,
|
||||
(const void **)&state->next_in);
|
||||
&read_buf);
|
||||
state->next_in = read_buf;
|
||||
if (ret < 0)
|
||||
return (ARCHIVE_FATAL);
|
||||
if (ret == 0)
|
||||
|
@ -258,10 +258,10 @@ static ssize_t
|
||||
read_ahead(struct archive_read *a, const void **p, size_t min)
|
||||
{
|
||||
struct private_data *state;
|
||||
int read_avail, was_avail, ret;
|
||||
size_t read_avail, was_avail;
|
||||
int ret;
|
||||
|
||||
state = (struct private_data *)a->compression_data;
|
||||
was_avail = -1;
|
||||
if (!a->client_reader) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
|
||||
"No read callback is registered? "
|
||||
@ -280,13 +280,14 @@ read_ahead(struct archive_read *a, const void **p, size_t min)
|
||||
= state->uncompressed_buffer_size - read_avail;
|
||||
}
|
||||
|
||||
while (was_avail < read_avail && /* Made some progress. */
|
||||
read_avail < (int)min && /* Haven't satisfied min. */
|
||||
read_avail < (int)state->uncompressed_buffer_size) { /* !full */
|
||||
while (read_avail < min && /* Haven't satisfied min. */
|
||||
read_avail < state->uncompressed_buffer_size) { /* !full */
|
||||
was_avail = read_avail;
|
||||
if ((ret = drive_decompressor(a, state)) != ARCHIVE_OK)
|
||||
return (ret);
|
||||
was_avail = read_avail;
|
||||
read_avail = state->stream.next_out - state->read_next;
|
||||
if (was_avail == read_avail) /* No progress? */
|
||||
break;
|
||||
}
|
||||
|
||||
*p = state->read_next;
|
||||
@ -349,10 +350,11 @@ static int
|
||||
drive_decompressor(struct archive_read *a, struct private_data *state)
|
||||
{
|
||||
ssize_t ret;
|
||||
int decompressed, total_decompressed;
|
||||
size_t decompressed, total_decompressed;
|
||||
int count, flags, header_state;
|
||||
unsigned char *output;
|
||||
unsigned char b;
|
||||
const void *read_buf;
|
||||
|
||||
flags = 0;
|
||||
count = 0;
|
||||
@ -360,8 +362,10 @@ drive_decompressor(struct archive_read *a, struct private_data *state)
|
||||
total_decompressed = 0;
|
||||
for (;;) {
|
||||
if (state->stream.avail_in == 0) {
|
||||
read_buf = state->stream.next_in;
|
||||
ret = (a->client_reader)(&a->archive, a->client_data,
|
||||
(const void **)&state->stream.next_in);
|
||||
&read_buf);
|
||||
state->stream.next_in = (unsigned char *)(uintptr_t)read_buf;
|
||||
if (ret < 0) {
|
||||
/*
|
||||
* TODO: Find a better way to handle
|
||||
|
@ -51,7 +51,7 @@ struct archive_decompress_none {
|
||||
size_t buffer_size;
|
||||
char *next; /* Current read location. */
|
||||
size_t avail; /* Bytes in my buffer. */
|
||||
const char *client_buff; /* Client buffer information. */
|
||||
const void *client_buff; /* Client buffer information. */
|
||||
size_t client_total;
|
||||
const char *client_next;
|
||||
size_t client_avail;
|
||||
@ -130,7 +130,7 @@ archive_decompressor_none_init(struct archive_read *a, const void *buff, size_t
|
||||
}
|
||||
|
||||
/* Save reference to first block of data. */
|
||||
state->client_buff = (const char *)buff;
|
||||
state->client_buff = buff;
|
||||
state->client_total = n;
|
||||
state->client_next = state->client_buff;
|
||||
state->client_avail = state->client_total;
|
||||
@ -219,8 +219,7 @@ archive_decompressor_none_read_ahead(struct archive_read *a, const void **buff,
|
||||
* aren't, hence the cast.
|
||||
*/
|
||||
bytes_read = (a->client_reader)(&a->archive,
|
||||
a->client_data,
|
||||
(const void **)&state->client_buff);
|
||||
a->client_data, &state->client_buff);
|
||||
if (bytes_read < 0) { /* Read error. */
|
||||
state->client_total = state->client_avail = 0;
|
||||
state->client_next = state->client_buff = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user