Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow compile with gcc -Werror=format-security #4024

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

Closed
wants to merge 1 commit into from

Conversation

dkelson
Copy link

@dkelson dkelson commented Dec 8, 2016

When building a v.25-rc1 RPM on Fedora 25, the default compiler flags include -Werror=format-security and a compile of v.25-rc1 fails in two locations with "format not a string literal and no format arguments".

Please merge this PR.

Fixes "format not a string literal and no format arguments" compile
error with -Werror=format-security
@@ -552,7 +552,7 @@ int git_index_clear(git_index *index)

static int create_index_error(int error, const char *msg)
{
giterr_set_str(GITERR_INDEX, msg);
giterr_set_str(GITERR_INDEX, "index creation error '%s'", msg);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're changing the behavior rather drastically. The name create_index_error indicates that this function creates an index error; it doesn't indicate that there was an error creating the index.

This will produce errors like:

index creation error 'Failed to read index: The index is in-memory only'

Which does not make sense.

There are a variety of options for fixing this, simply giterr_set_str(GITERR_INDEX, "%s", msg); is certainly the simplest.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I misread this. This doesn't even compile; giterr_set_str takes a string argument, not a format.

@carlosmn
Copy link
Member

giterr_set_str does not indicate to the compiler that it takes format arguments, and neither do any of the functions it calls. Indeed, this is the function you use in order to fix those warnings.

Can you share the warnings your compiler is generating? The format errors should have been fixed in #4009 which IIRC came after the RC.

@ethomson
Copy link
Member

It feels to me like you were seeing these warnings reported in your build, but those issues were coincidentally fixed to use giterr_set_str before you were able to submit a PR. Does that sound correct to you?

I'm closing this; please do resubmit a change if you think that this is not yet fixed in master.

Thanks!

@ethomson ethomson closed this Dec 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants