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

Skip to content

Fix compiler warnings #1725

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
Feb 20, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion setupext.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ def add_tk_flags(module):
if not exists(join(F, fw + '.framework')):
break
else:
# ok, F is now directory with both frameworks. Continure
# ok, F is now directory with both frameworks. Continue
# building
tk_framework_found = 1
break
Expand Down
15 changes: 13 additions & 2 deletions src/_backend_agg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@

#include "numpy/arrayobject.h"
#include "agg_py_transforms.h"

// This C function resides in npy_3kcompat.h and is unused by
// matplotlib. This is here so that the compiler doesn't complain
// that it is unused.
extern "C" {
__attribute__((unused)) static void simple_capsule_dtor(void *ptr);
Copy link
Member

Choose a reason for hiding this comment

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

Personally, I have absolutely no idea what this does (black magic 😄). Could somebody who does give it the 👍 please?

Copy link
Member

Choose a reason for hiding this comment

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

Seems fine, except I wish there were a cleaner way to hide this warning... Don't know what that would be.

}
#include "file_compat.h"

#ifndef M_PI
Expand Down Expand Up @@ -2048,7 +2055,9 @@ RendererAgg::write_rgba(const Py::Tuple& args)
{
if (fwrite(pixBuffer, 1, NUMBYTES, fp) != NUMBYTES)
{
npy_PyFile_DupClose(py_file, fp);
if (npy_PyFile_DupClose(py_file, fp)) {
throw Py::RuntimeError("Error closing dupe file handle");
}
Copy link
Member Author

Choose a reason for hiding this comment

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

All this block does is make use of the value npy_PyFile_DupClose returns.


if (close_file) {
npy_PyFile_CloseFile(py_file);
Expand All @@ -2058,7 +2067,9 @@ RendererAgg::write_rgba(const Py::Tuple& args)
throw Py::RuntimeError("Error writing to file");
}

npy_PyFile_DupClose(py_file, fp);
if (npy_PyFile_DupClose(py_file, fp)) {
throw Py::RuntimeError("Error closing dupe file handle");
}

if (close_file) {
npy_PyFile_CloseFile(py_file);
Expand Down
4 changes: 0 additions & 4 deletions src/_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,6 @@ Image::resize(const Py::Tuple& args, const Py::Dict& kwargs)

typedef agg::span_allocator<agg::rgba8> span_alloc_type;
span_alloc_type sa;
agg::rgba8 background(agg::rgba8(int(255*bg.r),
int(255*bg.g),
int(255*bg.b),
int(255*bg.a)));

// the image path
agg::path_storage path;
Expand Down
19 changes: 16 additions & 3 deletions src/_png.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
#include "CXX/Extensions.hxx"
#include "numpy/arrayobject.h"
#include "mplutils.h"

// This C function resides in npy_3kcompat.h and is unused by
// matplotlib. This is here so that the compiler doesn't complain
// that it is unused.
extern "C" {
__attribute__((unused)) static void simple_capsule_dtor(void *ptr);
}
#include "file_compat.h"

// As reported in [3082058] build _png.so on aix
Expand Down Expand Up @@ -239,7 +246,9 @@ Py::Object _png_module::write_png(const Py::Tuple& args)

if (close_dup_file)
{
npy_PyFile_DupClose(py_file, fp);
if (npy_PyFile_DupClose(py_file, fp)) {
throw Py::RuntimeError("Error closing dupe file handle");
}
}

if (close_file)
Expand All @@ -258,7 +267,9 @@ Py::Object _png_module::write_png(const Py::Tuple& args)
delete [] row_pointers;
if (close_dup_file)
{
npy_PyFile_DupClose(py_file, fp);
if (npy_PyFile_DupClose(py_file, fp)) {
throw Py::RuntimeError("Error closing dupe file handle");
}
}

if (close_file)
Expand Down Expand Up @@ -569,7 +580,9 @@ _png_module::_read_png(const Py::Object& py_fileobj, const bool float_result,
#endif
if (close_dup_file)
{
npy_PyFile_DupClose(py_file, fp);
if (npy_PyFile_DupClose(py_file, fp)) {
throw Py::RuntimeError("Error closing dupe file handle");
}
}

if (close_file)
Expand Down