From: Loic Dachary Date: Mon, 22 Sep 2014 12:09:56 +0000 (+0200) Subject: erasure-code: isa test compare chunks with memcmp instead of strncmp X-Git-Tag: v0.86~29^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=aa9d70be389044f3098ec99ce74b5e7505fbb9e7;p=ceph.git erasure-code: isa test compare chunks with memcmp instead of strncmp Because they may contain null characters. Signed-off-by: Loic Dachary --- diff --git a/src/test/erasure-code/TestErasureCodeIsa.cc b/src/test/erasure-code/TestErasureCodeIsa.cc index 5d98f5d29aa2..43526d0e64c9 100644 --- a/src/test/erasure-code/TestErasureCodeIsa.cc +++ b/src/test/erasure-code/TestErasureCodeIsa.cc @@ -344,7 +344,7 @@ DecodeAndVerify(ErasureCodeIsaDefault& Isa, map °raded, set< for (int i = 0; i < (int) decoded.size(); i++) { // compare all the buffers with their original - ok |= strncmp(decoded[i].c_str(), enc[i].c_str(), length); + ok |= memcmp(decoded[i].c_str(), enc[i].c_str(), length); } return ok; @@ -415,7 +415,7 @@ TEST_F(IsaErasureCodeTest, isa_vandermonde_exhaustive) unsigned length = encoded[0].length(); for (int i = 0; i < k; i++) { - EXPECT_EQ(0, strncmp(encoded[i].c_str(), in.c_str() + (i * length), length)); + EXPECT_EQ(0, memcmp(encoded[i].c_str(), in.c_str() + (i * length), length)); } buffer::ptr enc[k + m]; @@ -542,7 +542,7 @@ TEST_F(IsaErasureCodeTest, isa_cauchy_exhaustive) unsigned length = encoded[0].length(); for (int i = 0; i < k; i++) { - EXPECT_EQ(0, strncmp(encoded[i].c_str(), in.c_str() + (i * length), length)); + EXPECT_EQ(0, memcmp(encoded[i].c_str(), in.c_str() + (i * length), length)); } buffer::ptr enc[k + m]; @@ -669,7 +669,7 @@ TEST_F(IsaErasureCodeTest, isa_cauchy_cache_trash) unsigned length = encoded[0].length(); for (int i = 0; i < k; i++) { - EXPECT_EQ(0, strncmp(encoded[i].c_str(), in.c_str() + (i * length), length)); + EXPECT_EQ(0, memcmp(encoded[i].c_str(), in.c_str() + (i * length), length)); } buffer::ptr enc[k + m]; @@ -795,7 +795,7 @@ TEST_F(IsaErasureCodeTest, isa_xor_codec) unsigned length = encoded[0].length(); for (int i = 0; i < k; i++) { - EXPECT_EQ(0, strncmp(encoded[i].c_str(), in.c_str() + (i * length), length)); + EXPECT_EQ(0, memcmp(encoded[i].c_str(), in.c_str() + (i * length), length)); } buffer::ptr enc[k + m];