From 0f241fcda6a9ffd10364b1e92bdbf47ee914f90b Mon Sep 17 00:00:00 2001 From: Colin Patrick McCabe Date: Fri, 25 Mar 2011 14:01:29 -0700 Subject: [PATCH] common: run_cmd: fix bad implicit conversion 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 --- src/mon/MonitorStore.cc | 4 ++-- src/os/FileStore.cc | 8 ++++---- src/test/run_cmd.cc | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mon/MonitorStore.cc b/src/mon/MonitorStore.cc index 038a1e28fe47a..d0856d92772c4 100644 --- a/src/mon/MonitorStore.cc +++ b/src/mon/MonitorStore.cc @@ -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; diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 940662c94994a..ac6e60fdedcea 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -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); } { diff --git a/src/test/run_cmd.cc b/src/test/run_cmd.cc index 73d584f34826d..f110350e7d3ba 100644 --- a/src/test/run_cmd.cc +++ b/src/test/run_cmd.cc @@ -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); -- 2.39.5