]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
common: run_cmd: fix bad implicit conversion
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 25 Mar 2011 21:01:29 +0000 (14:01 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Fri, 25 Mar 2011 21:04:50 +0000 (14:04 -0700)
Since NULL is really just a macro defined to be 0, we must use
(char*)NULL or similar to force the compiler to use a true pointer value
as the last argument to the run_cmd varargs function. Otherwise, the 0
gets promoted to an int, which probably is not the same length as a
pointer these days (32 vs. 64.)

Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/mon/MonitorStore.cc
src/os/FileStore.cc
src/test/run_cmd.cc

index 038a1e28fe47a28373826eba62535960a2285385..d0856d92772c456b46bb56cbfa84ae45f8ba4397 100644 (file)
@@ -110,14 +110,14 @@ int MonitorStore::umount()
 
 int MonitorStore::mkfs()
 {
-  int ret = run_cmd("rm", "-rf", dir.c_str(), NULL);
+  int ret = run_cmd("rm", "-rf", dir.c_str(), (char*)NULL);
   if (ret) {
     derr << "MonitorStore::mkfs: failed to remove " << dir
         << ": rm returned " << ret << dendl;
     return ret;
   }
 
-  ret = run_cmd("mkdir", "-p", dir.c_str(), NULL);
+  ret = run_cmd("mkdir", "-p", dir.c_str(), (char*)NULL);
   if (ret) {
     derr << "MonitorStore::mkfs: failed to mkdir -p " << dir
         << ": mkdir returned " << ret << dendl;
index 940662c94994ad89e404250e81b8f0efc098d30e..ac6e60fdedceaa33c18d3bd9f85c0f826c5efd44 100644 (file)
@@ -605,7 +605,7 @@ int FileStore::wipe_subvol(const char *s)
       continue;
     ostringstream oss;
     oss << old_dir.str().c_str() << "/" << de->d_name;
-    int ret = run_cmd("rm", "-rf", oss.str().c_str(), NULL);
+    int ret = run_cmd("rm", "-rf", oss.str().c_str(), (char*)NULL);
     if (ret) {
       derr << "FileStore::wipe_subvol: failed to remove " << oss.str() << ": "
           << "error " << ret << dendl;
@@ -628,7 +628,7 @@ int FileStore::mkfs()
 
   if (g_conf.filestore_dev) {
     dout(0) << "mounting" << dendl;
-    ret = run_cmd("mount", g_conf.filestore_dev, NULL);
+    ret = run_cmd("mount", g_conf.filestore_dev, (char*)NULL);
     if (ret) {
       derr << "FileStore::mkfs: failed to mount g_conf.filestore_dev "
           << "'" << g_conf.filestore_dev << "'. Error code " << ret << dendl;
@@ -1117,7 +1117,7 @@ int FileStore::mount()
 
   if (g_conf.filestore_dev) {
     dout(0) << "mounting" << dendl;
-    //run_cmd("mount", g_conf.filestore_dev, NULL);
+    //run_cmd("mount", g_conf.filestore_dev, (char*)NULL);
   }
 
   dout(5) << "basedir " << basedir << " journal " << journalpath << dendl;
@@ -1423,7 +1423,7 @@ int FileStore::umount()
 
   if (g_conf.filestore_dev) {
     dout(0) << "umounting" << dendl;
-    //run_cmd("umount", g_conf.filestore_dev, NULL);
+    //run_cmd("umount", g_conf.filestore_dev, (char*)NULL);
   }
 
   {
index 73d584f34826d9dd125556d925ae9dab1412447f..f110350e7d3baf554fe81e0a439e15d9f274cc58 100644 (file)
@@ -14,12 +14,12 @@ TEST(RunCommand, StringSimple)
   ASSERT_GE(fd, 0);
   ::close(fd);
 
-  int ret = run_cmd("touch", temp_file_name, NULL);
+  int ret = run_cmd("touch", temp_file_name, (char*)NULL);
   ASSERT_EQ(ret, 0);
 
   ASSERT_EQ(access(temp_file_name, R_OK), 0);
 
-  ret = run_cmd("rm", "-f", temp_file_name, NULL);
+  ret = run_cmd("rm", "-f", temp_file_name, (char*)NULL);
   ASSERT_EQ(ret, 0);
 
   ASSERT_NE(access(temp_file_name, R_OK), 0);