Skip to content

Properly pass wchar * type to giterr_set#4014

Merged
ethomson merged 2 commits into
libgit2:masterfrom
bokic:patch-1
Dec 7, 2016
Merged

Properly pass wchar * type to giterr_set#4014
ethomson merged 2 commits into
libgit2:masterfrom
bokic:patch-1

Conversation

@bokic
Copy link
Copy Markdown
Contributor

@bokic bokic commented Nov 20, 2016

Ensure correct type is passed, no garbage text is sent, and mute compiler warning.

Comment thread src/win32/w32_util.h Outdated
* not counting the NULL terminator */
if ((st->st_size = git__utf16_to_8(NULL, 0, target)) < 0) {
giterr_set(GITERR_OS, "Could not convert reparse point name for '%s'", path);
giterr_set(GITERR_OS, "Could not convert reparse point name for '%S'", path);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good catch.

IIRC, %S means that the argument should have the opposite size of the format string. So for the narrow printf family of functions, %S is a wchar_t * and for the Unicode/wide wprintf family of functions, %S is a narrow char *. Is my memory correct here?

If so, can we change this to %ls which (again, IIRC) indicates a wide string always, regardless of whether you're feeding it to printf or wprintf.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Just checked with MinGW 5.3.0, and, you are right. %S seem to reverse the character width.

So, yes %ls format is better for this case.

@ethomson
Copy link
Copy Markdown
Member

ethomson commented Dec 7, 2016

Thanks! 😀

@ethomson ethomson merged commit 1576973 into libgit2:master Dec 7, 2016
@carlosmn carlosmn mentioned this pull request Dec 10, 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.

2 participants