]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
test/crypto: fix narrowing conversion warning
authorSage Weil <sage@inktank.com>
Sat, 9 Feb 2013 05:47:34 +0000 (21:47 -0800)
committerSage Weil <sage@inktank.com>
Sat, 9 Feb 2013 05:47:34 +0000 (21:47 -0800)
warning: test/crypto.cc:49:3: narrowing conversion of ‘136’ from ‘int’ to ‘char’ inside { } is ill-formed in C++11 [-Wnarrowing]

Signed-off-by: Sage Weil <sage@inktank.com>
src/test/crypto.cc

index 80a5495001d912068894e8f89c49d33f55017b59..24d5c5a475d3dc25487fa8cd203042d485107ebf 100644 (file)
@@ -43,19 +43,19 @@ TEST(AES, Encrypt) {
   };
   bufferptr secret(secret_s, sizeof(secret_s));
 
-  char plaintext_s[] = {
+  unsigned char plaintext_s[] = {
     0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
     0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
   };
   bufferlist plaintext;
-  plaintext.append(plaintext_s, sizeof(plaintext_s));
+  plaintext.append((char *)plaintext_s, sizeof(plaintext_s));
 
   bufferlist cipher;
   std::string error;
   h->encrypt(secret, plaintext, cipher, error);
   ASSERT_EQ(error, "");
 
-  char want_cipher[] = {
+  unsigned char want_cipher[] = {
     0xb3, 0x8f, 0x5b, 0xc9, 0x35, 0x4c, 0xf8, 0xc6,
     0x13, 0x15, 0x66, 0x6f, 0x37, 0xd7, 0x79, 0x3a,
     0x11, 0x90, 0x7b, 0xe9, 0xd8, 0x3c, 0x35, 0x70,
@@ -79,16 +79,16 @@ TEST(AES, Decrypt) {
   };
   bufferptr secret(secret_s, sizeof(secret_s));
 
-  char cipher_s[] = {
+  unsigned char cipher_s[] = {
     0xb3, 0x8f, 0x5b, 0xc9, 0x35, 0x4c, 0xf8, 0xc6,
     0x13, 0x15, 0x66, 0x6f, 0x37, 0xd7, 0x79, 0x3a,
     0x11, 0x90, 0x7b, 0xe9, 0xd8, 0x3c, 0x35, 0x70,
     0x58, 0x7b, 0x97, 0x9b, 0x03, 0xd2, 0xa5, 0x01,
   };
   bufferlist cipher;
-  cipher.append(cipher_s, sizeof(cipher_s));
+  cipher.append((char *)cipher_s, sizeof(cipher_s));
 
-  char want_plaintext[] = {
+  unsigned char want_plaintext[] = {
     0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
     0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff,
   };