Fix build warning 53/216453/10
authorIlho Kim <ilho159.kim@samsung.com>
Fri, 25 Oct 2019 04:52:56 +0000 (13:52 +0900)
committerilho kim <ilho159.kim@samsung.com>
Mon, 4 Nov 2019 08:54:36 +0000 (08:54 +0000)
Warning that "deprecated conversion from string constant to 'char*'"

Change-Id: I358e41d668af069b79e40ff353f3ce62339a9654
Signed-off-by: Ilho Kim <ilho159.kim@samsung.com>
src/unit_tests/recovery_test.cc

index da59539..acde109 100644 (file)
@@ -27,7 +27,7 @@ typedef enum {
   MOUNT_UPDATE_REQ = 4,
 } REQ_TYPE;
 
-char *install_req_filter[] = {
+const char* install_req_filter[] = {
   "--gtest_filter=SmokeTest.RecoveryMode_Tpk_Installation",
   "--gtest_filter=SmokeTest.RecoveryMode_Tpk_Update",
   "--gtest_filter=SmokeTest.RecoveryMode_ForDelta",
@@ -262,7 +262,7 @@ TEST_F(SmokeTest, RecoveryMode_ForMountUpdate) {
 
 }  // namespace smoke_test
 
-#define BUF_SIZE 1024
+const int kBufSize = 1024;
 
 const char *short_options = "iudmn:l:t:r";
 const struct option long_options[] = {
@@ -361,16 +361,19 @@ int main(int argc,  char** argv) {
   }
 
   try {
-    char buf[BUF_SIZE];
+    char buf[10][kBufSize] = { 0, };
     std::vector<char *> gtest_argv;
 
-    gtest_argv.push_back(NULL);
-    gtest_argv.push_back(install_req_filter[req_type]);
+    gtest_argv.push_back(nullptr);
+    snprintf(buf[gtest_argv.size()], kBufSize,
+        "%s", install_req_filter[req_type]);
+    gtest_argv.push_back(buf[gtest_argv.size()]);
     if (repeat) {
-      snprintf(buf, sizeof(buf), "--gtest_repeat=%d", repeat_count);
-      gtest_argv.push_back(buf);
+      snprintf(buf[gtest_argv.size()], kBufSize,
+          "--gtest_repeat=%d", repeat_count);
+      gtest_argv.push_back(buf[gtest_argv.size()]);
     }
-    gtest_argv.push_back(NULL);
+    gtest_argv.push_back(nullptr);
     int gtest_argc = gtest_argv.size();
 
     testing::InitGoogleTest(&gtest_argc, gtest_argv.data());