use giterr_set_str() wherever possible#4009
use giterr_set_str() wherever possible#4009carlosmn merged 1 commit intolibgit2:masterlibgit2/libgit2:masterfrom pranitbauva1997:fix-string-formatCopy head branch name to clipboard
giterr_set_str() wherever possible#4009Conversation
|
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 |
src/index.c
Outdated
| } 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.
Let's not do unrelated whitespace changes.
There was a problem hiding this comment.
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 <pranit.bauva@gmail.com>
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.