-
Notifications
You must be signed in to change notification settings - Fork 752
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C89 support #1616
base: master
Are you sure you want to change the base?
C89 support #1616
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -114,7 +114,7 @@ enum { | |
OPTION_QUIET, | ||
OPTION_UUENCODE, | ||
OPTION_VERSION, | ||
OPTION_ZSTD, | ||
OPTION_ZSTD | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would leave the trailing commas, unless your compiler really does not like them. As you saw with the MacOS build - they are very common. |
||
}; | ||
|
||
int cpio_getopt(struct cpio *cpio); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,7 @@ struct private_data { | |
READ_DEFAULT_STREAM, | ||
READ_DEFAULT_BLOCK, | ||
READ_LEGACY_STREAM, | ||
READ_LEGACY_BLOCK, | ||
READ_LEGACY_BLOCK | ||
} stage; | ||
struct { | ||
unsigned block_independence:1; | ||
|
@@ -344,31 +344,33 @@ lz4_filter_read(struct archive_read_filter *self, const void **p) | |
state->eof = 1; | ||
*p = NULL; | ||
return (0); | ||
} | ||
uint32_t number = archive_le32dec(read_buf); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here and through the rest of the patch - do not re-indent hunks of code, just move the declaration further up. As-is it You'd want to enable |
||
__archive_read_filter_consume(self->upstream, 4); | ||
if (number == LZ4_MAGICNUMBER) | ||
return lz4_filter_read_default_stream(self, p); | ||
else if (number == LZ4_LEGACY) | ||
return lz4_filter_read_legacy_stream(self, p); | ||
else if ((number & ~0xF) == LZ4_SKIPPABLED) { | ||
read_buf = __archive_read_filter_ahead( | ||
self->upstream, 4, NULL); | ||
if (read_buf == NULL) { | ||
archive_set_error( | ||
&self->archive->archive, | ||
ARCHIVE_ERRNO_MISC, | ||
"Malformed lz4 data"); | ||
return (ARCHIVE_FATAL); | ||
} | ||
uint32_t skip_bytes = archive_le32dec(read_buf); | ||
__archive_read_filter_consume(self->upstream, | ||
4 + skip_bytes); | ||
} else { | ||
/* Ignore following unrecognized data. */ | ||
state->eof = 1; | ||
*p = NULL; | ||
return (0); | ||
uint32_t number = archive_le32dec(read_buf); | ||
__archive_read_filter_consume(self->upstream, 4); | ||
if (number == LZ4_MAGICNUMBER) | ||
return lz4_filter_read_default_stream(self, p); | ||
else if (number == LZ4_LEGACY) | ||
return lz4_filter_read_legacy_stream(self, p); | ||
else if ((number & ~0xF) == LZ4_SKIPPABLED) { | ||
read_buf = __archive_read_filter_ahead( | ||
self->upstream, 4, NULL); | ||
if (read_buf == NULL) { | ||
archive_set_error( | ||
&self->archive->archive, | ||
ARCHIVE_ERRNO_MISC, | ||
"Malformed lz4 data"); | ||
return (ARCHIVE_FATAL); | ||
} else { | ||
const uint32_t skip_bytes = archive_le32dec(read_buf); | ||
__archive_read_filter_consume(self->upstream, | ||
4 + skip_bytes); | ||
} | ||
} else { | ||
/* Ignore following unrecognized data. */ | ||
state->eof = 1; | ||
*p = NULL; | ||
return (0); | ||
} | ||
} | ||
} | ||
state->eof = 1; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -213,7 +213,9 @@ zstd_filter_read(struct archive_read_filter *self, const void **p) | |
|
||
state = (struct private_data *)self->data; | ||
|
||
out = (ZSTD_outBuffer) { state->out_block, state->out_block_size, 0 }; | ||
out.dst = state->out_block; | ||
out.pos = state->out_block_size; | ||
out.size = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original code will always zero fill any struct fields that are not mentioned. I would use either |
||
|
||
/* Try to fill the output buffer. */ | ||
while (out.pos < out.size && !state->eof) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above three seem rather uncommon/new. I would suggest doing a compile-time check if they're present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't compile on strict C89 mode without these