remove warnings (#3524)

diff --git a/build/platform-darwin.mk b/build/platform-darwin.mk
index fd5b7f9..270b1fd 100644
--- a/build/platform-darwin.mk
+++ b/build/platform-darwin.mk
@@ -10,8 +10,7 @@
 	$(SHAREDLIB_DIR)/$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXMAJORVER)
 SHARED = -dynamiclib
 SHARED += -current_version $(CURRENT_VERSION) -compatibility_version $(COMPATIBILITY_VERSION)
-CFLAGS += -Wall -fPIC -MMD -MP -stdlib=libc++
-CXXFLAGS += -stdlib=libc++
+CFLAGS += -Wall -Werror -fPIC -MMD -MP -stdlib=libc++
 LDFLAGS += -stdlib=libc++
 ifeq ($(ARCH), arm64)
 CFLAGS += -arch arm64
diff --git a/build/platform-linux.mk b/build/platform-linux.mk
index b5c006b..fb4ac7e 100644
--- a/build/platform-linux.mk
+++ b/build/platform-linux.mk
@@ -3,7 +3,7 @@
 SHAREDLIBSUFFIXFULLVER=$(SHAREDLIBSUFFIX).$(FULL_VERSION)
 SHAREDLIBSUFFIXMAJORVER=$(SHAREDLIBSUFFIX).$(SHAREDLIB_MAJORVERSION)
 SHLDFLAGS = -Wl,-soname,$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXMAJORVER)
-CFLAGS += -Wall -fno-strict-aliasing -fPIC -MMD -MP
+CFLAGS += -Wall -Werror -Wno-error=class-memaccess -fno-strict-aliasing -fPIC -MMD -MP
 ifeq ($(USE_STACK_PROTECTOR), Yes)
 CFLAGS += -fstack-protector-all
 endif
diff --git a/test/api/decoder_ec_test.cpp b/test/api/decoder_ec_test.cpp
index c5a71bc..ce33cbe 100644
--- a/test/api/decoder_ec_test.cpp
+++ b/test/api/decoder_ec_test.cpp
@@ -192,8 +192,9 @@
       if (!bVCLLoss) { //not loss
         rv = decoder_->DecodeFrame2 (info.sLayerInfo[0].pBsBuf + iTotalSliceSize,
                                      info.sLayerInfo[0].pNalLengthInByte[iPacketNum], pData, &dstBufInfo_);
-        if (uiEcIdc == ERROR_CON_DISABLE)
+        if (uiEcIdc == ERROR_CON_DISABLE) {
           EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
+        }
       }
       //EC_IDC should not change till now
       decoder_->GetOption (DECODER_OPTION_ERROR_CON_IDC, &uiGet);
@@ -206,8 +207,9 @@
 
       rv = decoder_->DecodeFrame2 (NULL, 0, pData, &dstBufInfo_); //reconstruction
       //EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
-      if (uiEcIdc == ERROR_CON_DISABLE && rv != 0)
+      if (uiEcIdc == ERROR_CON_DISABLE && rv != 0) {
         EXPECT_EQ (dstBufInfo_.iBufferStatus, 0);
+      }
 
       //deal with next slice
       iTotalSliceSize += len;
diff --git a/test/api/encode_decode_api_test.cpp b/test/api/encode_decode_api_test.cpp
index ab7a3d8..78042ea 100644
--- a/test/api/encode_decode_api_test.cpp
+++ b/test/api/encode_decode_api_test.cpp
@@ -34,7 +34,7 @@
   //for encoder
   //I420: 1(Y) + 1/4(U) + 1/4(V)
   int frameSize = EncDecFileParam.width * EncDecFileParam.height * 3 / 2;
-  if (-1 == buf_.SetLength(frameSize))
+  if (-1 == buf_.SetLength (frameSize))
     return false;
   if (buf_.Length() != (size_t)frameSize) {
     printf ("buf_.Length() failed! frameSize = %d\n", frameSize);
@@ -85,7 +85,7 @@
     SEncParamExt* pParam) {
   memset (pParam, 0, sizeof (SEncParamExt));
   encoder_->GetDefaultParams (pParam);
-  EncodeDecodeTestBase::prepareParam (iLayers, iSlices, VALID_SIZE(width), VALID_SIZE(height), framerate, pParam);
+  EncodeDecodeTestBase::prepareParam (iLayers, iSlices, VALID_SIZE (width), VALID_SIZE (height), framerate, pParam);
 }
 
 
@@ -95,10 +95,11 @@
   memset (buf_.data(), iRandValue, lumaSize);
   memset (buf_.data() + lumaSize, rand() % 256, (frameSize - lumaSize));
   int rv = encoder_->EncodeFrame (&EncPic, &info);
-  if (0 == iCheckTypeIndex)
+  if (0 == iCheckTypeIndex) {
     ASSERT_TRUE (rv == cmResultSuccess) << rv;
-  else if (1 == iCheckTypeIndex)
+  } else if (1 == iCheckTypeIndex) {
     ASSERT_TRUE (rv == cmResultSuccess || rv == cmUnknownReason);
+  }
 }
 
 bool EncodeDecodeTestAPIBase::EncDecOneFrame (const int iWidth, const int iHeight, const int iFrame, FILE* pfEnc) {
diff --git a/test/api/encode_options_test.cpp b/test/api/encode_options_test.cpp
index 17d9066..8e9fef5 100644
--- a/test/api/encode_options_test.cpp
+++ b/test/api/encode_options_test.cpp
@@ -1316,10 +1316,11 @@
       ptr[i] = bAllRandom ? (rand() % 256) : uiVal;
     }
     int rv = encoder_->EncodeFrame (&EncPic, &info);
-    if (0 == iCheckTypeIndex)
+    if (0 == iCheckTypeIndex) {
       ASSERT_TRUE (rv == cmResultSuccess) << "rv=" << rv;
-    else if (1 == iCheckTypeIndex)
+    } else if (1 == iCheckTypeIndex) {
       ASSERT_TRUE (rv == cmResultSuccess || rv == cmUnknownReason) << "rv=" << rv;
+    }
   }
 };
 
@@ -2309,7 +2310,8 @@
       if ((iStepIdx < 3) && (iFrameNum == ((iTotalFrame / 3) * (iStepIdx + 1)))) {
         sParam.iTemporalLayerNum = originalTemporalLayerNum * iSteps[iStepIdx];
         sParam.iTargetBitrate = sParam.sSpatialLayers[0].iSpatialBitrate = originalBR * iSteps[iStepIdx];
-        sParam.fMaxFrameRate = sParam.sSpatialLayers[0].fFrameRate = static_cast <float> (originalFR * pow (2.0f, iSteps[iStepIdx]));
+        sParam.fMaxFrameRate = sParam.sSpatialLayers[0].fFrameRate = static_cast <float> (originalFR * pow (2.0f,
+                               iSteps[iStepIdx]));
         encoder_->SetOption (ENCODER_OPTION_SVC_ENCODE_PARAM_EXT, &sParam);
 
         bSetOption = true;
diff --git a/test/encoder/EncUT_Cavlc.cpp b/test/encoder/EncUT_Cavlc.cpp
index 5cf4158..5d52794 100644
--- a/test/encoder/EncUT_Cavlc.cpp
+++ b/test/encoder/EncUT_Cavlc.cpp
@@ -34,9 +34,9 @@
 }
 
 void TestCavlcParamCalWithEndIdx (PCavlcParamCalFunc func, int endIdx, bool allZero, bool allNonZero) {
-  ENFORCE_STACK_ALIGN_1D(int16_t, coeffLevel, 16, 16);
-  ENFORCE_STACK_ALIGN_1D(int16_t, level, 16, 16);
-  ENFORCE_STACK_ALIGN_1D(uint8_t, run, 16, 16);
+  ENFORCE_STACK_ALIGN_1D (int16_t, coeffLevel, 16, 16);
+  ENFORCE_STACK_ALIGN_1D (int16_t, level, 16, 16);
+  ENFORCE_STACK_ALIGN_1D (uint8_t, run, 16, 16);
   uint8_t run_ref[16];
   int16_t level_ref[16];
   int32_t totalCoeffs = 0;
@@ -53,8 +53,9 @@
   const int32_t totalZeros_ref = CavlcParamCal_ref (coeffLevel, run_ref, level_ref, &totalCoeffs_ref, endIdx);
   const int32_t totalZeros = func (coeffLevel, run, level, &totalCoeffs, endIdx);
   ASSERT_EQ (totalCoeffs, totalCoeffs_ref);
-  if (totalCoeffs > 0)
+  if (totalCoeffs > 0) {
     ASSERT_EQ (totalZeros, totalZeros_ref);
+  }
   for (int i = 0; i < totalCoeffs_ref; i++)
     ASSERT_EQ (level[i], level_ref[i]);
   for (int i = 0; i < totalCoeffs_ref - 1; i++)
@@ -64,7 +65,7 @@
 void TestCavlcParamCal (PCavlcParamCalFunc func) {
   const int endIdxes[] = { 3, 14, 15 };
   const int num_test_repetitions = 10000;
-  for (std::size_t i = 0; i < sizeof endIdxes / sizeof *endIdxes; i++) {
+  for (std::size_t i = 0; i < sizeof endIdxes / sizeof * endIdxes; i++) {
     for (int count = 0; count < num_test_repetitions; count++)
       TestCavlcParamCalWithEndIdx (func, endIdxes[i], count == 0, count == 1);
   }