Skip to content

Commit

Permalink
Merge pull request opencv#13889 from mshabunin:enable-narrowing-warning
Browse files Browse the repository at this point in the history
* Enabled -Wnarrowing warning

* Fixed type narrowing issues

* Cast python constants

* Use long long for python constants

* Use int for python constants with fallback to long

* Update cv2.cpp
  • Loading branch information
mshabunin authored and alalek committed Feb 26, 2019
1 parent 5421d08 commit 8c1e053
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 0 additions & 1 deletion cmake/OpenCVCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ if(CV_GCC OR CV_CLANG)
add_extra_compiler_option(-Wcast-align)
add_extra_compiler_option(-Wstrict-aliasing=2)
else()
add_extra_compiler_option(-Wno-narrowing)
add_extra_compiler_option(-Wno-delete-non-virtual-dtor)
add_extra_compiler_option(-Wno-unnamed-type-template-args)
add_extra_compiler_option(-Wno-comment)
Expand Down
4 changes: 2 additions & 2 deletions modules/python/src2/cv2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1838,7 +1838,7 @@ static PyMethodDef special_methods[] = {
struct ConstDef
{
const char * name;
long val;
long long val;
};

static void init_submodule(PyObject * root, const char * name, PyMethodDef * methods, ConstDef * consts)
Expand Down Expand Up @@ -1877,7 +1877,7 @@ static void init_submodule(PyObject * root, const char * name, PyMethodDef * met
}
for (ConstDef * c = consts; c->name != NULL; ++c)
{
PyDict_SetItemString(d, c->name, PyInt_FromLong(c->val));
PyDict_SetItemString(d, c->name, PyLong_FromLongLong(c->val));
}

}
Expand Down
5 changes: 4 additions & 1 deletion modules/videoio/src/cap_v4l.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ make & enjoy!
#include <assert.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <limits>

#ifdef HAVE_CAMV4L2
#include <asm/types.h> /* for videodev2.h */
Expand Down Expand Up @@ -538,7 +539,9 @@ bool CvCaptureCAM_V4L::convertableToRgb() const

void CvCaptureCAM_V4L::v4l2_create_frame()
{
CvSize size = {form.fmt.pix.width, form.fmt.pix.height};
CV_Assert(form.fmt.pix.width <= (uint)std::numeric_limits<int>::max());
CV_Assert(form.fmt.pix.height <= (uint)std::numeric_limits<int>::max());
CvSize size = {(int)form.fmt.pix.width, (int)form.fmt.pix.height};
int channels = 3;
int depth = IPL_DEPTH_8U;

Expand Down

0 comments on commit 8c1e053

Please sign in to comment.