]> granicus.if.org Git - libvpx/commitdiff
Fix scan_build warnings in idct_test.cc
authorAngie Chiang <angiebird@google.com>
Mon, 19 Nov 2018 18:35:41 +0000 (10:35 -0800)
committerAngie Chiang <angiebird@google.com>
Tue, 20 Nov 2018 02:46:01 +0000 (18:46 -0800)
BUG=webm:1575

Change-Id: Ib2380aaf8c9f9bc7db87f36701a2792781beb44b

test/idct_test.cc

index 79a5e9b1741286f9cc58c709ba83de6548e83d8d..e3d1c9ecc0c1d0896aefbf58dde7132652b94e6d 100644 (file)
@@ -72,49 +72,57 @@ TEST_P(IDCTTest, TestAllZeros) {
 
 TEST_P(IDCTTest, TestAllOnes) {
   input->Set(0);
-  // When the first element is '4' it will fill the output buffer with '1'.
-  input->TopLeftPixel()[0] = 4;
-  predict->Set(0);
-  output->Set(0);
-
-  ASM_REGISTER_STATE_CHECK(UUT(input->TopLeftPixel(), predict->TopLeftPixel(),
-                               predict->stride(), output->TopLeftPixel(),
-                               output->stride()));
-
-  ASSERT_TRUE(output->CheckValues(1));
-  ASSERT_TRUE(output->CheckPadding());
+  if (input->TopLeftPixel() != NULL) {
+    // When the first element is '4' it will fill the output buffer with '1'.
+    input->TopLeftPixel()[0] = 4;
+    predict->Set(0);
+    output->Set(0);
+
+    ASM_REGISTER_STATE_CHECK(UUT(input->TopLeftPixel(), predict->TopLeftPixel(),
+                                 predict->stride(), output->TopLeftPixel(),
+                                 output->stride()));
+
+    ASSERT_TRUE(output->CheckValues(1));
+    ASSERT_TRUE(output->CheckPadding());
+  } else {
+    assert(0);
+  }
 }
 
 TEST_P(IDCTTest, TestAddOne) {
   // Set the transform output to '1' and make sure it gets added to the
   // prediction buffer.
   input->Set(0);
-  input->TopLeftPixel()[0] = 4;
-  output->Set(0);
-
-  uint8_t *pred = predict->TopLeftPixel();
-  for (int y = 0; y < 4; ++y) {
-    for (int x = 0; x < 4; ++x) {
-      pred[y * predict->stride() + x] = y * 4 + x;
+  if (input->TopLeftPixel() != NULL) {
+    input->TopLeftPixel()[0] = 4;
+    output->Set(0);
+
+    uint8_t *pred = predict->TopLeftPixel();
+    for (int y = 0; y < 4; ++y) {
+      for (int x = 0; x < 4; ++x) {
+        pred[y * predict->stride() + x] = y * 4 + x;
+      }
     }
-  }
 
-  ASM_REGISTER_STATE_CHECK(UUT(input->TopLeftPixel(), predict->TopLeftPixel(),
-                               predict->stride(), output->TopLeftPixel(),
-                               output->stride()));
+    ASM_REGISTER_STATE_CHECK(UUT(input->TopLeftPixel(), predict->TopLeftPixel(),
+                                 predict->stride(), output->TopLeftPixel(),
+                                 output->stride()));
 
-  uint8_t const *out = output->TopLeftPixel();
-  for (int y = 0; y < 4; ++y) {
-    for (int x = 0; x < 4; ++x) {
-      EXPECT_EQ(1 + y * 4 + x, out[y * output->stride() + x]);
+    uint8_t const *out = output->TopLeftPixel();
+    for (int y = 0; y < 4; ++y) {
+      for (int x = 0; x < 4; ++x) {
+        EXPECT_EQ(1 + y * 4 + x, out[y * output->stride() + x]);
+      }
     }
-  }
 
-  if (HasFailure()) {
-    output->DumpBuffer();
-  }
+    if (HasFailure()) {
+      output->DumpBuffer();
+    }
 
-  ASSERT_TRUE(output->CheckPadding());
+    ASSERT_TRUE(output->CheckPadding());
+  } else {
+    assert(0);
+  }
 }
 
 TEST_P(IDCTTest, TestWithData) {