more type cleanup

This commit is contained in:
2018-06-11 17:16:38 +02:00
parent 8dde86dae7
commit ded9bd2b4d
9 changed files with 91 additions and 79 deletions

View File

@ -41,6 +41,8 @@ extern "C" {
#include "asynUInt32Digital.h" #include "asynUInt32Digital.h"
#include "asynGpibDriver.h" #include "asynGpibDriver.h"
#define Z PRINTF_SIZE_T_PREFIX
/* How things are implemented: /* How things are implemented:
synchonous io: synchonous io:
@ -157,13 +159,13 @@ class AsynDriverInterface : StreamBusInterface
double writeTimeout; double writeTimeout;
double readTimeout; double readTimeout;
double replyTimeout; double replyTimeout;
long expectedLength; size_t expectedLength;
unsigned long eventMask; unsigned long eventMask;
unsigned long receivedEvent; unsigned long receivedEvent;
StreamBuffer inputBuffer; StreamBuffer inputBuffer;
const char* outputBuffer; const char* outputBuffer;
size_t outputSize; size_t outputSize;
int peeksize; size_t peeksize;
#ifdef EPICS_3_13 #ifdef EPICS_3_13
WDOG_ID timer; WDOG_ID timer;
CALLBACK timeoutCallback; CALLBACK timeoutCallback;
@ -182,7 +184,7 @@ class AsynDriverInterface : StreamBusInterface
bool writeRequest(const void* output, size_t size, bool writeRequest(const void* output, size_t size,
unsigned long writeTimeout_ms); unsigned long writeTimeout_ms);
bool readRequest(unsigned long replyTimeout_ms, bool readRequest(unsigned long replyTimeout_ms,
unsigned long readTimeout_ms, long expectedLength, bool async); unsigned long readTimeout_ms, size_t expectedLength, bool async);
bool acceptEvent(unsigned long mask, unsigned long replytimeout_ms); bool acceptEvent(unsigned long mask, unsigned long replytimeout_ms);
bool supportsEvent(); bool supportsEvent();
bool supportsAsyncRead(); bool supportsAsyncRead();
@ -680,8 +682,8 @@ writeHandler()
if (status == asynError || received == 0) break; if (status == asynError || received == 0) break;
#ifndef NO_TEMPORARY #ifndef NO_TEMPORARY
if (received) debug("AsynDriverInterface::writeHandler(%s): " if (received) debug("AsynDriverInterface::writeHandler(%s): "
"flushing %ld bytes: \"%s\"\n", "flushing %" Z "u bytes: \"%s\"\n",
clientName(), (long)received, StreamBuffer(buffer, received).expand()()); clientName(), received, StreamBuffer(buffer, received).expand()());
#endif #endif
} while (status == asynSuccess); } while (status == asynSuccess);
} }
@ -722,11 +724,11 @@ writeHandler()
outputBuffer, outputSize, &written); outputBuffer, outputSize, &written);
#ifndef NO_TEMPORARY #ifndef NO_TEMPORARY
debug("AsynDriverInterface::writeHandler(%s): " debug("AsynDriverInterface::writeHandler(%s): "
"write(..., \"%s\", outputSize=%ld, written=%ld) " "write(..., \"%s\", outputSize=%" Z "u, written=%" Z "u) "
"[timeout=%g sec] = %s (%s)\n", "[timeout=%g sec] = %s (%s)\n",
clientName(), clientName(),
StreamBuffer(outputBuffer, outputSize).expand()(), StreamBuffer(outputBuffer, outputSize).expand()(),
(long)outputSize, (long)written, outputSize, written,
pasynUser->timeout, asynStatusStr[status], pasynUser->timeout, asynStatusStr[status],
pasynUser->errorMessage); pasynUser->errorMessage);
#endif #endif
@ -809,10 +811,10 @@ writeHandler()
// interface function: we want to read something // interface function: we want to read something
bool AsynDriverInterface:: bool AsynDriverInterface::
readRequest(unsigned long replyTimeout_ms, unsigned long readTimeout_ms, readRequest(unsigned long replyTimeout_ms, unsigned long readTimeout_ms,
long _expectedLength, bool async) size_t _expectedLength, bool async)
{ {
debug("AsynDriverInterface::readRequest(%s, %ld msec reply, " debug("AsynDriverInterface::readRequest(%s, %ld msec reply, "
"%ld msec read, expect %ld bytes, async=%s)\n", "%ld msec read, expect %" Z "u bytes, async=%s)\n",
clientName(), replyTimeout_ms, readTimeout_ms, clientName(), replyTimeout_ms, readTimeout_ms,
_expectedLength, async?"yes":"no"); _expectedLength, async?"yes":"no");
@ -892,13 +894,13 @@ readHandler()
oldeoslen = -1; oldeoslen = -1;
} else do { } else do {
// device (e.g. GPIB) might not accept full eos length // device (e.g. GPIB) might not accept full eos length
if ((int)deveoslen == oldeoslen && strcmp(deveos, oldeos) == 0) if (deveoslen == (size_t)oldeoslen && strcmp(deveos, oldeos) == 0)
{ {
// nothing to do: old and new eos are the same // nothing to do: old and new eos are the same
break; break;
} }
if (pasynOctet->setInputEos(pvtOctet, pasynUser, if (pasynOctet->setInputEos(pvtOctet, pasynUser,
deveos, deveoslen) == asynSuccess) deveos, (int)deveoslen) == asynSuccess)
{ {
#ifndef NO_TEMPORARY #ifndef NO_TEMPORARY
if (ioAction != AsyncRead) if (ioAction != AsyncRead)
@ -921,8 +923,8 @@ readHandler()
} while (deveoslen); } while (deveoslen);
} }
long bytesToRead = peeksize; size_t bytesToRead = peeksize;
long buffersize; size_t buffersize;
if (expectedLength > 0) if (expectedLength > 0)
{ {
@ -954,7 +956,7 @@ readHandler()
size_t received; size_t received;
int eomReason; int eomReason;
asynStatus status; asynStatus status;
long readMore; ssize_t readMore;
int connected; int connected;
while (1) while (1)
@ -965,17 +967,18 @@ readHandler()
pasynUser->errorMessage[0] = 0; pasynUser->errorMessage[0] = 0;
debug("AsynDriverInterface::readHandler(%s): ioAction=%s " debug("AsynDriverInterface::readHandler(%s): ioAction=%s "
"read(..., bytesToRead=%ld, ...) " "read(..., bytesToRead=%" Z "u, ...) "
"[timeout=%g sec]\n", "[timeout=%g sec]\n",
clientName(), ioActionStr[ioAction], clientName(), ioActionStr[ioAction],
bytesToRead, pasynUser->timeout); bytesToRead, pasynUser->timeout);
status = pasynOctet->read(pvtOctet, pasynUser, status = pasynOctet->read(pvtOctet, pasynUser,
buffer, bytesToRead, &received, &eomReason); buffer, bytesToRead, &received, &eomReason);
// Even though received is size_t I have seen (size_t)-1 here!
#ifndef NO_TEMPORARY #ifndef NO_TEMPORARY
debug("AsynDriverInterface::readHandler(%s): " debug("AsynDriverInterface::readHandler(%s): "
"read returned %s: ioAction=%s received=%ld, eomReason=%s, buffer=\"%s\"\n", "read returned %s: ioAction=%s received=%" Z "d, eomReason=%s, buffer=\"%s\"\n",
clientName(), asynStatusStr[status], ioActionStr[ioAction], clientName(), asynStatusStr[status], ioActionStr[ioAction],
(long)received,eomReasonStr[eomReason&0x7], received,eomReasonStr[eomReason&0x7],
StreamBuffer(buffer, received).expand()()); StreamBuffer(buffer, received).expand()());
#endif #endif
pasynManager->isConnected(pasynUser, &connected); pasynManager->isConnected(pasynUser, &connected);
@ -1003,9 +1006,9 @@ readHandler()
{ {
#ifndef NO_TEMPORARY #ifndef NO_TEMPORARY
debug("AsynDriverInterface::readHandler(%s): " debug("AsynDriverInterface::readHandler(%s): "
"AsyncRead poll: received %ld of %ld bytes \"%s\" " "AsyncRead poll: received %" Z "d of %" Z "u bytes \"%s\" "
"eomReason=%s [data ignored]\n", "eomReason=%s [data ignored]\n",
clientName(), (long)received, bytesToRead, clientName(), received, bytesToRead,
StreamBuffer(buffer, received).expand()(), StreamBuffer(buffer, received).expand()(),
eomReasonStr[eomReason&0x7]); eomReasonStr[eomReason&0x7]);
#endif #endif
@ -1018,9 +1021,9 @@ readHandler()
} }
#ifndef NO_TEMPORARY #ifndef NO_TEMPORARY
debug("AsynDriverInterface::readHandler(%s): " debug("AsynDriverInterface::readHandler(%s): "
"received %ld of %ld bytes \"%s\" " "received %" Z "d of %" Z "u bytes \"%s\" "
"eomReason=%s\n", "eomReason=%s\n",
clientName(), (long)received, bytesToRead, clientName(), received, bytesToRead,
StreamBuffer(buffer, received).expand()(), StreamBuffer(buffer, received).expand()(),
eomReasonStr[eomReason&0x7]); eomReasonStr[eomReason&0x7]);
#endif #endif
@ -1041,7 +1044,7 @@ readHandler()
size_t i; size_t i;
for (i = 0; i < deveoslen; i++, received++) for (i = 0; i < deveoslen; i++, received++)
{ {
if ((int)received >= 0) buffer[received] = deveos[i]; if ((ssize_t)received >= 0) buffer[received] = deveos[i];
// It is safe to add to buffer here, because // It is safe to add to buffer here, because
// the terminator was already there before // the terminator was already there before
// asynOctet->read() had cut it. // asynOctet->read() had cut it.
@ -1081,9 +1084,9 @@ readHandler()
#ifndef NO_TEMPORARY #ifndef NO_TEMPORARY
debug("AsynDriverInterface::readHandler(%s): " debug("AsynDriverInterface::readHandler(%s): "
"ioAction=%s, timeout [%g sec] " "ioAction=%s, timeout [%g sec] "
"after %ld of %ld bytes \"%s\"\n", "after %" Z "d of %" Z "u bytes \"%s\"\n",
clientName(), ioActionStr[ioAction], pasynUser->timeout, clientName(), ioActionStr[ioAction], pasynUser->timeout,
(long)received, bytesToRead, received, bytesToRead,
StreamBuffer(buffer, received).expand()()); StreamBuffer(buffer, received).expand()());
#endif #endif
if (ioAction == AsyncRead || ioAction == AsyncReadMore) if (ioAction == AsyncRead || ioAction == AsyncReadMore)
@ -1144,7 +1147,7 @@ readHandler()
bytesToRead = inputBuffer.capacity(); bytesToRead = inputBuffer.capacity();
} }
debug("AsynDriverInterface::readHandler(%s) " debug("AsynDriverInterface::readHandler(%s) "
"readMore=%ld bytesToRead=%ld\n", "readMore=%" Z "d bytesToRead=%" Z "u\n",
clientName(), readMore, bytesToRead); clientName(), readMore, bytesToRead);
pasynUser->timeout = readTimeout; pasynUser->timeout = readTimeout;
waitForReply = false; waitForReply = false;
@ -1204,7 +1207,7 @@ asynReadHandler(const char *buffer, size_t received, int eomReason)
#endif #endif
ioAction = None; ioAction = None;
long readMore = 1; ssize_t readMore = 1;
if (received) if (received)
{ {
// At the moment, it seems that asynDriver does not cut off // At the moment, it seems that asynDriver does not cut off
@ -1281,7 +1284,7 @@ asynReadHandler(const char *buffer, size_t received, int eomReason)
ioAction = AsyncReadMore; ioAction = AsyncReadMore;
startTimer(readTimeout); startTimer(readTimeout);
} }
debug("AsynDriverInterface::asynReadHandler(%s) readMore=%li, ioAction=%s \n", debug("AsynDriverInterface::asynReadHandler(%s) readMore=%" Z "d, ioAction=%s \n",
clientName(), readMore, ioActionStr[ioAction]); clientName(), readMore, ioActionStr[ioAction]);
} }

View File

@ -21,6 +21,8 @@
#include "StreamError.h" #include "StreamError.h"
#include "StreamBuffer.h" #include "StreamBuffer.h"
#define Z PRINTF_SIZE_T_PREFIX
// This is a non-blocking bus interface for debugging purpose. // This is a non-blocking bus interface for debugging purpose.
// Normally, a bus interface will use blocking I/O and thus require // Normally, a bus interface will use blocking I/O and thus require
// a separate thread. // a separate thread.
@ -35,7 +37,7 @@ class DebugInterface : StreamBusInterface
bool writeRequest(const void* output, size_t size, bool writeRequest(const void* output, size_t size,
unsigned long writeTimeout_ms); unsigned long writeTimeout_ms);
bool readRequest(unsigned long replyTimeout_ms, bool readRequest(unsigned long replyTimeout_ms,
unsigned long readTimeout_ms, long expectedLength, bool async); unsigned long readTimeout_ms, size_t expectedLength, bool async);
protected: protected:
~DebugInterface(); ~DebugInterface();
@ -167,9 +169,9 @@ writeRequest(const void* output, size_t size, unsigned long writeTimeout_ms)
// Return false if the read request cannot be accepted. // Return false if the read request cannot be accepted.
bool DebugInterface:: bool DebugInterface::
readRequest(unsigned long replyTimeout_ms, unsigned long readTimeout_ms, readRequest(unsigned long replyTimeout_ms, unsigned long readTimeout_ms,
long expectedLength, bool async) size_t expectedLength, bool async)
{ {
debug("DebugInterface::readRequest(%s, %ld msec reply, %ld msec read, expect %ld bytes, asyn=%s)\n", debug("DebugInterface::readRequest(%s, %ld msec reply, %ld msec read, expect %" Z "u bytes, asyn=%s)\n",
clientName(), replyTimeout_ms, readTimeout_ms, expectedLength, async?"yes":"no"); clientName(), replyTimeout_ms, readTimeout_ms, expectedLength, async?"yes":"no");
// Debug interface does not support async mode. // Debug interface does not support async mode.

View File

@ -70,7 +70,7 @@ printDouble(const StreamFormat& fmt, StreamBuffer& output, double value)
// Have to divide value into mantissa and exponent // Have to divide value into mantissa and exponent
// precision field is number of characters in mantissa // precision field is number of characters in mantissa
// number of characters in exponent is at least 2 // number of characters in exponent is at least 2
size_t spaces; ssize_t spaces;
StreamBuffer buf; StreamBuffer buf;
int prec = fmt.prec; int prec = fmt.prec;

View File

@ -22,6 +22,9 @@
#include "StreamError.h" #include "StreamError.h"
#include "string.h" #include "string.h"
#include "pcre.h" #include "pcre.h"
#include <limits.h>
#define Z PRINTF_SIZE_T_PREFIX
// Perl regular expressions (PCRE) %/regexp/ and %#/regexp/subst/ // Perl regular expressions (PCRE) %/regexp/ and %#/regexp/subst/
@ -121,17 +124,19 @@ scanString(const StreamFormat& fmt, const char* input,
{ {
int ovector[30]; int ovector[30];
int rc; int rc;
unsigned int l; size_t l;
const char* info = fmt.info; const char* info = fmt.info;
pcre* code = extract<pcre*>(info); pcre* code = extract<pcre*>(info);
int length = fmt.width > 0 ? fmt.width : strlen(input); size_t length = fmt.width > 0 ? fmt.width : strlen(input);
int subexpr = fmt.prec > 0 ? fmt.prec : 0; int subexpr = fmt.prec > 0 ? fmt.prec : 0;
if (length > INT_MAX)
length = INT_MAX;
debug("input = \"%s\"\n", input); debug("input = \"%s\"\n", input);
debug("length=%d\n", length); debug("length=%" Z "u\n", length);
rc = pcre_exec(code, NULL, input, length, 0, 0, ovector, 30); rc = pcre_exec(code, NULL, input, (int)length, 0, 0, ovector, 30);
debug("pcre_exec match \"%.*s\" result = %d\n", length, input, rc); debug("pcre_exec match \"%.*s\" result = %d\n", (int)length, input, rc);
if ((subexpr && rc <= subexpr) || rc < 0) if ((subexpr && rc <= subexpr) || rc < 0)
{ {
// error or no match or not enough sub-expressions // error or no match or not enough sub-expressions
@ -142,9 +147,9 @@ scanString(const StreamFormat& fmt, const char* input,
l = ovector[subexpr*2+1] - ovector[subexpr*2]; l = ovector[subexpr*2+1] - ovector[subexpr*2];
if (l >= size) { if (l >= size) {
if (!(fmt.flags & sign_flag)) { if (!(fmt.flags & sign_flag)) {
error("Regexp: Matching string \"%s\" too long (%d>%ld bytes). You may want to try the + flag: \"%%+/.../\"\n", error("Regexp: Matching string \"%s\" too long (%" Z "u>%" Z "u bytes). You may want to try the + flag: \"%%+/.../\"\n",
StreamBuffer(input + ovector[subexpr*2],l).expand()(), StreamBuffer(input + ovector[subexpr*2],l).expand()(),
l, (long)size-1); l, size-1);
return -1; return -1;
} }
l = size-1; l = size-1;
@ -155,11 +160,11 @@ scanString(const StreamFormat& fmt, const char* input,
return ovector[1]; // consume input until end of match return ovector[1]; // consume input until end of match
} }
static void regsubst(const StreamFormat& fmt, StreamBuffer& buffer, long start) static void regsubst(const StreamFormat& fmt, StreamBuffer& buffer, size_t start)
{ {
const char* subst = fmt.info; const char* subst = fmt.info;
pcre* code = extract<pcre*>(subst); pcre* code = extract<pcre*>(subst);
unsigned long length, c; size_t length, c;
int rc, l, r, rl, n; int rc, l, r, rl, n;
int ovector[30]; int ovector[30];
StreamBuffer s; StreamBuffer s;
@ -167,15 +172,17 @@ static void regsubst(const StreamFormat& fmt, StreamBuffer& buffer, long start)
length = buffer.length() - start; length = buffer.length() - start;
if (fmt.width && fmt.width < length) if (fmt.width && fmt.width < length)
length = fmt.width; length = fmt.width;
if (length > INT_MAX)
length = INT_MAX;
if (fmt.flags & sign_flag) if (fmt.flags & sign_flag)
start = buffer.length() - length; start = buffer.length() - length;
debug("regsubst buffer=\"%s\", start=%ld, length=%ld, subst = \"%s\"\n", debug("regsubst buffer=\"%s\", start=%" Z "u, length=%" Z "u, subst = \"%s\"\n",
buffer.expand()(), start, length, subst); buffer.expand()(), start, length, subst);
for (c = 0, n = 1; c < length; n++) for (c = 0, n = 1; c < length; n++)
{ {
rc = pcre_exec(code, NULL, buffer(start+c), length-c, 0, 0, ovector, 30); rc = pcre_exec(code, NULL, buffer(start+c), (int)(length-c), 0, 0, ovector, 30);
debug("pcre_exec match \"%.*s\" result = %d\n", (int)(length-c), buffer(start+c), rc); debug("pcre_exec match \"%.*s\" result = %d\n", (int)(length-c), buffer(start+c), rc);
if (rc < 0) // no match if (rc < 0) // no match
return; return;

View File

@ -106,7 +106,7 @@ writeRequest(const void*, size_t, unsigned long)
} }
bool StreamBusInterface:: bool StreamBusInterface::
readRequest(unsigned long, unsigned long, long, bool) readRequest(unsigned long, unsigned long, size_t, bool)
{ {
return false; return false;
} }
@ -126,8 +126,8 @@ writeCallback(StreamIoStatus)
{ {
} }
long StreamBusInterface::Client:: ssize_t StreamBusInterface::Client::
readCallback(StreamIoStatus, const void*, long) readCallback(StreamIoStatus, const void*, size_t)
{ {
return 0; return 0;
} }

View File

@ -51,8 +51,8 @@ public:
friend class StreamBusInterface; friend class StreamBusInterface;
virtual void lockCallback(StreamIoStatus status) = 0; virtual void lockCallback(StreamIoStatus status) = 0;
virtual void writeCallback(StreamIoStatus status); virtual void writeCallback(StreamIoStatus status);
virtual long readCallback(StreamIoStatus status, virtual ssize_t readCallback(StreamIoStatus status,
const void* input, long size); const void* input, size_t size);
virtual void eventCallback(StreamIoStatus status); virtual void eventCallback(StreamIoStatus status);
virtual void connectCallback(StreamIoStatus status); virtual void connectCallback(StreamIoStatus status);
virtual void disconnectCallback(StreamIoStatus status); virtual void disconnectCallback(StreamIoStatus status);
@ -88,7 +88,7 @@ public:
return businterface && businterface->writeRequest(output, size, timeout_ms); return businterface && businterface->writeRequest(output, size, timeout_ms);
} }
bool busReadRequest(unsigned long replytimeout_ms, bool busReadRequest(unsigned long replytimeout_ms,
unsigned long readtimeout_ms, long expectedLength, unsigned long readtimeout_ms, size_t expectedLength,
bool async) { bool async) {
return businterface && businterface->readRequest(replytimeout_ms, return businterface && businterface->readRequest(replytimeout_ms,
readtimeout_ms, expectedLength, async); readtimeout_ms, expectedLength, async);
@ -123,8 +123,8 @@ protected:
{ client->lockCallback(status); } { client->lockCallback(status); }
void writeCallback(StreamIoStatus status) void writeCallback(StreamIoStatus status)
{ client->writeCallback(status); } { client->writeCallback(status); }
long readCallback(StreamIoStatus status, ssize_t readCallback(StreamIoStatus status,
const void* input = NULL, long size = 0) const void* input = NULL, size_t size = 0)
{ return client->readCallback(status, input, size); } { return client->readCallback(status, input, size); }
void eventCallback(StreamIoStatus status) void eventCallback(StreamIoStatus status)
{ client->eventCallback(status); } { client->eventCallback(status); }
@ -143,7 +143,7 @@ protected:
virtual bool writeRequest(const void* output, size_t size, virtual bool writeRequest(const void* output, size_t size,
unsigned long timeout_ms); unsigned long timeout_ms);
virtual bool readRequest(unsigned long replytimeout_ms, virtual bool readRequest(unsigned long replytimeout_ms,
unsigned long readtimeout_ms, long expectedLength, unsigned long readtimeout_ms, size_t expectedLength,
bool async); bool async);
virtual bool supportsEvent(); // defaults to false virtual bool supportsEvent(); // defaults to false
virtual bool supportsAsyncRead(); // defaults to false virtual bool supportsAsyncRead(); // defaults to false

View File

@ -23,7 +23,7 @@
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#define P PRINTF_SIZE_T_PREFIX #define Z PRINTF_SIZE_T_PREFIX
enum Commands { end_cmd, in_cmd, out_cmd, wait_cmd, event_cmd, exec_cmd, enum Commands { end_cmd, in_cmd, out_cmd, wait_cmd, event_cmd, exec_cmd,
connect_cmd, disconnect_cmd }; connect_cmd, disconnect_cmd };
@ -900,7 +900,7 @@ bool StreamCore::
evalIn() evalIn()
{ {
flags |= AcceptInput; flags |= AcceptInput;
long expectedInput; ssize_t expectedInput;
expectedInput = maxInput; expectedInput = maxInput;
if (unparsedInput) if (unparsedInput)
@ -935,9 +935,9 @@ evalIn()
return true; return true;
} }
long StreamCore:: ssize_t StreamCore::
readCallback(StreamIoStatus status, readCallback(StreamIoStatus status,
const void* input, long size) const void* input, size_t size)
// returns number of bytes to read additionally // returns number of bytes to read additionally
{ {
@ -951,7 +951,7 @@ readCallback(StreamIoStatus status,
lastInputStatus = status; lastInputStatus = status;
#ifndef NO_TEMPORARY #ifndef NO_TEMPORARY
debug("StreamCore::readCallback(%s, status=%s input=\"%s\", size=%ld)\n", debug("StreamCore::readCallback(%s, status=%s input=\"%s\", size=%" Z "u)\n",
name(), StreamIoStatusStr[status], name(), StreamIoStatusStr[status],
StreamBuffer(input, size).expand()(), size); StreamBuffer(input, size).expand()(), size);
#endif #endif
@ -998,7 +998,7 @@ readCallback(StreamIoStatus status,
finishProtocol(ReplyTimeout); finishProtocol(ReplyTimeout);
return 0; return 0;
case StreamIoFault: case StreamIoFault:
error("%s: I/O error after reading %" P "d byte%s: \"%s%s\"\n", error("%s: I/O error after reading %" Z "d byte%s: \"%s%s\"\n",
name(), name(),
inputBuffer.length(), inputBuffer.length()==1 ? "" : "s", inputBuffer.length(), inputBuffer.length()==1 ? "" : "s",
inputBuffer.length() > 20 ? "..." : "", inputBuffer.length() > 20 ? "..." : "",
@ -1007,7 +1007,7 @@ readCallback(StreamIoStatus status,
return 0; return 0;
} }
inputBuffer.append(input, size); inputBuffer.append(input, size);
debug("StreamCore::readCallback(%s) inputBuffer=\"%s\", size %" P "d\n", debug("StreamCore::readCallback(%s) inputBuffer=\"%s\", size %" Z "u\n",
name(), inputBuffer.expand()(), inputBuffer.length()); name(), inputBuffer.expand()(), inputBuffer.length());
if (*activeCommand != in_cmd) if (*activeCommand != in_cmd)
{ {
@ -1049,7 +1049,7 @@ readCallback(StreamIoStatus status,
if (end >= 0) if (end >= 0)
{ {
termlen = inTerminator.length(); termlen = inTerminator.length();
debug("StreamCore::readCallback(%s) inTerminator %s at position %" P "d\n", debug("StreamCore::readCallback(%s) inTerminator %s at position %" Z "u\n",
name(), inTerminator.expand()(), end); name(), inTerminator.expand()(), end);
} else { } else {
debug("StreamCore::readCallback(%s) inTerminator %s not found\n", debug("StreamCore::readCallback(%s) inTerminator %s not found\n",
@ -1066,8 +1066,8 @@ readCallback(StreamIoStatus status,
if (maxInput && end < 0 && maxInput <= inputBuffer.length()) if (maxInput && end < 0 && maxInput <= inputBuffer.length())
{ {
// no terminator but maxInput bytes read // no terminator but maxInput bytes read
debug("StreamCore::readCallback(%s) maxInput size reached\n", debug("StreamCore::readCallback(%s) maxInput size %lu reached\n",
name()); name(), maxInput);
end = maxInput; end = maxInput;
} }
if (maxInput && end > (ssize_t)maxInput) if (maxInput && end > (ssize_t)maxInput)
@ -1092,7 +1092,7 @@ readCallback(StreamIoStatus status,
name()); name());
flags |= AcceptInput; flags |= AcceptInput;
if (maxInput) if (maxInput)
return (long)(maxInput - inputBuffer.length()); return maxInput - inputBuffer.length();
else else
return -1; return -1;
} }
@ -1110,7 +1110,7 @@ readCallback(StreamIoStatus status,
} }
else else
{ {
error("%s: Timeout after reading %" P "d byte%s \"%s%s\"\n", error("%s: Timeout after reading %" Z "d byte%s \"%s%s\"\n",
name(), end, end==1 ? "" : "s", end > 20 ? "..." : "", name(), end, end==1 ? "" : "s", end > 20 ? "..." : "",
inputBuffer.expand(-20)()); inputBuffer.expand(-20)());
} }
@ -1366,7 +1366,7 @@ normal_format:
{ {
int i = 0; int i = 0;
while (commandIndex[i] >= ' ') i++; while (commandIndex[i] >= ' ') i++;
error("%s: Input \"%s%s\" mismatch after %" P "d byte%s: %c != %c\n", error("%s: Input \"%s%s\" mismatch after %" Z "d byte%s: %c != %c\n",
name(), name(),
consumedInput > 10 ? "..." : "", consumedInput > 10 ? "..." : "",
inputLine.expand(consumedInput > 10 ? inputLine.expand(consumedInput > 10 ?
@ -1393,18 +1393,18 @@ normal_format:
{ {
if (!(flags & AsyncMode) && onMismatch[0] != in_cmd) if (!(flags & AsyncMode) && onMismatch[0] != in_cmd)
{ {
error("%s: %" P "d byte%s surplus input \"%s%s\"\n", error("%s: %" Z "d byte%s surplus input \"%s%s\"\n",
name(), surplus, surplus==1 ? "" : "s", name(), surplus, surplus==1 ? "" : "s",
inputLine.expand(consumedInput, 20)(), inputLine.expand(consumedInput, 20)(),
surplus > 20 ? "..." : ""); surplus > 20 ? "..." : "");
if (consumedInput>20) if (consumedInput>20)
error("%s: after %" P "d byte%s \"...%s\"\n", error("%s: after %" Z "d byte%s \"...%s\"\n",
name(), consumedInput, name(), consumedInput,
consumedInput==1 ? "" : "s", consumedInput==1 ? "" : "s",
inputLine.expand(consumedInput-20, 20)()); inputLine.expand(consumedInput-20, 20)());
else else
error("%s: after %" P "d byte%s: \"%s\"\n", error("%s: after %" Z "d byte%s: \"%s\"\n",
name(), consumedInput, name(), consumedInput,
consumedInput==1 ? "" : "s", consumedInput==1 ? "" : "s",
inputLine.expand(0, consumedInput)()); inputLine.expand(0, consumedInput)());
@ -1536,7 +1536,7 @@ scanValue(const StreamFormat& fmt, char* value, size_t& size)
if (!matchSeparator()) return -1; if (!matchSeparator()) return -1;
ssize_t consumed = StreamFormatConverter::find(fmt.conv)-> ssize_t consumed = StreamFormatConverter::find(fmt.conv)->
scanString(fmt, inputLine(consumedInput), value, size); scanString(fmt, inputLine(consumedInput), value, size);
debug("StreamCore::scanValue(%s, format=%%%c, char*, size=%" P "d) input=\"%s\"\n", debug("StreamCore::scanValue(%s, format=%%%c, char*, size=%" Z "d) input=\"%s\"\n",
name(), fmt.conv, size, inputLine.expand(consumedInput)()); name(), fmt.conv, size, inputLine.expand(consumedInput)());
if (consumed < 0) if (consumed < 0)
{ {

View File

@ -194,8 +194,8 @@ protected:
// StreamBusInterface::Client methods // StreamBusInterface::Client methods
void lockCallback(StreamIoStatus status); void lockCallback(StreamIoStatus status);
void writeCallback(StreamIoStatus status); void writeCallback(StreamIoStatus status);
long readCallback(StreamIoStatus status, ssize_t readCallback(StreamIoStatus status,
const void* input, long size); const void* input, size_t size);
void eventCallback(StreamIoStatus status); void eventCallback(StreamIoStatus status);
void execCallback(StreamIoStatus status); void execCallback(StreamIoStatus status);
void connectCallback(StreamIoStatus status); void connectCallback(StreamIoStatus status);

View File

@ -80,7 +80,7 @@ extern "C" epicsShareFunc int epicsShareAPI iocshCmd(const char *command);
#include <sysSymTbl.h> #include <sysSymTbl.h>
#endif #endif
#define P PRINTF_SIZE_T_PREFIX #define Z PRINTF_SIZE_T_PREFIX
enum MoreFlags { enum MoreFlags {
// 0x00FFFFFF used by StreamCore // 0x00FFFFFF used by StreamCore
@ -1186,7 +1186,7 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
{ {
consumed = scanValue(format, lval); consumed = scanValue(format, lval);
if (consumed >= 0) ((epicsUInt32*)buffer)[nord] = lval; if (consumed >= 0) ((epicsUInt32*)buffer)[nord] = lval;
debug("Stream::matchValue(%s): %s.%s[%" P "u] = %lu\n", debug("Stream::matchValue(%s): %s.%s[%" Z "u] = %lu\n",
name(), pdbaddr->precord->name, name(), pdbaddr->precord->name,
((dbFldDes*)pdbaddr->pfldDes)->name, ((dbFldDes*)pdbaddr->pfldDes)->name,
nord, lval); nord, lval);
@ -1196,7 +1196,7 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
{ {
consumed = scanValue(format, lval); consumed = scanValue(format, lval);
if (consumed >= 0) ((epicsInt32*)buffer)[nord] = lval; if (consumed >= 0) ((epicsInt32*)buffer)[nord] = lval;
debug("Stream::matchValue(%s): %s.%s[%" P "u] = %li\n", debug("Stream::matchValue(%s): %s.%s[%" Z "u] = %li\n",
name(), pdbaddr->precord->name, name(), pdbaddr->precord->name,
((dbFldDes*)pdbaddr->pfldDes)->name, ((dbFldDes*)pdbaddr->pfldDes)->name,
nord, lval); nord, lval);
@ -1207,7 +1207,7 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
consumed = scanValue(format, lval); consumed = scanValue(format, lval);
if (consumed >= 0) if (consumed >= 0)
((epicsUInt16*)buffer)[nord] = (epicsUInt16)lval; ((epicsUInt16*)buffer)[nord] = (epicsUInt16)lval;
debug("Stream::matchValue(%s): %s.%s[%" P "u] = %li\n", debug("Stream::matchValue(%s): %s.%s[%" Z "u] = %li\n",
name(), pdbaddr->precord->name, name(), pdbaddr->precord->name,
((dbFldDes*)pdbaddr->pfldDes)->name, ((dbFldDes*)pdbaddr->pfldDes)->name,
nord, lval); nord, lval);
@ -1223,7 +1223,7 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
if (consumed >= 0) if (consumed >= 0)
memcpy(((epicsFloat64*)buffer)+nord, memcpy(((epicsFloat64*)buffer)+nord,
&f64, sizeof(f64)); &f64, sizeof(f64));
debug("Stream::matchValue(%s): %s.%s[%" P "u] = %#g %#g\n", debug("Stream::matchValue(%s): %s.%s[%" Z "u] = %#g %#g\n",
name(), pdbaddr->precord->name, name(), pdbaddr->precord->name,
((dbFldDes*)pdbaddr->pfldDes)->name, ((dbFldDes*)pdbaddr->pfldDes)->name,
nord, dval, nord, dval,
@ -1249,7 +1249,7 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
stringsize = MAX_STRING_SIZE; stringsize = MAX_STRING_SIZE;
consumed = scanValue(format, consumed = scanValue(format,
buffer+MAX_STRING_SIZE*nord, stringsize); buffer+MAX_STRING_SIZE*nord, stringsize);
debug("Stream::matchValue(%s): %s.%s[%" P "u] = \"%.*s\"\n", debug("Stream::matchValue(%s): %s.%s[%" Z "u] = \"%.*s\"\n",
name(), pdbaddr->precord->name, name(), pdbaddr->precord->name,
((dbFldDes*)pdbaddr->pfldDes)->name, ((dbFldDes*)pdbaddr->pfldDes)->name,
nord, (int)stringsize, buffer+MAX_STRING_SIZE*nord); nord, (int)stringsize, buffer+MAX_STRING_SIZE*nord);
@ -1353,14 +1353,14 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
case DBF_ULONG: case DBF_ULONG:
case DBF_LONG: case DBF_LONG:
case DBF_ENUM: case DBF_ENUM:
error("%s: %s(%s.%s, %s, %li, %" P "u) failed\n", error("%s: %s(%s.%s, %s, %li, %" Z "u) failed\n",
name(), putfunc, pdbaddr->precord->name, name(), putfunc, pdbaddr->precord->name,
((dbFldDes*)pdbaddr->pfldDes)->name, ((dbFldDes*)pdbaddr->pfldDes)->name,
pamapdbfType[fmt.type].strvalue, pamapdbfType[fmt.type].strvalue,
lval, nord); lval, nord);
return false; return false;
case DBF_DOUBLE: case DBF_DOUBLE:
error("%s: %s(%s.%s, %s, %#g, %" P "u) failed\n", error("%s: %s(%s.%s, %s, %#g, %" Z "u) failed\n",
name(), putfunc, pdbaddr->precord->name, name(), putfunc, pdbaddr->precord->name,
((dbFldDes*)pdbaddr->pfldDes)->name, ((dbFldDes*)pdbaddr->pfldDes)->name,
pamapdbfType[fmt.type].strvalue, pamapdbfType[fmt.type].strvalue,
@ -1368,7 +1368,7 @@ matchValue(const StreamFormat& format, const void* fieldaddress)
return false; return false;
case DBF_STRING: case DBF_STRING:
case DBF_CHAR: case DBF_CHAR:
error("%s: %s(%s.%s, %s, \"%.*s\", %" P "u) failed\n", error("%s: %s(%s.%s, %s, \"%.*s\", %" Z "u) failed\n",
name(), putfunc, pdbaddr->precord->name, name(), putfunc, pdbaddr->precord->name,
((dbFldDes*)pdbaddr->pfldDes)->name, ((dbFldDes*)pdbaddr->pfldDes)->name,
pamapdbfType[fmt.type].strvalue, pamapdbfType[fmt.type].strvalue,