On Sat, Sep 22, 2012 at 6:06 PM, Scott Kostyshak <skost...@lyx.org> wrote: > On Sat, Sep 22, 2012 at 5:47 PM, Pavel Sanda <sa...@lyx.org> wrote: >> Scott Kostyshak wrote: >>> not worth it worrying about the warnings because they are not harmful >>> and that by trying to fix them, something could go wrong. The reason I >> >> That *something could go wrong* is critical. Removing unused variable >> or a function is not problem, but changing function calls like str()/data() >> just asks for problems. > > Good point. OK, I will make a patch to remove the function and nothing > else for branch.
Attached is the patch for trunk incorporating Lars's suggestions. I'm not planning to submit a patch for branch per the discussion above. Is this OK for trunk? Thanks, Scott
From 53f0b5b109d748f7ebfe8425c46df3b281d01bc3 Mon Sep 17 00:00:00 2001 From: Scott Kostyshak <skost...@lyx.org> Date: Sun, 23 Sep 2012 05:09:44 -0400 Subject: [PATCH] Use an errno and replace a c_str() with data() Give a more detailed error message on a failed write by using errno. An instance of std::string::c_str() is replaced by std::string::data(). Thanks to Lars. --- src/Server.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Server.cpp b/src/Server.cpp index 1e673e6..c0a8b01 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -1015,8 +1015,12 @@ bool LyXComm::loadFilesInOtherInstance() break; string const cmd = "LYXCMD:pipe:file-open:" + fname.absFileName() + '\n'; - if (::write(pipefd, cmd.c_str(), cmd.length()) < 0) - LYXERR0("Cannot write to pipe!"); + if (::write(pipefd, cmd.data(), cmd.length()) < 0) { + char errbuf[80]; + strerror_r(errno, errbuf, sizeof errbuf); + LYXERR0("Cannot write to pipe: " << errbuf); + } + ::close(pipefd); ++loaded_files; it = theFilesToLoad().erase(it); -- 1.7.9.5