summaryrefslogtreecommitdiff
path: root/fxbarcode
diff options
context:
space:
mode:
authorRyan Harrison <rharrison@chromium.org>2018-06-04 21:15:57 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-06-04 21:15:57 +0000
commit82df54058ae56edef579d75421f216351bfd723e (patch)
tree3fddbe37e8cca9422ca43a1108a9c334f0d3bb7e /fxbarcode
parentd6c6a9f36666c290922efd59ba37bdfc3667eca4 (diff)
downloadpdfium-82df54058ae56edef579d75421f216351bfd723e.tar.xz
Fix a number of unused writes in barcode code
This fixes a number of instances where a value is written out to a variable, but never used in the barcode. There are three different types of fixes employed in this CL. If the non-use is a bug, then rewrite the code to actually use the value. If it is an assignment with no side effects, then just remove the entire line. Finally if it is an assignment of a function return value, cast it to void instead to clearly mark that the return is being ignored. Issues found with Clang Static Analyzer. Change-Id: If13a3684cb2db81592cce9a798788a26fcdb4c6d Reviewed-on: https://pdfium-review.googlesource.com/33771 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'fxbarcode')
-rw-r--r--fxbarcode/oned/BC_OnedCode39Writer_unittest.cpp22
-rw-r--r--fxbarcode/qrcode/BC_QRCoderEncoder.cpp1
2 files changed, 10 insertions, 13 deletions
diff --git a/fxbarcode/oned/BC_OnedCode39Writer_unittest.cpp b/fxbarcode/oned/BC_OnedCode39Writer_unittest.cpp
index 27a0410637..7a5f56998e 100644
--- a/fxbarcode/oned/BC_OnedCode39Writer_unittest.cpp
+++ b/fxbarcode/oned/BC_OnedCode39Writer_unittest.cpp
@@ -49,6 +49,8 @@ TEST(OnedCode39WriterTest, SetWideNarrowRatio) {
"### # # # ### " // U
"### ### # # # " // M
"# # ### ### #"; // * End
+ for (size_t i = 0; i < strlen(expected); i++)
+ EXPECT_EQ(expected[i] != ' ', !!encoded[i]) << i;
FX_Free(encoded);
writer.SetWideNarrowRatio(2);
@@ -63,6 +65,8 @@ TEST(OnedCode39WriterTest, SetWideNarrowRatio) {
"## # # # ## " // U
"## ## # # # " // M
"# # ## ## #"; // * End
+ for (size_t i = 0; i < strlen(expected); i++)
+ EXPECT_EQ(expected[i] != ' ', !!encoded[i]) << i;
FX_Free(encoded);
}
@@ -79,9 +83,8 @@ TEST(OnedCode39WriterTest, Encode) {
expected =
"# # ### ### # " // * Start
"# # ### ### #"; // * End
- for (size_t i = 0; i < strlen(expected); i++) {
+ for (size_t i = 0; i < strlen(expected); i++)
EXPECT_EQ(expected[i] != ' ', !!encoded[i]) << i;
- }
FX_Free(encoded);
encoded = writer.Encode("123", BCFORMAT_CODE_39, width, height);
@@ -93,9 +96,8 @@ TEST(OnedCode39WriterTest, Encode) {
"# ### # # ### " // 2
"### ### # # # " // 3
"# # ### ### #"; // * End
- for (size_t i = 0; i < strlen(expected); i++) {
+ for (size_t i = 0; i < strlen(expected); i++)
EXPECT_EQ(expected[i] != ' ', !!encoded[i]) << i;
- }
FX_Free(encoded);
encoded = writer.Encode("PDFIUM", BCFORMAT_CODE_39, width, height);
@@ -110,9 +112,8 @@ TEST(OnedCode39WriterTest, Encode) {
"### # # # ### " // U
"### ### # # # " // M
"# # ### ### #"; // * End
- for (size_t i = 0; i < strlen(expected); i++) {
+ for (size_t i = 0; i < strlen(expected); i++)
EXPECT_EQ(expected[i] != ' ', !!encoded[i]) << i;
- }
FX_Free(encoded);
encoded = writer.Encode("A -$%./+Z", BCFORMAT_CODE_39, width, height);
@@ -130,9 +131,8 @@ TEST(OnedCode39WriterTest, Encode) {
"# # # # # " // +
"# ### ### # # " // Z
"# # ### ### #"; // * End
- for (size_t i = 0; i < strlen(expected); i++) {
+ for (size_t i = 0; i < strlen(expected); i++)
EXPECT_EQ(expected[i] != ' ', !!encoded[i]) << i;
- }
FX_Free(encoded);
}
@@ -156,9 +156,8 @@ TEST(OnedCode39WriterTest, Checksum) {
"### ### # # # " // 3 (3)
"# ### ### # # " // 6 (6 = (1 + 2 + 3) % 43)
"# # ### ### #"; // * End
- for (size_t i = 0; i < strlen(expected); i++) {
+ for (size_t i = 0; i < strlen(expected); i++)
EXPECT_EQ(expected[i] != ' ', !!encoded[i]) << i;
- }
FX_Free(encoded);
encoded = writer.Encode("PDFIUM", BCFORMAT_CODE_39, width, height);
@@ -175,9 +174,8 @@ TEST(OnedCode39WriterTest, Checksum) {
"### ### # # # " // M (22)
"### # # ### # " // . (37 = (25 + 13 + 15 + 18 + 30 + 22) % 43)
"# # ### ### #"; // * End
- for (size_t i = 0; i < strlen(expected); i++) {
+ for (size_t i = 0; i < strlen(expected); i++)
EXPECT_EQ(expected[i] != ' ', !!encoded[i]) << i;
- }
FX_Free(encoded);
}
diff --git a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
index a44dfc39f6..8da2d48e34 100644
--- a/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
+++ b/fxbarcode/qrcode/BC_QRCoderEncoder.cpp
@@ -479,7 +479,6 @@ void SplitString(const ByteString& content,
result->push_back(
{CBC_QRCoderMode::sALPHANUMERIC, content.Mid(flag, index - flag)});
}
- flag = index;
if (index < content.GetLength())
SplitString(content.Right(content.GetLength() - index), result);
}