Commit 8c1e0537 authored by Maksim Shabunin's avatar Maksim Shabunin Committed by Alexander Alekhin

Merge pull request #13889 from mshabunin:enable-narrowing-warning

* 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
parent 5421d086
...@@ -119,7 +119,6 @@ if(CV_GCC OR CV_CLANG) ...@@ -119,7 +119,6 @@ if(CV_GCC OR CV_CLANG)
add_extra_compiler_option(-Wcast-align) add_extra_compiler_option(-Wcast-align)
add_extra_compiler_option(-Wstrict-aliasing=2) add_extra_compiler_option(-Wstrict-aliasing=2)
else() else()
add_extra_compiler_option(-Wno-narrowing)
add_extra_compiler_option(-Wno-delete-non-virtual-dtor) add_extra_compiler_option(-Wno-delete-non-virtual-dtor)
add_extra_compiler_option(-Wno-unnamed-type-template-args) add_extra_compiler_option(-Wno-unnamed-type-template-args)
add_extra_compiler_option(-Wno-comment) add_extra_compiler_option(-Wno-comment)
......
...@@ -1838,7 +1838,7 @@ static PyMethodDef special_methods[] = { ...@@ -1838,7 +1838,7 @@ static PyMethodDef special_methods[] = {
struct ConstDef struct ConstDef
{ {
const char * name; const char * name;
long val; long long val;
}; };
static void init_submodule(PyObject * root, const char * name, PyMethodDef * methods, ConstDef * consts) static void init_submodule(PyObject * root, const char * name, PyMethodDef * methods, ConstDef * consts)
...@@ -1877,7 +1877,7 @@ static void init_submodule(PyObject * root, const char * name, PyMethodDef * met ...@@ -1877,7 +1877,7 @@ static void init_submodule(PyObject * root, const char * name, PyMethodDef * met
} }
for (ConstDef * c = consts; c->name != NULL; ++c) 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));
} }
} }
......
...@@ -226,6 +226,7 @@ make & enjoy! ...@@ -226,6 +226,7 @@ make & enjoy!
#include <assert.h> #include <assert.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <limits>
#ifdef HAVE_CAMV4L2 #ifdef HAVE_CAMV4L2
#include <asm/types.h> /* for videodev2.h */ #include <asm/types.h> /* for videodev2.h */
...@@ -538,7 +539,9 @@ bool CvCaptureCAM_V4L::convertableToRgb() const ...@@ -538,7 +539,9 @@ bool CvCaptureCAM_V4L::convertableToRgb() const
void CvCaptureCAM_V4L::v4l2_create_frame() 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 channels = 3;
int depth = IPL_DEPTH_8U; int depth = IPL_DEPTH_8U;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment