-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
MNT: Fix types in C-code to reduce warnings #22604
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
5ad5aee
to
b38f5b8
Compare
Turned out that MSVC does not consider snprintf as a safe function either, but I think it can stay to avoid an extra build cycle (if the rest is OK) and that it probably is safer than sprintf anyway. |
@@ -291,7 +291,7 @@ static unsigned long read_from_file_callback(FT_Stream stream, | |||
return 1; // Non-zero signals error, when count == 0. | |||
} | |||
} | |||
return n_read; | |||
return PyLong_AsUnsignedLong(PyLong_FromSsize_t(n_read)); |
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 change is new from after I reviewed; it leaks the PyLong
you just created. Anyway, I don't know why you need a PyLong
and can't just cast it in C++?
@@ -1545,7 +1545,7 @@ PyMODINIT_FUNC PyInit_ft2font(void) | |||
FT_Int major, minor, patch; | |||
char version_string[64]; | |||
FT_Library_Version(_ft2Library, &major, &minor, &patch); | |||
sprintf(version_string, "%d.%d.%d", major, minor, patch); | |||
snprintf(version_string, sizeof(version_string), "%d.%d.%d", major, minor, patch); |
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 could have been PyOS_snprintf for consistency with the rest of the codebase.
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.
OK! It still complains, so can change it.
Fix new leak in ft2font introduced in #22604
PR Summary
Minor fix getting rid of type cast warnings (on Windows).
(Editor removed some trailing spaces.)
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).