From 903d117485c4f09593bd312040506c48c62b3e79 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 28 Dec 2017 10:49:54 -0600 Subject: [PATCH] pvAccessLog() add EPICS_PRINTF_STYLE() and fixup incorrect specifiers --- pvtoolsSrc/pvlist.cpp | 2 +- src/remote/blockingUDPTransport.cpp | 10 +++++----- src/remote/codec.cpp | 4 ++-- src/remoteClient/clientContextImpl.cpp | 2 +- src/server/serverContext.cpp | 2 +- src/utils/pv/logger.h | 3 ++- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/pvtoolsSrc/pvlist.cpp b/pvtoolsSrc/pvlist.cpp index 0eff7bb..675a152 100644 --- a/pvtoolsSrc/pvlist.cpp +++ b/pvtoolsSrc/pvlist.cpp @@ -250,7 +250,7 @@ bool discoverServers(double timeOut) for (size_t i = 0; i < broadcastAddresses.size(); i++) LOG(logLevelDebug, - "Broadcast address #%d: %s.", i, inetAddressToString(broadcastAddresses[i]).c_str()); + "Broadcast address #%zu: %s.", i, inetAddressToString(broadcastAddresses[i]).c_str()); // --- diff --git a/src/remote/blockingUDPTransport.cpp b/src/remote/blockingUDPTransport.cpp index bcf49d0..ad524ed 100644 --- a/src/remote/blockingUDPTransport.cpp +++ b/src/remote/blockingUDPTransport.cpp @@ -395,7 +395,7 @@ bool BlockingUDPTransport::send(const char* buffer, size_t length, const osiSock { if (IS_LOGGABLE(logLevelDebug)) { - LOG(logLevelDebug, "Sending %d bytes to %s.", + LOG(logLevelDebug, "Sending %zu bytes to %s.", length, inetAddressToString(address).c_str()); } @@ -419,7 +419,7 @@ bool BlockingUDPTransport::send(ByteBuffer* buffer, const osiSockAddr& address) if (IS_LOGGABLE(logLevelDebug)) { - LOG(logLevelDebug, "Sending %d bytes to %s.", + LOG(logLevelDebug, "Sending %zu bytes to %s.", buffer->getRemaining(), inetAddressToString(address).c_str()); } @@ -456,7 +456,7 @@ bool BlockingUDPTransport::send(ByteBuffer* buffer, InetAddressType target) { if (IS_LOGGABLE(logLevelDebug)) { - LOG(logLevelDebug, "Sending %d bytes to %s.", + LOG(logLevelDebug, "Sending %zu bytes to %s.", buffer->getRemaining(), inetAddressToString(_sendAddresses[i]).c_str()); } @@ -586,7 +586,7 @@ void initializeUDPTransports(bool serverFlag, if (listenPort == 0) { listenPort = ntohs(sendTransport->getRemoteAddress()->ia.sin_port); - LOG(logLevelDebug, "Dynamic listen UDP port set to %d.", listenPort); + LOG(logLevelDebug, "Dynamic listen UDP port set to %u.", (unsigned)listenPort); } // TODO current implementation shares the port (aka beacon and search port) @@ -651,7 +651,7 @@ void initializeUDPTransports(bool serverFlag, else for (size_t i = 0; i < blist.size(); i++) LOG(logLevelDebug, - "Broadcast address #%d: %s.", i, inetAddressToString(blist[i]).c_str()); + "Broadcast address #%zu: %s.", i, inetAddressToString(blist[i]).c_str()); // TODO configurable local NIF, address diff --git a/src/remote/codec.cpp b/src/remote/codec.cpp index bb1d6cd..8e89293 100644 --- a/src/remote/codec.cpp +++ b/src/remote/codec.cpp @@ -1569,7 +1569,7 @@ void BlockingServerTCPTransportCodec::destroyAllChannels() { { LOG( logLevelDebug, - "Transport to %s still has %zd channel(s) active and closing...", + "Transport to %s still has %zu channel(s) active and closing...", _socketName.c_str(), _channels.size()); } @@ -1793,7 +1793,7 @@ void BlockingClientTCPTransportCodec::closedNotifyClients() { { LOG( logLevelDebug, - "Transport to %s still has %d client(s) active and closing...", + "Transport to %s still has %zu client(s) active and closing...", _socketName.c_str(), refs); } diff --git a/src/remoteClient/clientContextImpl.cpp b/src/remoteClient/clientContextImpl.cpp index 0b2bde0..6d021f5 100644 --- a/src/remoteClient/clientContextImpl.cpp +++ b/src/remoteClient/clientContextImpl.cpp @@ -4230,7 +4230,7 @@ private: } if (transportCount) - LOG(logLevelDebug, "PVA client context destroyed with %d transport(s) active.", transportCount); + LOG(logLevelDebug, "PVA client context destroyed with %u transport(s) active.", (unsigned)transportCount); } void destroyAllChannels() { diff --git a/src/server/serverContext.cpp b/src/server/serverContext.cpp index 4f4e52e..84f8e24 100644 --- a/src/server/serverContext.cpp +++ b/src/server/serverContext.cpp @@ -369,7 +369,7 @@ void ServerContextImpl::destroyAllTransports() if (size == 0) return; - LOG(logLevelDebug, "Server context still has %d transport(s) active and closing...", size); + LOG(logLevelDebug, "Server context still has %zu transport(s) active and closing...", size); for (size_t i = 0; i < size; i++) { diff --git a/src/utils/pv/logger.h b/src/utils/pv/logger.h index cfdbdbb..54e636d 100644 --- a/src/utils/pv/logger.h +++ b/src/utils/pv/logger.h @@ -9,6 +9,7 @@ #include +#include #include namespace epics { @@ -37,7 +38,7 @@ OFF */ -epicsShareFunc void pvAccessLog(pvAccessLogLevel level, const char* format, ...); +epicsShareFunc void pvAccessLog(pvAccessLogLevel level, const char* format, ...) EPICS_PRINTF_STYLE(2, 3); epicsShareFunc void pvAccessSetLogLevel(pvAccessLogLevel level); epicsShareFunc bool pvAccessIsLoggable(pvAccessLogLevel level);