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

Skip to content

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

Merged
merged 1 commit into from
Mar 6, 2022

Conversation

oscargus
Copy link
Member

@oscargus oscargus commented Mar 4, 2022

PR Summary

Minor fix getting rid of type cast warnings (on Windows).

   C:\Users\Oscar\matplotlib\src\_path.h(843): warning C4244: 'initializing': conversion from 'double' to 'float', possible loss of data
...
    C:\Users\Oscar\matplotlib\src\_path.h(1157): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data

(Editor removed some trailing spaces.)

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@oscargus oscargus marked this pull request as draft March 4, 2022 21:51
@oscargus oscargus force-pushed the pathtypefix branch 4 times, most recently from 5ad5aee to b38f5b8 Compare March 5, 2022 00:22
@oscargus oscargus marked this pull request as ready for review March 5, 2022 09:30
@oscargus
Copy link
Member Author

oscargus commented Mar 5, 2022

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.

@oscargus oscargus changed the title MNT: Fix types in _path.h MNT: Fix types in C-code to reduce warnings Mar 5, 2022
@tacaswell tacaswell merged commit 921e9ac into matplotlib:main Mar 6, 2022
@tacaswell tacaswell added this to the v3.6.0 milestone Mar 6, 2022
@oscargus oscargus deleted the pathtypefix branch March 6, 2022 08:02
@@ -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));
Copy link
Member

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++?

QuLogic added a commit to QuLogic/matplotlib that referenced this pull request Mar 14, 2022
@@ -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);
Copy link
Contributor

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.

Copy link
Member Author

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.

oscargus added a commit that referenced this pull request Mar 15, 2022
Fix new leak in ft2font introduced in #22604
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants