Skip to content

Commit

Permalink
Remove redundant operations
Browse files Browse the repository at this point in the history
Some operations, like assigning to 0, or breaking after a non-returning function, are redundant and can be removed.
  • Loading branch information
AtariDreams committed Oct 16, 2023
1 parent ee16885 commit 72033fc
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 16 deletions.
2 changes: 1 addition & 1 deletion libarchive/archive_cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ get_argument(struct archive_string *as, const char *p)
archive_string_empty(as);

/* Skip beginning space characters. */
while (*s != '\0' && *s == ' ')
while (*s == ' ')
s++;
/* Copy non-space characters. */
while (*s != '\0' && *s != ' ') {
Expand Down
1 change: 0 additions & 1 deletion libarchive/archive_entry_link_resolver.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,6 @@ archive_entry_linkify(struct archive_entry_linkresolver *res,
default:
break;
}
return;
}

static struct links_entry *
Expand Down
3 changes: 0 additions & 3 deletions libarchive/archive_read_support_filter_lzop.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ __FBSDID("$FreeBSD$");
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_LZO_LZOCONF_H
#include <lzo/lzoconf.h>
#endif
Expand Down
4 changes: 0 additions & 4 deletions libarchive/archive_read_support_filter_zstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@

__FBSDID("$FreeBSD$");

#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif

#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_write_add_filter_zstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
int ret;

for (;;) {
Expand Down
5 changes: 2 additions & 3 deletions libarchive/archive_write_disk_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -2064,7 +2064,6 @@ edit_deep_directories(struct archive_write_disk *a)
/* The chdir() succeeded; we've now shortened the path. */
a->name = tail;
}
return;
}
#endif

Expand Down Expand Up @@ -3891,7 +3890,7 @@ set_fflags(struct archive_write_disk *a)
* The first test encourages the compiler to eliminate
* all of this if it's not necessary.
*/
if ((critical_flags != 0) && (set & critical_flags)) {
if ((set & critical_flags) != 0) {
le = current_fixup(a, a->name);
if (le == NULL)
return (ARCHIVE_FATAL);
Expand Down Expand Up @@ -4632,7 +4631,7 @@ set_xattrs(struct archive_write_disk *a)
e = extattr_set_fd(a->fd, namespace, name,
value, size);
if (e == 0 && errno == 0) {
e = size;
e = (int)size;
}
} else {
e = extattr_set_link(
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_write_set_format_gnutar.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ archive_write_gnutar_header(struct archive_write *a,
/* 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)
archive_entry_set_size(entry, 0);

if (AE_IFDIR == archive_entry_filetype(entry)) {
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_write_set_format_ustar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
archive_entry_set_size(entry, 0);

if (AE_IFDIR == archive_entry_filetype(entry)) {
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_write_set_format_v7tar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
archive_entry_set_size(entry, 0);

if (AE_IFDIR == archive_entry_filetype(entry)) {
Expand Down

0 comments on commit 72033fc

Please sign in to comment.