Skip to content
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

Remove redundant operations #1992

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AtariDreams
Copy link
Contributor

Some operations, like assigning to 0, or breaking after a non-returning function, are redundant and can be removed.

Copy link
Contributor

@evelikov evelikov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a handful of unrelated changes that should be dropped from this patch. Nothing too special though.


if (!mine->use_lseek)
return (0);

/* Reduce a request that would overflow the 'skip' variable. */
if (sizeof(request) > sizeof(skip)) {
int skip_bits = sizeof(skip) * 8 - 1; /* off_t is a signed type. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change.

@@ -145,6 +144,7 @@ file_skip(struct archive *a, void *client_data, int64_t request)

/* If request is too big for a long or an off_t, reduce it. */
if (sizeof(request) > sizeof(skip)) {
int skip_bits = sizeof(skip) * 8 - 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto - unrelated change.

libarchive/archive_write_add_filter_compress.c Outdated Show resolved Hide resolved
libarchive/archive_write_disk_posix.c Outdated Show resolved Hide resolved
libarchive/archive_write_set_format_gnutar.c Outdated Show resolved Hide resolved
libarchive_fe/passphrase.c Outdated Show resolved Hide resolved
cat/bsdcat.c Show resolved Hide resolved
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, please pay attention to previous suggestions. These should be separate patch (doesn't matter which MR), literally all MRs have bunch of unaddressed and unrelated whitespace changes.

Thanks o/

@@ -384,7 +384,7 @@ drive_compressor(struct archive_write_filter *f,
struct private_data *data, int flush, const void *src, size_t length)
{
ZSTD_inBuffer in = { .src = src, .size = length, .pos = 0 };
size_t ipos, opos, zstdret = 0;
size_t ipos, opos, zstdret;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to keep the = 0 here. It's not obvious by looking at only this function that data->state cannot be resetting on entry. (You would have to study every place that data->state was set to be certain of this.

@@ -265,7 +265,7 @@ archive_write_ustar_header(struct archive_write *a, struct archive_entry *entry)
/* Only regular files (not hardlinks) have data. */
if (archive_entry_hardlink(entry) != NULL ||
archive_entry_symlink(entry) != NULL ||
!(archive_entry_filetype(entry) == AE_IFREG))
archive_entry_filetype(entry) != AE_IFREG)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace is wrong here.

@@ -243,7 +243,7 @@ archive_write_v7tar_header(struct archive_write *a, struct archive_entry *entry)
/* Only regular files (not hardlinks) have data. */
if (archive_entry_hardlink(entry) != NULL ||
archive_entry_symlink(entry) != NULL ||
!(archive_entry_filetype(entry) == AE_IFREG))
archive_entry_filetype(entry) != AE_IFREG)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace is wrong here.

@@ -40,9 +40,6 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing headers must be done very carefully. Libarchive builds on a lot of different platforms, many of which have headers that behave quite differently. PLEASE make changes like this in a separate Pull Request.

Copy link
Contributor

@kientzle kientzle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Emil: There are some good changes here, but some that really should be handled separately.

@AtariDreams AtariDreams force-pushed the redundant branch 2 times, most recently from ceeca32 to 7e4ddae Compare October 18, 2023 22:17
Some operations, like assigning to 0, or breaking after a non-returning function, are redundant and can be removed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants