-
Notifications
You must be signed in to change notification settings - Fork 2.5k
use giterr_set_str()
wherever possible
#4009
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
Conversation
I'm not sure that I fully understand your comment - |
What compiler are you using? We do run with In the places were we don't expect to perform any substitution, we should rather be using |
@@ -2358,7 +2358,7 @@ static size_t read_entry( | |||
entry.path = (char *)path_ptr; | |||
} else { | |||
size_t varint_len; | |||
size_t shared = git_decode_varint((const unsigned char *)path_ptr, | |||
size_t shared = git_decode_varint((const unsigned char *)path_ptr, |
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.
Let's not do unrelated whitespace changes.
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.
Sure! My editor corrected it by default.
@ethomson I was unsure about it. But since that warning only occurs when the above-specified thing happens, I assumed it to be some technicality within variable arguments (I am not sure about this). I guess it is better to remove it altogether. |
@carlosmn There seems to be a problem with both of our local builds I guess because after I pushed this out, I was checking out the travis-ci builds for master as well as for this PR where you can easily see that it is displaying 3 warnings in which this is one of them. Also, I am not getting the other two warnings locally which are clearly shown in the master build on travis-ci. |
`giterr_set()` is used when it is required to format a string, and since we don't really require it for this case, it is better to stick to `giterr_set_str()`. This also suppresses a warning(-Wformat-security) raised by the compiler. Signed-off-by: Pranit Bauva <[email protected]>
const char *
because giterr_set() expects itgiterr_set_str()
wherever possible
The warning I see on that build is
which is the issue with formatting that @ethomson mentioned, it's nothing to do with Ubuntu used to harden their GCC and the version string on Travis suggests they're still adding patches which is why I don't see this on my Debian GCC. |
@carlosmn Thanks for explaining! I was under the impression that it would only occur because of |
I've got a hardened gcc, as well, but it in fact does not contain "-Wformat-security". Which makes me think - how about adding a build job that compiles with "-Werror" so that we catch compilation warnings early on? Oh wait, there are these curl warnings which would cause the build to fail... sucks :/ |
That curl weirdness is disappointing, but I'd like to get rid of curl regardless. We can certainly add a few choice options like |
Makes sense to me, yes |
giterr_set()
is used when it is required to format a string, and sincewe don't really require it for this case, it is better to stick to
giterr_set_str()
.This also suppresses a warning(-Wformat-security) raised by the compiler.