hash: explicit casts for truncation in CRC32c
authorAndy Green <andy@warmcat.com>
Sat, 12 May 2018 02:00:37 +0000 (10:00 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Sun, 13 May 2018 20:45:37 +0000 (22:45 +0200)
In function 'crc32c_sse42_u64_mimic':
rte_hash_crc.h:402:40:
warning: conversion from 'uint64_t' {aka 'long unsigned int'}
to 'uint32_t' {aka 'unsigned int'} may change value [-Wconversion]
  init_val = crc32c_sse42_u32(d.u32[0], init_val);

Fixes: 00bf774bab0b ("hash: add assembly implementation of CRC32 intrinsics")
Cc: stable@dpdk.org
Signed-off-by: Andy Green <andy@warmcat.com>
Reviewed-by: Stephen Hemminger <stephen@networkplumber.org>
lib/librte_hash/rte_hash_crc.h

index 5f5fb3d..cf28031 100644 (file)
@@ -398,9 +398,9 @@ crc32c_sse42_u64_mimic(uint64_t data, uint64_t init_val)
        } d;
 
        d.u64 = data;
-       init_val = crc32c_sse42_u32(d.u32[0], init_val);
-       init_val = crc32c_sse42_u32(d.u32[1], init_val);
-       return init_val;
+       init_val = crc32c_sse42_u32(d.u32[0], (uint32_t)init_val);
+       init_val = crc32c_sse42_u32(d.u32[1], (uint32_t)init_val);
+       return (uint32_t)init_val;
 }
 #endif
 
@@ -412,7 +412,7 @@ crc32c_sse42_u64(uint64_t data, uint64_t init_val)
                        "crc32q %[data], %[init_val];"
                        : [init_val] "+r" (init_val)
                        : [data] "rm" (data));
-       return init_val;
+       return (uint32_t)init_val;
 }
 #endif