From 06ac4a110d1ce888aeef9a5a95a59c07279d1c03 Mon Sep 17 00:00:00 2001 From: "smparkes@smparkes.net" Date: Tue, 29 Nov 2011 19:58:18 +0000 Subject: [PATCH] Turn on more conservative warnings in C++ and a few related cleanups. Not quite gcc -pedantic clean: there are some variable-length auto arrays that aren't standard C++. I don't want to touch those at this point. git-svn-id: https://zxing.googlecode.com/svn/trunk@2056 59b500cc-1b3d-0410-9834-0bbf25fbcc57 --- cpp/SConscript | 4 ++++ cpp/core/src/zxing/BarcodeFormat.cpp | 4 +--- cpp/core/src/zxing/LuminanceSource.cpp | 4 ++++ .../zxing/common/detector/WhiteRectangleDetector.cpp | 2 +- cpp/core/src/zxing/datamatrix/DataMatrixReader.cpp | 2 ++ .../multi/qrcode/detector/MultiFinderPatternFinder.cpp | 5 +++++ .../multi/qrcode/detector/MultiFinderPatternFinder.h | 8 ++++---- cpp/core/src/zxing/oned/Code128Reader.h | 10 +++------- cpp/core/src/zxing/oned/EAN13Reader.cpp | 5 ++--- cpp/core/src/zxing/oned/EAN8Reader.cpp | 5 ++--- cpp/core/src/zxing/oned/ITFReader.cpp | 6 +++--- cpp/core/src/zxing/oned/ITFReader.h | 10 +++------- cpp/core/src/zxing/oned/UPCEANReader.h | 10 +++------- cpp/core/src/zxing/oned/UPCEReader.cpp | 5 ++--- cpp/core/src/zxing/oned/UPCEReader.h | 3 --- cpp/core/src/zxing/qrcode/decoder/DataMask.cpp | 4 ++-- cpp/core/src/zxing/qrcode/detector/QREdgeDetector.cpp | 5 ++--- 17 files changed, 43 insertions(+), 49 deletions(-) diff --git a/cpp/SConscript b/cpp/SConscript index 5277c48c2..a730ad5c9 100644 --- a/cpp/SConscript +++ b/cpp/SConscript @@ -19,6 +19,10 @@ else: if env['PIC']: flags.append("-fPIC") +flags.append("-Wextra -Werror") +# Can't enable unless we get rid of the dynamic variable length arrays +# flags.append("-pedantic") + compile_options['CXXFLAGS'] = ' '.join(flags) compile_options['LINKFLAGS'] = "-ldl" diff --git a/cpp/core/src/zxing/BarcodeFormat.cpp b/cpp/core/src/zxing/BarcodeFormat.cpp index 7badb2abf..c0623f379 100755 --- a/cpp/core/src/zxing/BarcodeFormat.cpp +++ b/cpp/core/src/zxing/BarcodeFormat.cpp @@ -1,7 +1,5 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- /* - * BarcodeFormat.cpp - * zxing - * * Created by Christian Brunschen on 13/05/2008. * Copyright 2008 ZXing authors All rights reserved. * diff --git a/cpp/core/src/zxing/LuminanceSource.cpp b/cpp/core/src/zxing/LuminanceSource.cpp index 99d54dffa..0ba1ff1e1 100644 --- a/cpp/core/src/zxing/LuminanceSource.cpp +++ b/cpp/core/src/zxing/LuminanceSource.cpp @@ -35,6 +35,10 @@ bool LuminanceSource::isCropSupported() const { } Ref LuminanceSource::crop(int left, int top, int width, int height) { + (void)left; + (void)top; + (void)width; + (void)height; throw IllegalArgumentException("This luminance source does not support cropping."); } diff --git a/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.cpp b/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.cpp index 735127b78..87b409957 100644 --- a/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.cpp +++ b/cpp/core/src/zxing/common/detector/WhiteRectangleDetector.cpp @@ -33,7 +33,7 @@ int WhiteRectangleDetector::CORR = 1; WhiteRectangleDetector::WhiteRectangleDetector(Ref image) : image_(image) { width_ = image->getWidth(); height_ = image->getHeight(); -}; +} /** *

diff --git a/cpp/core/src/zxing/datamatrix/DataMatrixReader.cpp b/cpp/core/src/zxing/datamatrix/DataMatrixReader.cpp index 74a1b2c63..53366e4fd 100644 --- a/cpp/core/src/zxing/datamatrix/DataMatrixReader.cpp +++ b/cpp/core/src/zxing/datamatrix/DataMatrixReader.cpp @@ -1,3 +1,4 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- /* * DataMatrixReader.cpp * zxing @@ -32,6 +33,7 @@ DataMatrixReader::DataMatrixReader() : } Ref DataMatrixReader::decode(Ref image, DecodeHints hints) { + (void)hints; #ifdef DEBUG cout << "decoding image " << image.object_ << ":\n" << flush; #endif diff --git a/cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp b/cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp index c7694f256..b93b4111a 100644 --- a/cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp +++ b/cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.cpp @@ -25,6 +25,11 @@ namespace zxing{ namespace multi { using namespace zxing::qrcode; +const float MultiFinderPatternFinder::MAX_MODULE_COUNT_PER_EDGE = 180; +const float MultiFinderPatternFinder::MIN_MODULE_COUNT_PER_EDGE = 9; +const float MultiFinderPatternFinder::DIFF_MODSIZE_CUTOFF_PERCENT = 0.05f; +const float MultiFinderPatternFinder::DIFF_MODSIZE_CUTOFF = 0.5f; + bool compareModuleSize(Ref a, Ref b){ float value = a->getEstimatedModuleSize() - b->getEstimatedModuleSize(); return value < 0.0; diff --git a/cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h b/cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h index b6db8107d..c700273ee 100644 --- a/cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h +++ b/cpp/core/src/zxing/multi/qrcode/detector/MultiFinderPatternFinder.h @@ -27,10 +27,10 @@ class MultiFinderPatternFinder : zxing::qrcode::FinderPatternFinder { private: std::vector > > selectBestPatterns(); - static const float MAX_MODULE_COUNT_PER_EDGE = 180; - static const float MIN_MODULE_COUNT_PER_EDGE = 9; - static const float DIFF_MODSIZE_CUTOFF_PERCENT = 0.05f; - static const float DIFF_MODSIZE_CUTOFF = 0.5f; + static const float MAX_MODULE_COUNT_PER_EDGE; + static const float MIN_MODULE_COUNT_PER_EDGE; + static const float DIFF_MODSIZE_CUTOFF_PERCENT; + static const float DIFF_MODSIZE_CUTOFF; public: MultiFinderPatternFinder(Ref image, Ref resultPointCallback); diff --git a/cpp/core/src/zxing/oned/Code128Reader.h b/cpp/core/src/zxing/oned/Code128Reader.h index b0bf5d103..065bd2f48 100644 --- a/cpp/core/src/zxing/oned/Code128Reader.h +++ b/cpp/core/src/zxing/oned/Code128Reader.h @@ -1,9 +1,7 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __CODE_128_READER_H__ #define __CODE_128_READER_H__ /* - * Code128Reader.h - * ZXing - * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,10 +26,8 @@ namespace zxing { class Code128Reader : public OneDReader { private: - //static const unsigned int MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.25f); - enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.25f)}; - //static const int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.7f); - enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.7f)}; + enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 250/1000)}; + enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 700/1000)}; static const int CODE_SHIFT = 98; static const int CODE_CODE_C = 99; diff --git a/cpp/core/src/zxing/oned/EAN13Reader.cpp b/cpp/core/src/zxing/oned/EAN13Reader.cpp index 223c79a2f..48f440321 100644 --- a/cpp/core/src/zxing/oned/EAN13Reader.cpp +++ b/cpp/core/src/zxing/oned/EAN13Reader.cpp @@ -1,7 +1,5 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- /* - * EAN13Reader.cpp - * ZXing - * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,6 +29,7 @@ namespace zxing { int EAN13Reader::decodeMiddle(Ref row, int startGuardBegin, int startGuardEnd, std::string& resultString) { + (void)startGuardBegin; const int countersLen = 4; int counters[countersLen] = { 0, 0, 0, 0 }; diff --git a/cpp/core/src/zxing/oned/EAN8Reader.cpp b/cpp/core/src/zxing/oned/EAN8Reader.cpp index 05ff5cb10..2568948cb 100644 --- a/cpp/core/src/zxing/oned/EAN8Reader.cpp +++ b/cpp/core/src/zxing/oned/EAN8Reader.cpp @@ -1,7 +1,5 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- /* - * EAN8Reader.cpp - * ZXing - * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,6 +25,7 @@ namespace zxing { int EAN8Reader::decodeMiddle(Ref row, int startGuardBegin, int startGuardEnd, std::string& resultString){ + (void)startGuardBegin; const int countersLen = 4; int counters[countersLen] = { 0, 0, 0, 0 }; diff --git a/cpp/core/src/zxing/oned/ITFReader.cpp b/cpp/core/src/zxing/oned/ITFReader.cpp index e37bad7f2..1fa72673e 100644 --- a/cpp/core/src/zxing/oned/ITFReader.cpp +++ b/cpp/core/src/zxing/oned/ITFReader.cpp @@ -1,7 +1,5 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- /* - * ITFReader.cpp - * ZXing - * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -240,6 +238,8 @@ namespace zxing { * @throws ReaderException if the quiet zone cannot be found, a ReaderException is thrown. */ void ITFReader::validateQuietZone(Ref row, int startPattern) { + (void)row; + (void)startPattern; //#pragma mark needs some corrections // int quietCount = narrowLineWidth * 10; // expect to find this many pixels of quiet zone // diff --git a/cpp/core/src/zxing/oned/ITFReader.h b/cpp/core/src/zxing/oned/ITFReader.h index 81ebd0bf6..29bba0c00 100644 --- a/cpp/core/src/zxing/oned/ITFReader.h +++ b/cpp/core/src/zxing/oned/ITFReader.h @@ -1,10 +1,8 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __ITF_READER_H__ #define __ITF_READER_H__ /* - * ITFReader.h - * ZXing - * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,10 +27,8 @@ namespace zxing { class ITFReader : public OneDReader { private: - //static const unsigned int MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f); - enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f)}; - //static const int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f); - enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.8f)}; + enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 420/1000)}; + enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 800/1000)}; // Stores the actual narrow line width of the image being decoded. int narrowLineWidth; diff --git a/cpp/core/src/zxing/oned/UPCEANReader.h b/cpp/core/src/zxing/oned/UPCEANReader.h index a9e1f9b4b..36d0ce0ab 100644 --- a/cpp/core/src/zxing/oned/UPCEANReader.h +++ b/cpp/core/src/zxing/oned/UPCEANReader.h @@ -1,10 +1,8 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- #ifndef __UPC_EAN_READER_H__ #define __UPC_EAN_READER_H__ /* - * UPCEANReader.h - * ZXing - * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,10 +32,8 @@ namespace zxing { class UPCEANReader : public OneDReader { private: - //static const unsigned int MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f); - enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.42f)}; - //static const int MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.7f); - enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 0.7f)}; + enum {MAX_AVG_VARIANCE = (unsigned int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 420/1000)}; + enum {MAX_INDIVIDUAL_VARIANCE = (int) (PATTERN_MATCH_RESULT_SCALE_FACTOR * 700/1000)}; static bool findStartGuardPattern(Ref row, int* rangeStart, int* rangeEnd); diff --git a/cpp/core/src/zxing/oned/UPCEReader.cpp b/cpp/core/src/zxing/oned/UPCEReader.cpp index 520512ed6..b052dbda9 100644 --- a/cpp/core/src/zxing/oned/UPCEReader.cpp +++ b/cpp/core/src/zxing/oned/UPCEReader.cpp @@ -1,7 +1,5 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- /* - * UPCEReader.cpp - * ZXing - * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -44,6 +42,7 @@ namespace zxing { int UPCEReader::decodeMiddle(Ref row, int startGuardBegin, int startGuardEnd, std::string& resultString) { + (void)startGuardBegin; const int countersLen = 4; int counters[countersLen] = { 0, 0, 0, 0 }; diff --git a/cpp/core/src/zxing/oned/UPCEReader.h b/cpp/core/src/zxing/oned/UPCEReader.h index 0f4c61fb0..a6303b19e 100644 --- a/cpp/core/src/zxing/oned/UPCEReader.h +++ b/cpp/core/src/zxing/oned/UPCEReader.h @@ -2,9 +2,6 @@ #define __UPC_E_READER_H__ /* - * UPCEReader.h - * ZXing - * * Copyright 2010 ZXing authors All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/cpp/core/src/zxing/qrcode/decoder/DataMask.cpp b/cpp/core/src/zxing/qrcode/decoder/DataMask.cpp index 9b293b13c..b231a17c1 100644 --- a/cpp/core/src/zxing/qrcode/decoder/DataMask.cpp +++ b/cpp/core/src/zxing/qrcode/decoder/DataMask.cpp @@ -70,7 +70,7 @@ public: */ class DataMask001 : public DataMask { public: - bool isMasked(size_t x, size_t y) { + bool isMasked(size_t x, size_t) { // return (x & 0x01) == 0; return (x % 2) == 0; } @@ -81,7 +81,7 @@ public: */ class DataMask010 : public DataMask { public: - bool isMasked(size_t x, size_t y) { + bool isMasked(size_t, size_t y) { return y % 3 == 0; } }; diff --git a/cpp/core/src/zxing/qrcode/detector/QREdgeDetector.cpp b/cpp/core/src/zxing/qrcode/detector/QREdgeDetector.cpp index b2162ef50..211f5daf0 100644 --- a/cpp/core/src/zxing/qrcode/detector/QREdgeDetector.cpp +++ b/cpp/core/src/zxing/qrcode/detector/QREdgeDetector.cpp @@ -1,7 +1,5 @@ +// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*- /* - * QREdgeDetector.cpp - * zxing - * * Created by Ralf Kistner on 7/12/2009. * Copyright 2008 ZXing authors All rights reserved. * @@ -61,6 +59,7 @@ Ref QREdgeDetector::createTransform(Ref topLe Point QREdgeDetector::findCorner(const BitMatrix& image, Point topLeft, Point topRight, Point bottomLeft, int dimension) { + (void)dimension; Point bottomRight = guessLastPattern(topLeft, topRight, bottomLeft); Line bottomEst = findPatternEdge(image, bottomLeft, topLeft, bottomRight, false);