vdr-xine 0.7.6: kill a few compiler warnings
Commit Message
This patch prevents some printf format string warnings when building vdr-xine
0.7.6 with these extra flags:
-Wall -Wnonnull -Wformat=2 -Wextra
(There are potential problems if the fifo directory's name contains % and
mkdir or mknod fails. This patch eliminates them.)
Comments
Hi,
Darren Salt wrote:
> This patch prevents some printf format string warnings when building vdr-xine
> 0.7.6 with these extra flags:
> -Wall -Wnonnull -Wformat=2 -Wextra
>
> (There are potential problems if the fifo directory's name contains % and
> mkdir or mknod fails. This patch eliminates them.)
Thank you for this patch. I'll integrate it into release 0.7.7.
Bye.
@@ -1912,8 +1912,8 @@
}
else
{
- ::fprintf(stderr, ("vdr-xine: error: couldn't open '" + noSignalFileName + "'!\n").c_str());
- esyslog(("vdr-xine: error: couldn't open '" + noSignalFileName + "'!\n").c_str());
+ ::fprintf(stderr, "vdr-xine: error: couldn't open '%s'!\n", noSignalFileName.c_str());
+ esyslog("vdr-xine: error: couldn't open '%s'!\n", noSignalFileName.c_str());
}
assert(remote);
@@ -1953,69 +1953,32 @@
const mode_t origUmask = ::umask(0);
- if (::mkdir(m_fifoDir.c_str(), 0755) < 0)
- {
- perror(("vdr-xine: error: couldn't create directory '" + m_fifoDir + "'").c_str());
- esyslog(("vdr-xine: error: couldn't create directory '" + m_fifoDir + "'").c_str());
-
- ::umask(origUmask);
- return false;
- }
-
- if (::mknod(m_fifoNameExtControl.c_str(), 0666 | S_IFIFO, 0) < 0)
- {
- perror(("vdr-xine: error: couldn't create fifo '" + m_fifoNameExtControl + "'").c_str());
- esyslog(("vdr-xine: error: couldn't create fifo '" + m_fifoNameExtControl + "'").c_str());
-
- ::umask(origUmask);
- return false;
- }
-
- if (::mknod(m_fifoNameExtResult.c_str(), 0644 | S_IFIFO, 0) < 0)
- {
- perror(("vdr-xine: error: couldn't create fifo '" + m_fifoNameExtResult + "'").c_str());
- esyslog(("vdr-xine: error: couldn't create fifo '" + m_fifoNameExtResult + "'").c_str());
-
- ::umask(origUmask);
- return false;
- }
-
- if (::mknod(m_fifoNameControl.c_str(), 0644 | S_IFIFO, 0) < 0)
- {
- perror(("vdr-xine: error: couldn't create fifo '" + m_fifoNameControl + "'").c_str());
- esyslog(("vdr-xine: error: couldn't create fifo '" + m_fifoNameControl + "'").c_str());
-
- ::umask(origUmask);
- return false;
- }
-
- if (::mknod(m_fifoNameResult.c_str(), 0666 | S_IFIFO, 0) < 0)
- {
- perror(("vdr-xine: error: couldn't create fifo '" + m_fifoNameResult + "'").c_str());
- esyslog(("vdr-xine: error: couldn't create fifo '" + m_fifoNameResult + "'").c_str());
-
- ::umask(origUmask);
- return false;
- }
+#define MkFifo(String, Mask) \
+ do { if (::mknod((String).c_str(), (Mask) | S_IFIFO, 0) < 0) \
+ { \
+ string msg = "vdr-xine: error: couldn't create fifo '" + (String) + "'"; \
+ perror(msg.c_str()); \
+ esyslog("%s", msg.c_str()); \
+ ::umask(origUmask); \
+ return false; \
+ } } while (0)
- if (::mknod(m_fifoNameRemote.c_str(), 0666 | S_IFIFO, 0) < 0)
+ if (::mkdir(m_fifoDir.c_str(), 0755) < 0)
{
- perror(("vdr-xine: error: couldn't create fifo '" + m_fifoNameRemote + "'").c_str());
- esyslog(("vdr-xine: error: couldn't create fifo '" + m_fifoNameRemote + "'").c_str());
-
+ string msg = "vdr-xine: error: couldn't create directory '" + m_fifoDir + "'";
+ perror(msg.c_str());
+ esyslog("%s", msg.c_str());
::umask(origUmask);
return false;
}
- if (::mknod(m_fifoNameStream.c_str(), 0644 | S_IFIFO, 0) < 0)
- {
- perror(("vdr-xine: error: couldn't create fifo '" + m_fifoNameStream + "'").c_str());
- esyslog(("vdr-xine: error: couldn't create fifo '" + m_fifoNameStream + "'").c_str());
+ MkFifo(m_fifoNameExtControl, 0666);
+ MkFifo(m_fifoNameExtResult, 0644);
+ MkFifo(m_fifoNameControl, 0644);
+ MkFifo(m_fifoNameResult, 0666);
+ MkFifo(m_fifoNameRemote, 0666);
+ MkFifo(m_fifoNameStream, 0644);
- ::umask(origUmask);
- return false;
- }
-
::umask(origUmask);
if (!Start())