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
Fix a handful of compiler warnings #1862
base: master
Are you sure you want to change the base?
Conversation
4aadd92
to
d2365be
Compare
Any updates on this? |
You say this fixes compiler warnings? What compilers have you tried, and what were the warnings you saw? |
Not a maintainer here, so take this with a pinch of salt: On most, if not all platforms sizeof returns a size_t, although not many compilers will warn if the value is saved as an int. Having the commit message say, "Happens with compiler X, version Y and warning -Wfoobar" would be great. That said, the commit does a bunch of unrelated changes at once. It would be better if they are split:
The loop & whitespace ones seem superfluous, the rest are good fixes. HTH |
2218fe1
to
43e9b97
Compare
177b7ab
to
ca9c4b6
Compare
@AtariDreams please update the PR to address the earlier review suggestions. |
3c45804
to
5daa616
Compare
@evelikov Done! |
libarchive/archive_disk_acl_darwin.c
Outdated
if (tacl_entry[i].permset != 0) { | ||
archive_entry_acl_add_entry(entry, | ||
tacl_entry[i].type, tacl_entry[i].permset, | ||
tacl_entry[i].tag, -1, NULL); | ||
} | ||
} | ||
|
||
return; |
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 return removal is good but should be part of the "remove redundant" PR.
26a4a17
to
5f0588d
Compare
This fixes a couple of warnings raised by clang.
@AtariDreams I think the maintainers are looking for an answer to their earlier questions:
Personally it makes sense to also add the relevant -Wfoobar options to the autotools and cmake builds as part of this PR. This way it a) clearly illustrates/answers the above questions and b) reduces the odds of reintroducing similar changes in the future. HTH o/ |
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.
There are some good changes here and some that seem to have no reason.
I also still want to know what the warnings were. I tried compiling the current libarchive code with a recent clang with -Wall
and I don't see the warnings you're talking about.
@@ -1090,7 +1090,7 @@ MACRO(CHECK_ICONV LIB TRY_ICONV_CONST) | |||
ENDIF(HAVE_ICONV_${LIB}_${TRY_ICONV_CONST}) | |||
CMAKE_POP_CHECK_STATE() # Restore the state of the variables | |||
ENDIF(NOT HAVE_ICONV) | |||
ENDMACRO(CHECK_ICONV TRY_ICONV_CONST) | |||
ENDMACRO() |
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.
Why did you remove the argument from this ENDMACRO()
but no other? Was this one wrong somehow?
@@ -133,13 +133,13 @@ file_skip(struct archive *a, void *client_data, int64_t request) | |||
struct read_fd_data *mine = (struct read_fd_data *)client_data; | |||
int64_t skip = request; |
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.
skip
here should be off_t
since that's the type that the lseek
calls expect.
@@ -195,7 +195,7 @@ add_trivial_nfs4_acl(struct archive_entry *entry) | |||
} else if ((mode & 0010) || (mode & 0001)) | |||
tacl_entry[1].permset |= eperm; | |||
|
|||
for (i = 0; i < 6; i++) { | |||
for (i = 0; i < sizeof(tacl_entry) / sizeof(tacl_entry[0]); i++) { |
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.
Nice fix!
@@ -793,7 +793,8 @@ setup_xattrs(struct archive_read_disk *a, | |||
struct archive_entry *entry, int *fd) | |||
{ | |||
int namespaces[2]; | |||
int i, res; | |||
int res; | |||
unsigned i; |
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.
unsigned
here is not necessary.
@@ -706,7 +706,7 @@ _archive_write_disk_header(struct archive *_a, struct archive_entry *entry) | |||
const void *attr_value; | |||
size_t attr_size; | |||
int i = archive_entry_xattr_reset(a->entry); | |||
while (i--) { | |||
while (i-- > 0) { |
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.
This is a good change that fixes a real warning on some compilers.
@@ -4574,11 +4574,11 @@ set_xattrs(struct archive_write_disk *a) | |||
struct archive_string errlist; | |||
int ret = ARCHIVE_OK; | |||
int i = archive_entry_xattr_reset(entry); | |||
short fail = 0; | |||
int fail = 0; |
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.
int
is a better choice here.
static const int acl_nfs4_perm_map_size = | ||
(int)(sizeof(acl_nfs4_perm_map)/sizeof(acl_nfs4_perm_map[0])); | ||
static const size_t acl_nfs4_perm_map_size = | ||
(sizeof(acl_nfs4_perm_map) / sizeof(acl_nfs4_perm_map[0])); |
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.
This is an unnecessary style change: I generally prefer to use int
unless there's a need to do otherwise. In this case, the map is a fixed list (just above) that has less than 20 entries. So int
works perfectly fine and reduces the need for extra casting below.
This fixes a couple of warnings raised by clang.