Skip to content

Commit 184daa1

Browse files
committed
Fixed minor issues reported by GCC 7.2
1 parent 18a4ced commit 184daa1

File tree

6 files changed

+31
-31
lines changed

6 files changed

+31
-31
lines changed

3rdparty/libjasper/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ endif(WIN32 AND NOT MINGW)
2525

2626
ocv_warnings_disable(CMAKE_C_FLAGS -Wno-implicit-function-declaration -Wno-uninitialized -Wmissing-prototypes
2727
-Wno-unused-but-set-parameter -Wmissing-declarations -Wunused -Wshadow
28-
-Wsign-compare -Wstrict-overflow)
28+
-Wsign-compare -Wstrict-overflow -Wpointer-compare)
2929
ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter) # clang
3030
ocv_warnings_disable(CMAKE_C_FLAGS /wd4013 /wd4018 /wd4101 /wd4244 /wd4267 /wd4715) # vs2005
3131

apps/traincascade/cascadeclassifier.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ bool CvCascadeClassifier::load( const string cascadeDirName )
534534
featureEvaluator->init( featureParams, numPos + numNeg, cascadeParams.winSize );
535535
fs.release();
536536

537-
char buf[10];
537+
char buf[16] = {0};
538538
for ( int si = 0; si < numStages; si++ )
539539
{
540540
sprintf( buf, "%s%d", "stage", si);

modules/core/src/lda.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ class EigenvalueDecomposition {
519519

520520
// Double QR step involving rows l:n and columns m:n
521521

522-
for (int k = m; k <= n1 - 1; k++) {
522+
for (int k = m; k < n1; k++) {
523523
bool notlast = (k != n1 - 1);
524524
if (k != m) {
525525
p = H[k][k - 1];
@@ -761,7 +761,7 @@ class EigenvalueDecomposition {
761761
int low = 0;
762762
int high = n - 1;
763763

764-
for (int m = low + 1; m <= high - 1; m++) {
764+
for (int m = low + 1; m < high; m++) {
765765

766766
// Scale column.
767767

@@ -822,7 +822,7 @@ class EigenvalueDecomposition {
822822
}
823823
}
824824

825-
for (int m = high - 1; m >= low + 1; m--) {
825+
for (int m = high - 1; m > low; m--) {
826826
if (H[m][m - 1] != 0.0) {
827827
for (int i = m + 1; i <= high; i++) {
828828
ort[i] = H[i][m - 1];
@@ -1083,7 +1083,7 @@ void LDA::lda(InputArrayOfArrays _src, InputArray _lbls) {
10831083
<< std::endl;
10841084
}
10851085
// clip number of components to be a valid number
1086-
if ((_num_components <= 0) || (_num_components > (C - 1))) {
1086+
if ((_num_components <= 0) || (_num_components >= C)) {
10871087
_num_components = (C - 1);
10881088
}
10891089
// holds the mean over all classes

modules/imgproc/src/resize.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3173,7 +3173,7 @@ void resize(int src_type,
31733173
short* ialpha = (short*)alpha;
31743174
float* beta = alpha + width*ksize;
31753175
short* ibeta = ialpha + width*ksize;
3176-
float cbuf[MAX_ESIZE];
3176+
float cbuf[MAX_ESIZE] = {0};
31773177

31783178
for( dx = 0; dx < dsize.width; dx++ )
31793179
{

modules/objdetect/test/test_cascadeandhog.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void CV_DetectorTest::run( int )
209209
vector<string>::const_iterator it = imageFilenames.begin();
210210
for( int ii = 0; it != imageFilenames.end(); ++it, ii++ )
211211
{
212-
char buf[10];
212+
char buf[16] = {0};
213213
sprintf( buf, "%s%d", "img_", ii );
214214
//cvWriteComment( validationFS.fs, buf, 0 );
215215
validationFS << *it;
@@ -265,7 +265,7 @@ int CV_DetectorTest::runTestCase( int detectorIdx, vector<vector<Rect> >& object
265265
Mat image = images[ii];
266266
if( image.empty() )
267267
{
268-
char msg[30];
268+
char msg[50] = {0};
269269
sprintf( msg, "%s %d %s", "image ", ii, " can not be read" );
270270
ts->printf( cvtest::TS::LOG, msg );
271271
return cvtest::TS::FAIL_INVALID_TEST_DATA;
@@ -278,7 +278,7 @@ int CV_DetectorTest::runTestCase( int detectorIdx, vector<vector<Rect> >& object
278278

279279
if( write_results )
280280
{
281-
char buf[10];
281+
char buf[16] = {0};
282282
sprintf( buf, "%s%d", "img_", ii );
283283
string imageIdxStr = buf;
284284
validationFS << imageIdxStr << "[:";
@@ -313,7 +313,7 @@ int CV_DetectorTest::validate( int detectorIdx, vector<vector<Rect> >& objects )
313313
int noPair = 0;
314314

315315
// read validation rectangles
316-
char buf[10];
316+
char buf[16] = {0};
317317
sprintf( buf, "%s%d", "img_", imageIdx );
318318
string imageIdxStr = buf;
319319
FileNode node = validationFS.getFirstTopLevelNode()[VALIDATION][detectorNames[detectorIdx]][imageIdxStr];

modules/videoio/src/cap_libv4l.cpp

+20-20
Original file line numberDiff line numberDiff line change
@@ -393,27 +393,27 @@ static int xioctl( int fd, int request, void *arg)
393393
Returns the global numCameras with the correct value (we hope) */
394394

395395
static void icvInitCapture_V4L() {
396-
int deviceHandle;
397-
int CameraNumber;
398-
char deviceName[MAX_DEVICE_DRIVER_NAME];
396+
int deviceHandle;
397+
int CameraNumber;
398+
char deviceName[MAX_DEVICE_DRIVER_NAME];
399399

400-
CameraNumber = 0;
401-
while(CameraNumber < MAX_CAMERAS) {
402-
/* Print the CameraNumber at the end of the string with a width of one character */
403-
sprintf(deviceName, "/dev/video%1d", CameraNumber);
404-
/* Test using an open to see if this new device name really does exists. */
405-
deviceHandle = open(deviceName, O_RDONLY);
406-
if (deviceHandle != -1) {
407-
/* This device does indeed exist - add it to the total so far */
408-
// add indexList
409-
indexList|=(1 << CameraNumber);
410-
numCameras++;
411-
}
412-
if (deviceHandle != -1)
413-
close(deviceHandle);
414-
/* Set up to test the next /dev/video source in line */
415-
CameraNumber++;
416-
} /* End while */
400+
CameraNumber = 0;
401+
while(CameraNumber < MAX_CAMERAS) {
402+
/* Print the CameraNumber at the end of the string with a width of one character */
403+
sprintf(deviceName, "/dev/video%1d", CameraNumber);
404+
/* Test using an open to see if this new device name really does exists. */
405+
deviceHandle = open(deviceName, O_RDONLY);
406+
if (deviceHandle != -1) {
407+
/* This device does indeed exist - add it to the total so far */
408+
numCameras++;
409+
// add indexList
410+
indexList|=(1 << CameraNumber);
411+
}
412+
if (deviceHandle != -1)
413+
close(deviceHandle);
414+
/* Set up to test the next /dev/video source in line */
415+
CameraNumber++;
416+
} /* End while */
417417

418418
}; /* End icvInitCapture_V4L */
419419

0 commit comments

Comments
 (0)