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 18, 2023
1 parent 2edd881 commit 7e4ddae
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cat/bsdcat.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ main(int argc, char **argv)
bsdcat->argv = argv;
bsdcat->argc = argc;

while ((c = bsdcat_getopt(bsdcat)) != -1) {
if ((c = bsdcat_getopt(bsdcat)) != -1) {
switch (c) {
case 'h':
usage(stdout, 0);
Expand Down
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
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 7e4ddae

Please sign in to comment.