build: fix werror build with clang
authorMatthew Waters <matthew@centricular.com>
Tue, 27 Aug 2019 01:36:49 +0000 (11:36 +1000)
committerMatthew Waters <matthew@centricular.com>
Tue, 27 Aug 2019 01:36:49 +0000 (11:36 +1000)
../subprojects/orc/orc-test/orcarray.c:230:47: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value]
          if ((a[i] < 0.0) == (b[i] < 0.0) && abs(*(orc_uint32 *)&a[i] - *(orc_uint32 *)&b[i]) <= 2) continue;
                                              ^
../subprojects/orc/orc-test/orcarray.c:230:47: note: remove the call to 'abs' since unsigned values cannot be negative
          if ((a[i] < 0.0) == (b[i] < 0.0) && abs(*(orc_uint32 *)&a[i] - *(orc_uint32 *)&b[i]) <= 2) continue;
                                              ^~~
../subprojects/orc/orc-test/orcarray.c:247:47: error: taking the absolute value of unsigned type 'unsigned long' has no effect [-Werror,-Wabsolute-value]
          if ((a[i] < 0.0) == (b[i] < 0.0) && abs(*(orc_uint64 *)&a[i] - *(orc_uint64 *)&b[i]) <= 2) continue;
                                              ^
../subprojects/orc/orc-test/orcarray.c:247:47: note: remove the call to 'abs' since unsigned values cannot be negative
          if ((a[i] < 0.0) == (b[i] < 0.0) && abs(*(orc_uint64 *)&a[i] - *(orc_uint64 *)&b[i]) <= 2) continue;
                                              ^~~
../subprojects/orc/orc-test/orctest.c:525:63: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value]
      if ((*(float *)ptr1 < 0.0) == (*(float *)ptr2 < 0.0) && abs(*(orc_uint32 *)ptr1 - *(orc_uint32 *)ptr2) <= 2) return TRUE;
                                                              ^
../subprojects/orc/orc-test/orctest.c:525:63: note: remove the call to 'abs' since unsigned values cannot be negative
      if ((*(float *)ptr1 < 0.0) == (*(float *)ptr2 < 0.0) && abs(*(orc_uint32 *)ptr1 - *(orc_uint32 *)ptr2) <= 2) return TRUE;
                                                              ^~~
../subprojects/orc/orc-test/orctest.c:530:65: error: taking the absolute value of unsigned type 'unsigned long' has no effect [-Werror,-Wabsolute-value]
      if ((*(double *)ptr1 < 0.0) == (*(double *)ptr2 < 0.0) && abs(*(orc_uint64 *)ptr1 - *(orc_uint64 *)ptr2) <= 2) return TRUE;
                                                                ^
../subprojects/orc/orc-test/orctest.c:530:65: note: remove the call to 'abs' since unsigned values cannot be negative
      if ((*(double *)ptr1 < 0.0) == (*(double *)ptr2 < 0.0) && abs(*(orc_uint64 *)ptr1 - *(orc_uint64 *)ptr2) <= 2) return TRUE;
                                                                ^~~

orc-test/orcarray.c
orc-test/orctest.c

index b27a1f9..7cc5fc1 100644 (file)
@@ -227,7 +227,7 @@ orc_array_compare (OrcArray *array1, OrcArray *array2, int flags)
         for (i=0;i<array1->n;i++){
           if (isnan(a[i]) && isnan(b[i])) continue;
           if (a[i] == b[i]) continue;
-          if ((a[i] < 0.0) == (b[i] < 0.0) && abs(*(orc_uint32 *)&a[i] - *(orc_uint32 *)&b[i]) <= 2) continue;
+          if ((a[i] < 0.0) == (b[i] < 0.0) && (*(orc_uint32 *)&a[i] - *(orc_uint32 *)&b[i]) <= 2) continue;
           return FALSE;
         }
       }
@@ -244,7 +244,7 @@ orc_array_compare (OrcArray *array1, OrcArray *array2, int flags)
         for (i=0;i<array1->n;i++){
           if (isnan(a[i]) && isnan(b[i])) continue;
           if (a[i] == b[i]) continue;
-          if ((a[i] < 0.0) == (b[i] < 0.0) && abs(*(orc_uint64 *)&a[i] - *(orc_uint64 *)&b[i]) <= 2) continue;
+          if ((a[i] < 0.0) == (b[i] < 0.0) && (*(orc_uint64 *)&a[i] - *(orc_uint64 *)&b[i]) <= 2) continue;
           return FALSE;
         }
       }
index 6f6d6d5..4b07823 100644 (file)
@@ -522,12 +522,12 @@ float_compare (OrcArray *array1, OrcArray *array2, int i, int j)
     case 4:
       if (isnan(*(float *)ptr1) && isnan(*(float *)ptr2)) return TRUE;
       if (*(float *)ptr1 == *(float *)ptr2) return TRUE;
-      if ((*(float *)ptr1 < 0.0) == (*(float *)ptr2 < 0.0) && abs(*(orc_uint32 *)ptr1 - *(orc_uint32 *)ptr2) <= 2) return TRUE;
+      if ((*(float *)ptr1 < 0.0) == (*(float *)ptr2 < 0.0) && (*(orc_uint32 *)ptr1 - *(orc_uint32 *)ptr2) <= 2) return TRUE;
       return FALSE;
     case 8:
       if (isnan(*(double *)ptr1) && isnan(*(double *)ptr2)) return TRUE;
       if (*(double *)ptr1 == *(double *)ptr2) return TRUE;
-      if ((*(double *)ptr1 < 0.0) == (*(double *)ptr2 < 0.0) && abs(*(orc_uint64 *)ptr1 - *(orc_uint64 *)ptr2) <= 2) return TRUE;
+      if ((*(double *)ptr1 < 0.0) == (*(double *)ptr2 < 0.0) && (*(orc_uint64 *)ptr1 - *(orc_uint64 *)ptr2) <= 2) return TRUE;
       return FALSE;
   }
   return FALSE;