diff options
author | Lei Zhang <thestig@chromium.org> | 2016-02-24 15:26:50 -0800 |
---|---|---|
committer | Lei Zhang <thestig@chromium.org> | 2016-02-24 15:26:50 -0800 |
commit | 38eaaf36b09b816b963015e33dc4eb02580e0462 (patch) | |
tree | 9a2721eb404a2de4ddce91b50cac25b2cac0edb1 /xfa/src/fxbarcode/pdf417 | |
parent | e1fb98394a6885cf03bdc6391e5a3878aad5b375 (diff) | |
download | pdfium-38eaaf36b09b816b963015e33dc4eb02580e0462.tar.xz |
Remove foo != NULL checks in xfa/src/fxbarcode.
R=dsinclair@chromium.org
Review URL: https://codereview.chromium.org/1726373002 .
Diffstat (limited to 'xfa/src/fxbarcode/pdf417')
7 files changed, 29 insertions, 31 deletions
diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417.cpp index c8b7c4cffa..c06f8112da 100644 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417.cpp +++ b/xfa/src/fxbarcode/pdf417/BC_PDF417.cpp @@ -553,7 +553,7 @@ CFX_Int32Array* CBC_PDF417::determineDimensions( } FX_FLOAT newRatio = ((17 * cols + 69) * DEFAULT_MODULE_WIDTH) / (rows * HEIGHT); - if (dimension != NULL && + if (dimension && fabsf(newRatio - PREFERRED_RATIO) > fabsf(ratio - PREFERRED_RATIO)) { continue; } diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp index df1ab78ba5..6deef4c969 100644 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp +++ b/xfa/src/fxbarcode/pdf417/BC_PDF417BoundingBox.cpp @@ -33,8 +33,7 @@ CBC_BoundingBox::CBC_BoundingBox(CBC_CommonBitMatrix* image, int32_t& e) { if ((topLeft == NULL && topRight == NULL) || (bottomLeft == NULL && bottomRight == NULL) || - (topLeft != NULL && bottomLeft == NULL) || - (topRight != NULL && bottomRight == NULL)) { + (topLeft && bottomLeft == NULL) || (topRight && bottomRight == NULL)) { e = BCExceptionNotFoundInstance; } init(image, topLeft, bottomLeft, topRight, bottomRight); diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp index f48faa3bb7..b9eee7c446 100644 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp +++ b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResult.cpp @@ -110,7 +110,7 @@ CFX_ByteString CBC_DetectionResult::toString() { } void CBC_DetectionResult::adjustIndicatorColumnRowNumbers( CBC_DetectionResultColumn* detectionResultColumn) { - if (detectionResultColumn != NULL) { + if (detectionResultColumn) { ((CBC_DetectionResultRowIndicatorColumn*)detectionResultColumn) ->adjustCompleteIndicatorColumnRowNumbers(*m_barcodeMetadata); } @@ -156,8 +156,8 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromBothRI() { ->getCodewords(); for (int32_t codewordsRow = 0; codewordsRow < LRIcodewords->GetSize(); codewordsRow++) { - if (LRIcodewords->GetAt(codewordsRow) != NULL && - RRIcodewords->GetAt(codewordsRow) != NULL && + if (LRIcodewords->GetAt(codewordsRow) && + RRIcodewords->GetAt(codewordsRow) && ((CBC_Codeword*)LRIcodewords->GetAt(codewordsRow))->getRowNumber() == ((CBC_Codeword*)RRIcodewords->GetAt(codewordsRow)) ->getRowNumber()) { @@ -208,7 +208,7 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromRRI() { m_detectionResultColumns.GetAt(barcodeColumn)) ->getCodewords() ->GetAt(codewordsRow); - if (codeword != NULL) { + if (codeword) { invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword); if (!codeword->hasValidRowNumber()) { @@ -243,7 +243,7 @@ int32_t CBC_DetectionResult::adjustRowNumbersFromLRI() { m_detectionResultColumns[barcodeColumn]) ->getCodewords() ->GetAt(codewordsRow); - if (codeword != NULL) { + if (codeword) { invalidRowCounts = adjustRowNumberIfValid(rowIndicatorRowNumber, invalidRowCounts, codeword); if (!codeword->hasValidRowNumber()) { @@ -280,7 +280,7 @@ void CBC_DetectionResult::adjustRowNumbers(int32_t barcodeColumn, barcodeColumn - 1)) ->getCodewords(); CFX_PtrArray* nextColumnCodewords = previousColumnCodewords; - if (m_detectionResultColumns[barcodeColumn + 1] != NULL) { + if (m_detectionResultColumns[barcodeColumn + 1]) { nextColumnCodewords = ((CBC_DetectionResultColumn*) m_detectionResultColumns[barcodeColumn + 1]) ->getCodewords(); diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp index 9c492ba010..e375b7c30f 100644 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp +++ b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultColumn.cpp @@ -41,21 +41,21 @@ CBC_DetectionResultColumn::~CBC_DetectionResultColumn() { } CBC_Codeword* CBC_DetectionResultColumn::getCodewordNearby(int32_t imageRow) { CBC_Codeword* codeword = getCodeword(imageRow); - if (codeword != NULL) { + if (codeword) { return codeword; } for (int32_t i = 1; i < MAX_NEARBY_DISTANCE; i++) { int32_t nearImageRow = imageRowToCodewordIndex(imageRow) - i; if (nearImageRow >= 0) { codeword = (CBC_Codeword*)m_codewords->GetAt(nearImageRow); - if (codeword != NULL) { + if (codeword) { return codeword; } } nearImageRow = imageRowToCodewordIndex(imageRow) + i; if (nearImageRow < m_codewords->GetSize()) { codeword = (CBC_Codeword*)m_codewords->GetAt(nearImageRow); - if (codeword != NULL) { + if (codeword) { return codeword; } } diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp index a5d61b9210..403c34c5fd 100644 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp +++ b/xfa/src/fxbarcode/pdf417/BC_PDF417DetectionResultRowIndicatorColumn.cpp @@ -42,7 +42,7 @@ CBC_DetectionResultRowIndicatorColumn:: void CBC_DetectionResultRowIndicatorColumn::setRowNumbers() { for (int32_t i = 0; i < m_codewords->GetSize(); i++) { CBC_Codeword* codeword = (CBC_Codeword*)m_codewords->GetAt(i); - if (codeword != NULL) { + if (codeword) { codeword->setRowNumberAsRowIndicatorColumn(); } } @@ -119,7 +119,7 @@ CFX_Int32Array* CBC_DetectionResultRowIndicatorColumn::getRowHeights( result->SetSize(barcodeMetadata->getRowCount()); for (int32_t i = 0; i < getCodewords()->GetSize(); i++) { CBC_Codeword* codeword = (CBC_Codeword*)getCodewords()->GetAt(i); - if (codeword != NULL) { + if (codeword) { result->SetAt(codeword->getRowNumber(), result->GetAt(codeword->getRowNumber()) + 1); } diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp index 273f4906d1..54556af97c 100644 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp +++ b/xfa/src/fxbarcode/pdf417/BC_PDF417Detector.cpp @@ -124,10 +124,10 @@ CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, for (int32_t i = 0; i < barcodeCoordinates->GetSize(); i++) { CFX_PtrArray* barcodeCoordinate = (CFX_PtrArray*)barcodeCoordinates->GetAt(i); - if (barcodeCoordinate->GetAt(1) != NULL) { + if (barcodeCoordinate->GetAt(1)) { row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(1))->GetY(); } - if (barcodeCoordinate->GetAt(3) != NULL) { + if (barcodeCoordinate->GetAt(3)) { row = row > ((CBC_ResultPoint*)barcodeCoordinate->GetAt(3))->GetY(); } } @@ -142,7 +142,7 @@ CFX_PtrArray* CBC_Detector::detect(FX_BOOL multiple, if (!multiple) { break; } - if (vertices->GetAt(2) != NULL) { + if (vertices->GetAt(2)) { column = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetX(); row = (int32_t)((CBC_ResultPoint*)vertices->GetAt(2))->GetY(); } else { @@ -167,7 +167,7 @@ CFX_PtrArray* CBC_Detector::findVertices(CBC_CommonBitMatrix* matrix, sizeof(INDEXES_START_PATTERN) / sizeof(INDEXES_START_PATTERN[0])); startptr->RemoveAll(); delete startptr; - if (result->GetAt(4) != NULL) { + if (result->GetAt(4)) { startColumn = (int32_t)((CBC_ResultPoint*)result->GetAt(4))->GetX(); startRow = (int32_t)((CBC_ResultPoint*)result->GetAt(4))->GetY(); } @@ -204,12 +204,12 @@ CFX_PtrArray* CBC_Detector::findRowsWithPattern(CBC_CommonBitMatrix* matrix, CFX_Int32Array* loc = findGuardPattern(matrix, startColumn, startRow, width, FALSE, pattern, patternLength, counters); - if (loc != NULL) { + if (loc) { while (startRow > 0) { CFX_Int32Array* previousRowLoc = findGuardPattern(matrix, startColumn, --startRow, width, FALSE, pattern, patternLength, counters); - if (previousRowLoc != NULL) { + if (previousRowLoc) { delete loc; loc = previousRowLoc; } else { @@ -236,8 +236,7 @@ CFX_PtrArray* CBC_Detector::findRowsWithPattern(CBC_CommonBitMatrix* matrix, CFX_Int32Array* loc = findGuardPattern(matrix, previousRowLoc[0], stopRow, width, FALSE, pattern, patternLength, counters); - if (loc != NULL && - abs(previousRowLoc[0] - loc->GetAt(0)) < MAX_PATTERN_DRIFT && + if (loc && abs(previousRowLoc[0] - loc->GetAt(0)) < MAX_PATTERN_DRIFT && abs(previousRowLoc[1] - loc->GetAt(1)) < MAX_PATTERN_DRIFT) { previousRowLoc.Copy(*loc); skippedRowCount = 0; diff --git a/xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp b/xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp index 8090c79975..820b15e91d 100644 --- a/xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp +++ b/xfa/src/fxbarcode/pdf417/BC_PDF417ScanningDecoder.cpp @@ -70,12 +70,12 @@ CBC_CommonDecoderResult* CBC_PDF417ScanningDecoder::decode( CBC_DetectionResultRowIndicatorColumn* rightRowIndicatorColumn = NULL; CBC_DetectionResult* detectionResult = NULL; for (int32_t i = 0; i < 2; i++) { - if (imageTopLeft != NULL) { + if (imageTopLeft) { leftRowIndicatorColumn = getRowIndicatorColumn(image, boundingBox, *imageTopLeft, TRUE, minCodewordWidth, maxCodewordWidth); } - if (imageTopRight != NULL) { + if (imageTopRight) { rightRowIndicatorColumn = getRowIndicatorColumn(image, boundingBox, *imageTopRight, FALSE, minCodewordWidth, maxCodewordWidth); @@ -108,7 +108,7 @@ CBC_CommonDecoderResult* CBC_PDF417ScanningDecoder::decode( barcodeColumnCount++) { int32_t barcodeColumn = leftToRight ? barcodeColumnCount : maxBarcodeColumn - barcodeColumnCount; - if (detectionResult->getDetectionResultColumn(barcodeColumn) != NULL) { + if (detectionResult->getDetectionResultColumn(barcodeColumn)) { continue; } CBC_DetectionResultColumn* detectionResultColumn = NULL; @@ -135,7 +135,7 @@ CBC_CommonDecoderResult* CBC_PDF417ScanningDecoder::decode( CBC_Codeword* codeword = detectCodeword( image, boundingBox->getMinX(), boundingBox->getMaxX(), leftToRight, startColumn, imageRow, minCodewordWidth, maxCodewordWidth); - if (codeword != NULL) { + if (codeword) { detectionResultColumn->setCodeword(imageRow, codeword); previousStartColumn = startColumn; minCodewordWidth = minCodewordWidth < codeword->getWidth() @@ -310,7 +310,7 @@ CBC_PDF417ScanningDecoder::getRowIndicatorColumn(CBC_CommonBitMatrix* image, CBC_Codeword* codeword = detectCodeword(image, 0, image->GetWidth(), leftToRight, startColumn, imageRow, minCodewordWidth, maxCodewordWidth); - if (codeword != NULL) { + if (codeword) { rowIndicatorColumn->setCodeword(imageRow, codeword); if (leftToRight) { startColumn = codeword->getStartX(); @@ -515,19 +515,19 @@ int32_t CBC_PDF417ScanningDecoder::getStartColumn( codeword = detectionResult->getDetectionResultColumn(barcodeColumn - offset) ->getCodeword(imageRow); } - if (codeword != NULL) { + if (codeword) { return leftToRight ? codeword->getEndX() : codeword->getStartX(); } codeword = detectionResult->getDetectionResultColumn(barcodeColumn) ->getCodewordNearby(imageRow); - if (codeword != NULL) { + if (codeword) { return leftToRight ? codeword->getStartX() : codeword->getEndX(); } if (isValidBarcodeColumn(detectionResult, barcodeColumn - offset)) { codeword = detectionResult->getDetectionResultColumn(barcodeColumn - offset) ->getCodewordNearby(imageRow); } - if (codeword != NULL) { + if (codeword) { return leftToRight ? codeword->getEndX() : codeword->getStartX(); } int32_t skippedColumns = 0; @@ -543,7 +543,7 @@ int32_t CBC_PDF417ScanningDecoder::getStartColumn( barcodeColumn) ->getCodewords() ->GetAt(i); - if (previousRowCodeword != NULL) { + if (previousRowCodeword) { return (leftToRight ? previousRowCodeword->getEndX() : previousRowCodeword->getStartX()) + offset * skippedColumns * (previousRowCodeword->getEndX() - |