From 908dbbfb31a02ae91de1178e51c8ae91de13586f Mon Sep 17 00:00:00 2001 From: Project Nayuki Date: Sun, 10 Dec 2017 16:36:02 +0000 Subject: [PATCH] Added initial values to some variables in C and C++ code to avoid potential compiler warnings. --- c/qrcodegen.c | 8 ++++---- cpp/QrCode.cpp | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/c/qrcodegen.c b/c/qrcodegen.c index 09ba8a5..d448f91 100644 --- a/c/qrcodegen.c +++ b/c/qrcodegen.c @@ -556,8 +556,8 @@ static long getPenaltyScore(const uint8_t qrcode[]) { // Adjacent modules in row having same color for (int y = 0; y < qrsize; y++) { - bool colorX; - for (int x = 0, runX; x < qrsize; x++) { + bool colorX = false; + for (int x = 0, runX = -1; x < qrsize; x++) { if (x == 0 || getModule(qrcode, x, y) != colorX) { colorX = getModule(qrcode, x, y); runX = 1; @@ -572,8 +572,8 @@ static long getPenaltyScore(const uint8_t qrcode[]) { } // Adjacent modules in column having same color for (int x = 0; x < qrsize; x++) { - bool colorY; - for (int y = 0, runY; y < qrsize; y++) { + bool colorY = false; + for (int y = 0, runY = -1; y < qrsize; y++) { if (y == 0 || getModule(qrcode, x, y) != colorY) { colorY = getModule(qrcode, x, y); runY = 1; diff --git a/cpp/QrCode.cpp b/cpp/QrCode.cpp index 2f6e842..a654d60 100644 --- a/cpp/QrCode.cpp +++ b/cpp/QrCode.cpp @@ -421,8 +421,8 @@ long QrCode::getPenaltyScore() const { // Adjacent modules in row having same color for (int y = 0; y < size; y++) { - bool colorX; - for (int x = 0, runX; x < size; x++) { + bool colorX = false; + for (int x = 0, runX = -1; x < size; x++) { if (x == 0 || module(x, y) != colorX) { colorX = module(x, y); runX = 1; @@ -437,8 +437,8 @@ long QrCode::getPenaltyScore() const { } // Adjacent modules in column having same color for (int x = 0; x < size; x++) { - bool colorY; - for (int y = 0, runY; y < size; y++) { + bool colorY = false; + for (int y = 0, runY = -1; y < size; y++) { if (y == 0 || module(x, y) != colorY) { colorY = module(x, y); runY = 1;