casting for c89 compatibility and lint cleanup

Bug: libyuv:756
Test: CFLAGS="-m32 -static -std=gnu89 -mno-sse -O2" CXXFLAGS="-m32 -x c -static -std=gnu99 -mno-sse -O2" make -f linux.mk libyuv.a
Change-Id: Ic362f93e01ccbb0bea14f361a58585e79297e7d2
Reviewed-on: https://chromium-review.googlesource.com/759423
Reviewed-by: Frank Barchard <fbarchard@google.com>
Reviewed-by: Patrik Höglund <phoglund@chromium.org>
Commit-Queue: Frank Barchard <fbarchard@google.com>
diff --git a/include/libyuv/row.h b/include/libyuv/row.h
index 7332bdf..96973da 100644
--- a/include/libyuv/row.h
+++ b/include/libyuv/row.h
@@ -274,7 +274,7 @@
 
 // The following are available for AVX2 gcc/clang x86 platforms:
 // TODO(fbarchard): Port to Visual C
-#if !defined(LIBYUV_DISABLE_X86) && \
+#if !defined(LIBYUV_DISABLE_X86) &&                                       \
     (defined(__x86_64__) || (defined(__i386__) && !defined(_MSC_VER))) && \
     (defined(CLANG_HAS_AVX2) || defined(GCC_HAS_AVX2))
 #define HAS_MERGEUV10ROW_AVX2
diff --git a/source/cpu_id.cc b/source/cpu_id.cc
index 7b97970..344f3c0 100644
--- a/source/cpu_id.cc
+++ b/source/cpu_id.cc
@@ -244,11 +244,11 @@
     if ((GetXCR0() & 0xe0) == 0xe0) {
       cpu_info |= (cpu_info7[1] & 0x40000000) ? kCpuHasAVX512BW : 0;
       cpu_info |= (cpu_info7[1] & 0x80000000) ? kCpuHasAVX512VL : 0;
-      cpu_info |= (cpu_info7[2] & 0x00000002) ? kCpuHasAVX512VBMI: 0;
-      cpu_info |= (cpu_info7[2] & 0x00000040) ? kCpuHasAVX512VBMI2: 0;
-      cpu_info |= (cpu_info7[2] & 0x00001000) ? kCpuHasAVX512VBITALG: 0;
-      cpu_info |= (cpu_info7[2] & 0x00004000) ? kCpuHasAVX512VPOPCNTDQ: 0;
-      cpu_info |= (cpu_info7[2] & 0x00000100) ? kCpuHasGFNI: 0;
+      cpu_info |= (cpu_info7[2] & 0x00000002) ? kCpuHasAVX512VBMI : 0;
+      cpu_info |= (cpu_info7[2] & 0x00000040) ? kCpuHasAVX512VBMI2 : 0;
+      cpu_info |= (cpu_info7[2] & 0x00001000) ? kCpuHasAVX512VBITALG : 0;
+      cpu_info |= (cpu_info7[2] & 0x00004000) ? kCpuHasAVX512VPOPCNTDQ : 0;
+      cpu_info |= (cpu_info7[2] & 0x00000100) ? kCpuHasGFNI : 0;
     }
   }
 
diff --git a/source/mjpeg_validate.cc b/source/mjpeg_validate.cc
index 1a17dd7..bd76042 100644
--- a/source/mjpeg_validate.cc
+++ b/source/mjpeg_validate.cc
@@ -24,7 +24,7 @@
     const uint8* it = sample;
     while (it < end) {
       // TODO(fbarchard): scan for 0xd9 instead.
-      it = static_cast<const uint8*>(memchr(it, 0xff, end - it));
+      it = (const uint8*)(memchr(it, 0xff, end - it));
       if (it == NULL) {
         break;
       }
diff --git a/source/row_gcc.cc b/source/row_gcc.cc
index c2874e1..ff2e8a3 100644
--- a/source/row_gcc.cc
+++ b/source/row_gcc.cc
@@ -2758,9 +2758,11 @@
                        const uint16* src_v,
                        uint16* dst_uv,
                        int width) {
+  // clang-format off
   asm volatile (
     "sub       %0,%1                           \n"
 
+    // 16 pixels per loop.
     LABELALIGN
     "1:                                        \n"
     "vmovdqu   (%0),%%ymm0                     \n"
@@ -2768,14 +2770,8 @@
     "add        $0x20,%0                       \n"
     "vpsllw    $0x6,%%ymm0,%%ymm0              \n"
     "vpsllw    $0x6,%%ymm1,%%ymm1              \n"
-//    "vpermq     $0xd8,%%ymm0,%%ymm0            \n"
-//    "vpermq     $0xd8,%%ymm1,%%ymm1            \n"
-    "vpunpcklwd %%ymm1,%%ymm0,%%ymm2           \n"
+    "vpunpcklwd %%ymm1,%%ymm0,%%ymm2           \n"  // mutates
     "vpunpckhwd %%ymm1,%%ymm0,%%ymm0           \n"
-
-//    "vmovdqu   %%ymm2, (%2)                    \n"
-//    "vmovdqu   %%ymm0, 0x20(%2)                \n"
-
     "vextractf128 $0x0,%%ymm2,(%2)             \n"
     "vextractf128 $0x0,%%ymm0,0x10(%2)         \n"
     "vextractf128 $0x1,%%ymm2,0x20(%2)         \n"
@@ -2784,17 +2780,16 @@
     "sub       $0x10,%3                        \n"
     "jg        1b                              \n"
     "vzeroupper                                \n"
-  : "+r"(src_u),     // %0
-    "+r"(src_v),     // %1
-    "+r"(dst_uv),    // %2
-    "+r"(width)      // %3
+  : "+r"(src_u),   // %0
+    "+r"(src_v),   // %1
+    "+r"(dst_uv),  // %2
+    "+r"(width)    // %3
   :
-  : "memory", "cc", "xmm0", "xmm1", "xmm2"
-  );
+  : "memory", "cc", "xmm0", "xmm1", "xmm2");
+  // clang-format on
 }
 #endif  // HAS_MERGEUVROW_AVX2
 
-
 #ifdef HAS_SPLITRGBROW_SSSE3
 
 // Shuffle table for converting RGB to Planar.
diff --git a/source/scale.cc b/source/scale.cc
index 13e242b..b3ad64e 100644
--- a/source/scale.cc
+++ b/source/scale.cc
@@ -822,11 +822,12 @@
 static void ScaleAddCols0_C(int dst_width,
                             int boxheight,
                             int x,
-                            int,
+                            int dx,
                             const uint16* src_ptr,
                             uint8* dst_ptr) {
   int scaleval = 65536 / boxheight;
   int i;
+  (void)dx;
   src_ptr += (x >> 16);
   for (i = 0; i < dst_width; ++i) {
     *dst_ptr++ = src_ptr[i] * scaleval >> 16;
diff --git a/unit_test/cpu_test.cc b/unit_test/cpu_test.cc
index 8115e0d..4e694f5 100644
--- a/unit_test/cpu_test.cc
+++ b/unit_test/cpu_test.cc
@@ -36,7 +36,7 @@
   int has_avx2 = TestCpuFlag(kCpuHasAVX2);
   int has_erms = TestCpuFlag(kCpuHasERMS);
   int has_fma3 = TestCpuFlag(kCpuHasFMA3);
-  int has_f16c = TestCpuFlag(kCpuHasF16C); 
+  int has_f16c = TestCpuFlag(kCpuHasF16C);
   int has_gfni = TestCpuFlag(kCpuHasGFNI);
   int has_avx512bw = TestCpuFlag(kCpuHasAVX512BW);
   int has_avx512vl = TestCpuFlag(kCpuHasAVX512VL);