diff --git a/src/ca/client/CAref.html b/src/ca/client/CAref.html
index 87ad469a6..2bdd0b452 100644
--- a/src/ca/client/CAref.html
+++ b/src/ca/client/CAref.html
@@ -1146,16 +1146,10 @@ the output.
Wide mode "name timestamp value stat sevr" (read PVs as
DBR_TIME_xxx) |
-
- | -n |
- Print DBF_ENUM values as number (default are enum strings) |
-
| -d <type> |
- Request specific dbr type; use string (DBR_ prefix may be omitted)
-
- or number of one of the following types:
-
+ | Request specific dbr type; use string (DBR_ prefix may be omitted)
+ or number of one of the following types:
@@ -1272,6 +1266,14 @@ the output.
|
+
+ |
+ Enum format: |
+
+
+ | -n |
+ Print DBF_ENUM value as number (default is enum string) |
+
|
Arrays: |
@@ -1303,15 +1305,15 @@ the output.
| -e <nr> |
- Use %e format, with <nr> digits after the decimal point |
+ Use %e format, with a precision of <nr> digits |
| -f <nr> |
- Use %f format, with <nr> digits after the decimal point |
+ Use %f format, with a precision of <nr> digits |
| -g <nr> |
- Use %g format, with <nr> digits after the decimal point |
+ Use %g format, with a precision of <nr> digits |
| -s |
@@ -1349,6 +1351,14 @@ the output.
-0b |
Print as binary number |
+
+ |
+ Alternate output field separator: |
+
+
+ | -F <ofs> |
+ Use <ofs> as an alternate output field separator |
+
@@ -1381,9 +1391,10 @@ the output.
Wait time, specifies longer CA timeout, default is 1.0 second |
- | -m <mask> |
- Specify CA event mask to use, with <mask> being any combination
- of 'v' (value), 'a' (alarm), 'l' (log), 'p' (property). Default: va |
+ -m <msk> |
+ Specify CA event mask to use. <msk> is any combination of
+ 'v' (value), 'a' (alarm), 'l' (log/archive), 'p' (property).
+ Default event mask is 'va' |
| -p <prio> |
@@ -1405,8 +1416,8 @@ the output.
'n' = no timestamps
'r' = relative timestamps (time elapsed since start of program)
'i' = incremental timestamps (time elapsed since last update)
- 'I' = incremental timestamps (time elapsed since last update, by
- channel)
+ 'I' = incremental timestamps (time since last update, by channel)
+ 'r', 'i' or 'I' require 's' or 'c' to select the time source
|
@@ -1414,7 +1425,7 @@ the output.
| -n |
- Print DBF_ENUM values as number (default are enum strings) |
+ Print DBF_ENUM values as number (default is enum string) |
|
@@ -1422,16 +1433,15 @@ the output.
|
- Value format: Print number of requested values, then list of
- values |
+ Array values: Print number of elements, then list of values |
| Default: |
- Print all values |
+ Default: Request and print all elements (dynamic arrays supported) |
- | -# <count> |
- Print first <count> elements of an array |
+ -# <num> |
+ Request and print up to <num> elements |
| -S |
@@ -1439,23 +1449,23 @@ the output.
|
- Floating point type format: |
+ Floating point format: |
| Default: |
Use %g format |
- | -e <nr> |
- Use %e format, with <nr> digits after the decimal point |
+ -e <num> |
+ Use %e format, with a precision of <num> digits |
- | -f <nr> |
- Use %f format, with <nr> digits after the decimal point |
+ -f <num> |
+ Use %f format, with a precision of <num> digits |
- | -g <nr> |
- Use %g format, with <nr> digits after the decimal point |
+ -g <num> |
+ Use %g format, with a precision of <num> digits |
| -s |
@@ -1497,21 +1507,27 @@ the output.
-caput [options] <PV name> <value>
+caput [options] <PV name> <value> ...
caput -a [options] <PV name> <no of elements> <value> ...
Description
Put value to a PV.
-The specified value is written to the PV (as a string). The PV value is read
-before and after the write operation and printed as "Old" and "new" values on
-stdout.
+The specified value is written to the PV (as a string). The PV's value is
+read before and after the write operation and printed as "Old" and "New" values
+on stdout.
-The array variant writes an array to the specified PV. The first numeric
-argument specifying the number of array elements is kept for compatibility with
-the array data format of caget - the actual number of values specified on the
-command line is used.
+There are two variants to the arguments for this command. For the scalar
+variant without the -a flag, all the value arguments provided after
+the PV name are concatenated with a single space character between them, and the
+resulting string (up to 40 characters long unless the -S flag is
+given) is written to the specified PV.
+
+The array variant with the -a flag writes an array of string
+values to the specified PV. The numeric argument giving the number of array
+elements is actually ignored, the array length to be written is actually
+controlled by the number of values provided on the command line.
@@ -1550,12 +1566,16 @@ command line is used.
| -t |
Terse mode - print only successfully written value, without name |
+
+ | -l |
+ Long mode "name timestamp value stat sevr" (read PVs as DBR_TIME_xxx) |
+
|
Enum Format: |
- |
+ Default: |
Auto - try value as ENUM string, then as index number |
@@ -1571,17 +1591,24 @@ command line is used.
| Arrays: |
- | -a |
- Put array data |
+ Default: |
+ Put scalar |
|
- Value format: Print number of requested values, then list of
- values |
+ Value format: all value arguments concatenated with spaces |
| -S |
- Put string as an array of char (long string) |
+ Put string as an array of chars (long string) |
+
+
+ | -a |
+ Put array |
+
+
+ |
+ Value format: number of values, then list of values |
diff --git a/src/ca/client/repeater.cpp b/src/ca/client/repeater.cpp
index 5e123ee2d..61ba33fc5 100644
--- a/src/ca/client/repeater.cpp
+++ b/src/ca/client/repeater.cpp
@@ -504,6 +504,7 @@ void ca_repeater ()
if ( sockerrno == SOCK_EADDRINUSE ) {
osiSockRelease ();
debugPrintf ( ( "CA Repeater: exiting because a repeater is already running\n" ) );
+ delete [] pBuf;
return;
}
char sockErrBuf[64];
diff --git a/src/ca/client/tools/caput.c b/src/ca/client/tools/caput.c
index f6dcc21cd..9c50cd9df 100644
--- a/src/ca/client/tools/caput.c
+++ b/src/ca/client/tools/caput.c
@@ -56,7 +56,7 @@ static epicsEventId epId;
void usage (void)
{
- fprintf (stderr, "\nUsage: caput [options] \n"
+ fprintf (stderr, "\nUsage: caput [options] ...\n"
" caput -a [options] ...\n\n"
" -h: Help: Print this message\n"
"Channel Access options:\n"
@@ -71,9 +71,11 @@ void usage (void)
" -n: Force interpretation of values as numbers\n"
" -s: Force interpretation of values as strings\n"
"Arrays:\n"
+ " Default: Put scalar\n"
+ " Value format: all value arguments concatenated with spaces\n"
+ " -S: Put string as an array of chars (long string)\n"
" -a: Put array\n"
- " Value format: number of requested values, then list of values\n"
- " -S: Put string as an array of char (long string)\n"
+ " Value format: number of values, then list of values\n"
"Alternate output field separator:\n"
" -F : Use as an alternate output field separator\n"
"\nExample: caput my_channel 1.2\n"
diff --git a/src/ca/client/udpiiu.cpp b/src/ca/client/udpiiu.cpp
index adf2ba949..beae07560 100644
--- a/src/ca/client/udpiiu.cpp
+++ b/src/ca/client/udpiiu.cpp
@@ -915,10 +915,12 @@ bool udpiiu::pushDatagramMsg ( epicsGuard < epicsMutex > & guard,
caHdr * pbufmsg = ( caHdr * ) &this->xmitBuf[this->nBytesInXmitBuf];
*pbufmsg = msg;
- memcpy ( pbufmsg + 1, pExt, extsize );
- if ( extsize != alignedExtSize ) {
- char *pDest = (char *) ( pbufmsg + 1 );
- memset ( pDest + extsize, '\0', alignedExtSize - extsize );
+ if ( extsize ) {
+ memcpy ( pbufmsg + 1, pExt, extsize );
+ if ( extsize != alignedExtSize ) {
+ char *pDest = (char *) ( pbufmsg + 1 );
+ memset ( pDest + extsize, '\0', alignedExtSize - extsize );
+ }
}
AlignedWireRef < epicsUInt16 > ( pbufmsg->m_postsize ) = alignedExtSize;
this->nBytesInXmitBuf += msgsize;
diff --git a/src/ca/legacy/gdd/gddTest.cc b/src/ca/legacy/gdd/gddTest.cc
index d36014018..881a55df9 100644
--- a/src/ca/legacy/gdd/gddTest.cc
+++ b/src/ca/legacy/gdd/gddTest.cc
@@ -308,7 +308,7 @@ void gdd::test()
pdd->convertOffsetsToAddress();
pdd->dump();
pdd->unreference();
- delete buf;
+ delete [] buf;
}
#endif
@@ -510,7 +510,7 @@ void gddContainer::test(void)
fprintf(stderr,"=====RE-DUMP OF ORIGINAL CONTAINER:\n");
dump();
cdd1->unreference();
- delete buf;
+ delete [] buf;
// test copy(), Dup(), copyInfo()
fprintf(stderr,"=======CREATING TEST CONTAINER FOR *COPY* TEST:\n");
diff --git a/src/ca/legacy/pcas/example/directoryService/main.cc b/src/ca/legacy/pcas/example/directoryService/main.cc
index cb8c43901..76f27e75d 100644
--- a/src/ca/legacy/pcas/example/directoryService/main.cc
+++ b/src/ca/legacy/pcas/example/directoryService/main.cc
@@ -170,7 +170,7 @@ static int parseDirectoryFP (FILE *pf, const char *pFileName)
status = aToIPAddr (hostNameStr, 0u, &ipa);
if (status) {
- fprintf (pf, "Unknown host name=\"%s\" (or bad dotted ip addr) in \"%s\" with PV=\"%s\"?\n",
+ fprintf (stderr, "Unknown host name=\"%s\" (or bad dotted ip addr) in \"%s\" with PV=\"%s\"?\n",
hostNameStr, pFileName, pvNameStr);
return -1;
}
diff --git a/src/ca/legacy/pcas/generic/casChannelI.cc b/src/ca/legacy/pcas/generic/casChannelI.cc
index 588f67d78..376f62f8c 100644
--- a/src/ca/legacy/pcas/generic/casChannelI.cc
+++ b/src/ca/legacy/pcas/generic/casChannelI.cc
@@ -21,6 +21,7 @@ casChannelI::casChannelI ( casCoreClient & clientIn,
casChannel & chanIn, casPVI & pvIn, ca_uint32_t cidIn ) :
privateForPV ( clientIn, *this ),
pv ( pvIn ),
+ maxElem( pvIn.nativeCount() ),
chan ( chanIn ),
cid ( cidIn ),
serverDeletePending ( false ),
@@ -29,7 +30,7 @@ casChannelI::casChannelI ( casCoreClient & clientIn,
}
casChannelI::~casChannelI ()
-{
+{
this->privateForPV.client().removeFromEventQueue (
*this, this->accessRightsEvPending );
@@ -48,7 +49,7 @@ void casChannelI::uninstallFromPV ( casEventSys & eventSys )
this->privateForPV.removeSelfFromPV ( this->pv, dest );
while ( casMonitor * pMon = dest.get () ) {
eventSys.prepareMonitorForDestroy ( *pMon );
- }
+ }
}
void casChannelI::show ( unsigned level ) const
@@ -68,13 +69,13 @@ caStatus casChannelI::cbFunc (
{
caStatus stat = S_cas_success;
{
- stat = this->privateForPV.client().accessRightsResponse (
+ stat = this->privateForPV.client().accessRightsResponse (
clientGuard, this );
}
- if ( stat == S_cas_success ) {
- this->accessRightsEvPending = false;
- }
- return stat;
+ if ( stat == S_cas_success ) {
+ this->accessRightsEvPending = false;
+ }
+ return stat;
}
caStatus casChannelI::read ( const casCtx & ctx, gdd & prototype )
diff --git a/src/ca/legacy/pcas/generic/casChannelI.h b/src/ca/legacy/pcas/generic/casChannelI.h
index 2c72e88e4..a0f74a1df 100644
--- a/src/ca/legacy/pcas/generic/casChannelI.h
+++ b/src/ca/legacy/pcas/generic/casChannelI.h
@@ -1,4 +1,3 @@
-
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
@@ -31,55 +30,62 @@ class casChannelI : public tsDLNode < casChannelI >,
public:
casChannelI ( casCoreClient & clientIn, casChannel & chanIn,
casPVI & pvIn, ca_uint32_t cidIn );
- ~casChannelI ();
+ ~casChannelI ();
void casChannelDestroyFromInterfaceNotify ();
- const caResId getCID ();
- const caResId getSID ();
+ const caResId getCID ();
+ const caResId getSID ();
void uninstallFromPV ( casEventSys & eventSys );
void installIntoPV ();
void installIO ( casAsyncIOI & );
void uninstallIO ( casAsyncIOI & );
void installMonitor ( casMonitor & mon );
casMonitor * removeMonitor ( ca_uint32_t clientIdIn );
- casPVI & getPVI () const;
- void clearOutstandingReads ();
- void postAccessRightsEvent ();
+ casPVI & getPVI () const;
+ void clearOutstandingReads ();
+ void postAccessRightsEvent ();
const gddEnumStringTable & enumStringTable () const;
- void setOwner ( const char * const pUserName,
- const char * const pHostName );
- bool readAccess () const;
+ ca_uint32_t getMaxElem () const;
+ void setOwner ( const char * const pUserName,
+ const char * const pHostName );
+ bool readAccess () const;
bool writeAccess () const;
- bool confirmationRequested () const;
+ bool confirmationRequested () const;
caStatus read ( const casCtx & ctx, gdd & prototype );
caStatus write ( const casCtx & ctx, const gdd & value );
caStatus writeNotify ( const casCtx & ctx, const gdd & value );
- void show ( unsigned level ) const;
+ void show ( unsigned level ) const;
private:
chanIntfForPV privateForPV;
- tsDLList < casAsyncIOI > ioList;
- casPVI & pv;
+ tsDLList < casAsyncIOI > ioList;
+ casPVI & pv;
+ ca_uint32_t maxElem;
casChannel & chan;
- caResId cid; // client id
+ caResId cid; // client id
bool serverDeletePending;
- bool accessRightsEvPending;
- //epicsShareFunc virtual void destroy ();
- caStatus cbFunc (
+ bool accessRightsEvPending;
+ //epicsShareFunc virtual void destroy ();
+ caStatus cbFunc (
casCoreClient &,
epicsGuard < casClientMutex > &,
epicsGuard < evSysMutex > & );
void postDestroyEvent ();
- casChannelI ( const casChannelI & );
- casChannelI & operator = ( const casChannelI & );
+ casChannelI ( const casChannelI & );
+ casChannelI & operator = ( const casChannelI & );
};
inline casPVI & casChannelI::getPVI () const
{
- return this->pv;
+ return this->pv;
+}
+
+inline ca_uint32_t casChannelI::getMaxElem () const
+{
+ return this->maxElem;
}
inline const caResId casChannelI::getCID ()
{
- return this->cid;
+ return this->cid;
}
inline const caResId casChannelI::getSID ()
@@ -89,7 +95,7 @@ inline const caResId casChannelI::getSID ()
inline void casChannelI::postAccessRightsEvent ()
{
- this->privateForPV.client().addToEventQueue ( *this, this->accessRightsEvPending );
+ this->privateForPV.client().addToEventQueue ( *this, this->accessRightsEvPending );
}
inline const gddEnumStringTable & casChannelI::enumStringTable () const
@@ -108,7 +114,7 @@ inline void casChannelI::clearOutstandingReads ()
}
inline void casChannelI::setOwner ( const char * const pUserName,
- const char * const pHostName )
+ const char * const pHostName )
{
this->chan.setOwner ( pUserName, pHostName );
}
diff --git a/src/ca/legacy/pcas/generic/casDGClient.cc b/src/ca/legacy/pcas/generic/casDGClient.cc
index 468f58148..83dc5ddd4 100644
--- a/src/ca/legacy/pcas/generic/casDGClient.cc
+++ b/src/ca/legacy/pcas/generic/casDGClient.cc
@@ -24,39 +24,39 @@
casDGClient::pCASMsgHandler const casDGClient::msgHandlers[] =
{
- & casDGClient::versionAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
+ & casDGClient::versionAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
& casDGClient::uknownMessageAction,
& casDGClient::searchAction,
& casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::echoAction,
- & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::echoAction,
+ & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction,
- & casDGClient::uknownMessageAction
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction,
+ & casDGClient::uknownMessageAction
};
//
@@ -84,7 +84,7 @@ casDGClient::~casDGClient()
//
void casDGClient::destroy()
{
- printf("Attempt to destroy the DG client was ignored\n");
+ printf("Attempt to destroy the DG client was ignored\n");
}
//
@@ -92,16 +92,16 @@ void casDGClient::destroy()
//
void casDGClient::show (unsigned level) const
{
- printf ( "casDGClient at %p\n",
+ printf ( "casDGClient at %p\n",
static_cast ( this ) );
- if (level>=1u) {
- char buf[64];
- this->hostName (buf, sizeof(buf));
- printf ("Client Host=%s\n", buf);
+ if (level>=1u) {
+ char buf[64];
+ this->hostName (buf, sizeof(buf));
+ printf ("Client Host=%s\n", buf);
this->casCoreClient::show ( level - 1u );
this->in.show ( level - 1u );
this->out.show ( level - 1u );
- }
+ }
}
//
@@ -109,7 +109,7 @@ void casDGClient::show (unsigned level) const
//
caStatus casDGClient::uknownMessageAction ()
{
- const caHdrLargeArray * mp = this->ctx.getMsg();
+ const caHdrLargeArray * mp = this->ctx.getMsg();
char pHostName[64u];
this->lastRecvAddr.stringConvert ( pHostName, sizeof ( pHostName ) );
@@ -117,7 +117,7 @@ caStatus casDGClient::uknownMessageAction ()
caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
"bad request code=%u in DG\n", mp->m_cmmd );
- return S_cas_badProtocol;
+ return S_cas_badProtocol;
}
//
@@ -125,9 +125,9 @@ caStatus casDGClient::uknownMessageAction ()
//
caStatus casDGClient::searchAction()
{
- const caHdrLargeArray *mp = this->ctx.getMsg();
+ const caHdrLargeArray *mp = this->ctx.getMsg();
const char *pChanName = static_cast ( this->ctx.getData() );
- caStatus status;
+ caStatus status;
//
// check the sanity of the message
@@ -135,7 +135,7 @@ caStatus casDGClient::searchAction()
if ( mp->m_postsize <= 1 ) {
char pHostName[64u];
this->lastRecvAddr.stringConvert ( pHostName, sizeof ( pHostName ) );
- caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
+ caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
"empty PV name extension in UDP search request?\n" );
return S_cas_success;
}
@@ -143,7 +143,7 @@ caStatus casDGClient::searchAction()
if ( pChanName[0] == '\0' ) {
char pHostName[64u];
this->lastRecvAddr.stringConvert ( pHostName, sizeof ( pHostName ) );
- caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
+ caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
"zero length PV name in UDP search request?\n" );
return S_cas_success;
}
@@ -155,56 +155,56 @@ caStatus casDGClient::searchAction()
if ( i <= 1 ) {
char pHostName[64u];
this->lastRecvAddr.stringConvert ( pHostName, sizeof ( pHostName ) );
- caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
+ caServerI::dumpMsg ( pHostName, "?", mp, this->ctx.getData(),
"unterminated PV name in UDP search request?\n" );
return S_cas_success;
}
}
- if ( this->getCAS().getDebugLevel() > 6u ) {
- char pHostName[64u];
- this->hostName ( pHostName, sizeof ( pHostName ) );
- printf ( "\"%s\" is searching for \"%s\"\n",
+ if ( this->getCAS().getDebugLevel() > 6u ) {
+ char pHostName[64u];
+ this->hostName ( pHostName, sizeof ( pHostName ) );
+ printf ( "\"%s\" is searching for \"%s\"\n",
pHostName, pChanName );
- }
+ }
- //
- // verify that we have sufficent memory for a PV and a
- // monitor prior to calling PV exist test so that when
- // the server runs out of memory we dont reply to
- // search requests, and therefore dont thrash through
- // caServer::pvExistTest() and casCreatePV::pvAttach()
- //
+ //
+ // verify that we have sufficent memory for a PV and a
+ // monitor prior to calling PV exist test so that when
+ // the server runs out of memory we dont reply to
+ // search requests, and therefore dont thrash through
+ // caServer::pvExistTest() and casCreatePV::pvAttach()
+ //
if ( ! osiSufficentSpaceInPool ( 0 ) ) {
return S_cas_success;
}
- //
- // ask the server tool if this PV exists
- //
- this->userStartedAsyncIO = false;
- pvExistReturn pver =
- this->getCAS()->pvExistTest ( this->ctx, this->lastRecvAddr, pChanName );
+ //
+ // ask the server tool if this PV exists
+ //
+ this->userStartedAsyncIO = false;
+ pvExistReturn pver =
+ this->getCAS()->pvExistTest ( this->ctx, this->lastRecvAddr, pChanName );
- //
- // prevent problems when they initiate
- // async IO but dont return status
- // indicating so (and vise versa)
- //
- if ( this->userStartedAsyncIO ) {
+ //
+ // prevent problems when they initiate
+ // async IO but dont return status
+ // indicating so (and vise versa)
+ //
+ if ( this->userStartedAsyncIO ) {
if ( pver.getStatus() != pverAsyncCompletion ) {
- errMessage (S_cas_badParameter,
- "- assuming asynch IO status from caServer::pvExistTest()");
+ errMessage (S_cas_badParameter,
+ "- assuming asynch IO status from caServer::pvExistTest()");
}
status = S_cas_success;
- }
- else {
- //
- // otherwise we assume sync IO operation was initiated
- //
+ }
+ else {
+ //
+ // otherwise we assume sync IO operation was initiated
+ //
switch ( pver.getStatus() ) {
case pverExistsHere:
- status = this->searchResponse (*mp, pver);
+ status = this->searchResponse (*mp, pver);
break;
case pverDoesNotExistHere:
@@ -212,18 +212,18 @@ caStatus casDGClient::searchAction()
break;
case pverAsyncCompletion:
- errMessage (S_cas_badParameter,
- "- unexpected asynch IO status from caServer::pvExistTest() ignored");
+ errMessage (S_cas_badParameter,
+ "- unexpected asynch IO status from caServer::pvExistTest() ignored");
status = S_cas_success;
break;
default:
- errMessage (S_cas_badParameter,
- "- invalid return from caServer::pvExistTest() ignored");
+ errMessage (S_cas_badParameter,
+ "- invalid return from caServer::pvExistTest() ignored");
status = S_cas_success;
break;
- }
- }
+ }
+ }
return status;
}
@@ -340,9 +340,9 @@ caStatus casDGClient::searchResponse ( const caHdrLargeArray & msg,
}
//
-// casDGClient::searchFailResponse()
-// (only when requested by the client
-// - when it isnt a reply to a broadcast)
+// casDGClient::searchFailResponse()
+// (only when requested by the client
+// - when it isnt a reply to a broadcast)
//
caStatus casDGClient::searchFailResponse ( const caHdrLargeArray * mp )
{
@@ -350,9 +350,9 @@ caStatus casDGClient::searchFailResponse ( const caHdrLargeArray * mp )
this->out.copyInHeader ( CA_PROTO_NOT_FOUND, 0,
mp->m_dataType, mp->m_count, mp->m_cid, mp->m_available, 0 );
- this->out.commitMsg ();
+ this->out.commitMsg ();
- return S_cas_success;
+ return S_cas_success;
}
/*
@@ -360,7 +360,7 @@ caStatus casDGClient::searchFailResponse ( const caHdrLargeArray * mp )
*/
caStatus casDGClient::versionAction ()
{
- const caHdrLargeArray * mp = this->ctx.getMsg();
+ const caHdrLargeArray * mp = this->ctx.getMsg();
if ( mp->m_count != 0 ) {
this->minor_version_number = static_cast ( mp->m_count );
@@ -371,7 +371,7 @@ caStatus casDGClient::versionAction ()
this->seqNoOfReq = 0;
}
}
- return S_cas_success;
+ return S_cas_success;
}
//
@@ -380,25 +380,25 @@ caStatus casDGClient::versionAction ()
//
void casDGClient::sendBeacon ( ca_uint32_t beaconNumber )
{
- union {
- caHdr msg;
- char buf;
- };
+ union {
+ caHdr msg;
+ char buf;
+ };
- //
- // create the message
- //
- memset ( & buf, 0, sizeof ( msg ) );
+ //
+ // create the message
+ //
+ memset ( & buf, 0, sizeof ( msg ) );
AlignedWireRef < epicsUInt16 > ( msg.m_cmmd ) = CA_PROTO_RSRV_IS_UP;
AlignedWireRef < epicsUInt16 > ( msg.m_dataType ) = CA_MINOR_PROTOCOL_REVISION;
AlignedWireRef < epicsUInt32 > ( msg.m_cid ) = beaconNumber;
- //
- // send it to all addresses on the beacon list,
+ //
+ // send it to all addresses on the beacon list,
// but let the IO specific code set the address
// field and the port field
- //
- this->sendBeaconIO ( buf, sizeof (msg), msg.m_count, msg.m_available );
+ //
+ this->sendBeaconIO ( buf, sizeof (msg), msg.m_count, msg.m_available );
}
//
@@ -419,8 +419,8 @@ outBufClient::flushCondition casDGClient::xSend ( char *pBufIn,
if ( pHdr->cadg_addr.isValid() ) {
outBufClient::flushCondition stat =
- this->osdSend ( pDG, sizeDG, pHdr->cadg_addr );
- if ( stat != outBufClient::flushProgress ) {
+ this->osdSend ( pDG, sizeDG, pHdr->cadg_addr );
+ if ( stat != outBufClient::flushProgress ) {
break;
}
}
@@ -429,10 +429,10 @@ outBufClient::flushCondition casDGClient::xSend ( char *pBufIn,
}
if ( totalBytes ) {
- //
- // !! this time fetch may be slowing things down !!
- //
- //this->lastSendTS = epicsTime::getCurrent();
+ //
+ // !! this time fetch may be slowing things down !!
+ //
+ //this->lastSendTS = epicsTime::getCurrent();
nBytesSent = totalBytes;
return outBufClient::flushProgress;
}
@@ -455,16 +455,16 @@ inBufClient::fillCondition casDGClient::xRecv (char *pBufIn, bufSizeT nBytesToRe
while (pAfter-pCurBuf >= static_cast(MAX_UDP_RECV+sizeof(cadg))) {
pHdr = reinterpret_cast < cadg * > ( pCurBuf );
- stat = this->osdRecv ( reinterpret_cast < char * > ( pHdr + 1 ),
+ stat = this->osdRecv ( reinterpret_cast < char * > ( pHdr + 1 ),
MAX_UDP_RECV, parm, nDGBytesRecv, pHdr->cadg_addr);
- if (stat==casFillProgress) {
+ if (stat==casFillProgress) {
pHdr->cadg_nBytes = nDGBytesRecv + sizeof(*pHdr);
pCurBuf += pHdr->cadg_nBytes;
- //
- // !! this time fetch may be slowing things down !!
- //
- //this->lastRecvTS = epicsTime::getCurrent();
- }
+ //
+ // !! this time fetch may be slowing things down !!
+ //
+ //this->lastRecvTS = epicsTime::getCurrent();
+ }
else {
break;
}
@@ -515,7 +515,7 @@ caStatus casDGClient::asyncSearchResponse (
pMsg->m_dataType = htons ( sequenceNoIsValid );
}
- caStatus stat = this->searchResponse ( msg, retVal );
+ caStatus stat = this->searchResponse ( msg, retVal );
pRespHdr->cadg_nBytes = this->out.popCtx (outctx) + sizeof ( *pRespHdr );
if ( pRespHdr->cadg_nBytes > sizeof ( *pRespHdr ) + sizeof (caHdr) ) {
@@ -523,7 +523,7 @@ caStatus casDGClient::asyncSearchResponse (
this->out.commitRawMsg ( pRespHdr->cadg_nBytes );
}
- return stat;
+ return stat;
}
//
@@ -653,7 +653,7 @@ caStatus casDGClient::processDG ()
//
unsigned casDGClient::getDebugLevel() const
{
- return this->getCAS().getDebugLevel();
+ return this->getCAS().getDebugLevel();
}
//
@@ -661,7 +661,7 @@ unsigned casDGClient::getDebugLevel() const
//
caNetAddr casDGClient::fetchLastRecvAddr () const
{
- return this->lastRecvAddr;
+ return this->lastRecvAddr;
}
//
@@ -669,7 +669,7 @@ caNetAddr casDGClient::fetchLastRecvAddr () const
//
ca_uint32_t casDGClient::datagramSequenceNumber () const
{
- return this->seqNoOfReq;
+ return this->seqNoOfReq;
}
//
@@ -729,27 +729,27 @@ outBufClient::flushCondition casDGClient::flush ()
//
caStatus casDGClient::processMsg ()
{
- int status = S_cas_success;
+ int status = S_cas_success;
try {
- unsigned bytesLeft;
- while ( ( bytesLeft = this->in.bytesPresent() ) ) {
+ unsigned bytesLeft;
+ while ( ( bytesLeft = this->in.bytesPresent() ) ) {
caHdrLargeArray msgTmp;
unsigned msgSize;
ca_uint32_t hdrSize;
char * rawMP;
{
- //
- // copy as raw bytes in order to avoid
- // alignment problems
- //
+ //
+ // copy as raw bytes in order to avoid
+ // alignment problems
+ //
caHdr smallHdr;
if ( bytesLeft < sizeof ( smallHdr ) ) {
break;
}
rawMP = this->in.msgPtr ();
- memcpy ( & smallHdr, rawMP, sizeof ( smallHdr ) );
+ memcpy ( & smallHdr, rawMP, sizeof ( smallHdr ) );
ca_uint32_t payloadSize = AlignedWireRef < epicsUInt16 > ( smallHdr.m_postsize );
ca_uint32_t nElem = AlignedWireRef < epicsUInt16 > ( smallHdr.m_count );
@@ -798,45 +798,45 @@ caStatus casDGClient::processMsg ()
this->ctx.setMsg ( msgTmp, rawMP + hdrSize );
- if ( this->getCAS().getDebugLevel() > 5u ) {
+ if ( this->getCAS().getDebugLevel() > 5u ) {
char pHostName[64u];
this->lastRecvAddr.stringConvert ( pHostName, sizeof ( pHostName ) );
- caServerI::dumpMsg ( pHostName, "?",
+ caServerI::dumpMsg ( pHostName, "?",
& msgTmp, rawMP + hdrSize, 0 );
- }
+ }
}
- //
- // Reset the context to the default
- // (guarantees that previous message does not get mixed
- // up with the current message)
- //
- this->ctx.setChannel ( NULL );
- this->ctx.setPV ( NULL );
+ //
+ // Reset the context to the default
+ // (guarantees that previous message does not get mixed
+ // up with the current message)
+ //
+ this->ctx.setChannel ( NULL );
+ this->ctx.setPV ( NULL );
- //
- // Call protocol stub
- //
+ //
+ // Call protocol stub
+ //
casDGClient::pCASMsgHandler pHandler;
- if ( msgTmp.m_cmmd < NELEMENTS ( casDGClient::msgHandlers ) ) {
+ if ( msgTmp.m_cmmd < NELEMENTS ( casDGClient::msgHandlers ) ) {
pHandler = this->casDGClient::msgHandlers[msgTmp.m_cmmd];
- }
+ }
else {
pHandler = & casDGClient::uknownMessageAction;
}
- status = ( this->*pHandler ) ();
- if ( status ) {
+ status = ( this->*pHandler ) ();
+ if ( status ) {
this->in.removeMsg ( this->in.bytesPresent() );
- break;
- }
+ break;
+ }
this->in.removeMsg ( msgSize );
- }
+ }
}
catch ( std::exception & except ) {
this->in.removeMsg ( this->in.bytesPresent() );
- status = this->sendErr (
+ this->sendErr (
this->ctx.getMsg(), invalidResID, ECA_INTERNAL,
"C++ exception \"%s\" in CA circuit server",
except.what () );
@@ -844,13 +844,13 @@ caStatus casDGClient::processMsg ()
}
catch (...) {
this->in.removeMsg ( this->in.bytesPresent() );
- status = this->sendErr (
+ this->sendErr (
this->ctx.getMsg(), invalidResID, ECA_INTERNAL,
"unexpected C++ exception in CA datagram server" );
status = S_cas_internal;
}
- return status;
+ return status;
}
//
@@ -859,24 +859,25 @@ caStatus casDGClient::processMsg ()
caStatus casDGClient::sendErr ( const caHdrLargeArray *curp,
ca_uint32_t cid, const int reportedStatus, const char *pformat, ... )
{
- unsigned stringSize;
- char msgBuf[1024]; /* allocate plenty of space for the message string */
- if ( pformat ) {
- va_list args;
- va_start ( args, pformat );
- int status = vsprintf ( msgBuf, pformat, args );
- if ( status < 0 ) {
- errPrintf (S_cas_internal, __FILE__, __LINE__,
- "bad sendErr(%s)", pformat);
- stringSize = 0u;
- }
- else {
- stringSize = 1u + (unsigned) status;
- }
- }
- else {
- stringSize = 0u;
- }
+ unsigned stringSize;
+ char msgBuf[1024]; /* allocate plenty of space for the message string */
+ if ( pformat ) {
+ va_list args;
+ va_start ( args, pformat );
+ int status = vsprintf ( msgBuf, pformat, args );
+ if ( status < 0 ) {
+ errPrintf (S_cas_internal, __FILE__, __LINE__,
+ "bad sendErr(%s)", pformat);
+ stringSize = 0u;
+ }
+ else {
+ stringSize = 1u + (unsigned) status;
+ }
+ va_end ( args );
+ }
+ else {
+ stringSize = 0u;
+ }
unsigned hdrSize = sizeof ( caHdr );
if ( ( curp->m_postsize >= 0xffff || curp->m_count >= 0xffff ) &&
@@ -927,7 +928,7 @@ caStatus casDGClient::sendErr ( const caHdrLargeArray *curp,
this->out.commitMsg ();
}
- return S_cas_success;
+ return S_cas_success;
}
@@ -936,8 +937,8 @@ caStatus casDGClient::sendErr ( const caHdrLargeArray *curp,
//
caStatus casDGClient::echoAction ()
{
- const caHdrLargeArray * mp = this->ctx.getMsg();
- const void * dp = this->ctx.getData();
+ const caHdrLargeArray * mp = this->ctx.getMsg();
+ const void * dp = this->ctx.getData();
void * pPayloadOut;
epicsGuard < epicsMutex > guard ( this->mutex );
@@ -948,5 +949,5 @@ caStatus casDGClient::echoAction ()
memcpy ( pPayloadOut, dp, mp->m_postsize );
this->out.commitMsg ();
}
- return S_cas_success;
+ return S_cas_success;
}
diff --git a/src/ca/legacy/pcas/generic/casStrmClient.cc b/src/ca/legacy/pcas/generic/casStrmClient.cc
index e23256d3f..ff12e889e 100644
--- a/src/ca/legacy/pcas/generic/casStrmClient.cc
+++ b/src/ca/legacy/pcas/generic/casStrmClient.cc
@@ -409,7 +409,7 @@ caStatus casStrmClient::verifyRequest (casChannelI * & pChan , bool allowdyn)
//
// element count out of range ?
//
- if ( ctx.msg.m_count > pChan->getPVI().nativeCount() ||
+ if ( ctx.msg.m_count > pChan->getMaxElem() ||
( !allowdyn && ctx.msg.m_count == 0u ) ) {
return ECA_BADCOUNT;
}
@@ -895,7 +895,7 @@ caStatus casStrmClient::monitorResponse (
gdd * pDBRDD = 0;
if ( completionStatus == S_cas_success ) {
caStatus status = createDBRDD ( msg.m_dataType, count,
- chan.getPVI().nativeCount(), pDBRDD );
+ chan.getMaxElem(), pDBRDD );
if ( status != S_cas_success ) {
caStatus ecaStatus;
if ( status == S_cas_badType ) {
@@ -1866,7 +1866,7 @@ caStatus casStrmClient::privateCreateChanResponse (
// the protocol buffer.
//
assert ( nativeTypeDBR <= 0xffff );
- aitIndex nativeCount = chan.getPVI().nativeCount();
+ aitIndex nativeCount = chan.getMaxElem();
assert ( nativeCount <= 0xffffffff );
assert ( hdr.m_cid == chan.getCID() );
status = this->out.copyInHeader ( CA_PROTO_CREATE_CHAN, 0,
@@ -2626,7 +2626,7 @@ caStatus casStrmClient::read ()
{
gdd * pDD = 0;
caStatus status = createDBRDD ( pHdr->m_dataType, pHdr->m_count,
- this->ctx.getChannel()->getPVI().nativeCount(), pDD );
+ this->ctx.getChannel()->getMaxElem(), pDD );
if ( status != S_cas_success ) {
return status;
}
@@ -2773,6 +2773,7 @@ caStatus casStrmClient::sendErr ( epicsGuard &,
else {
stringSize = 1u + (unsigned) status;
}
+ va_end ( args );
}
else {
stringSize = 0u;
diff --git a/src/ioc/db/dbCaTest.c b/src/ioc/db/dbCaTest.c
index 40cf451ba..8e7851fa2 100644
--- a/src/ioc/db/dbCaTest.c
+++ b/src/ioc/db/dbCaTest.c
@@ -130,8 +130,8 @@ long dbcar(char *precordname, int level)
precord->name,
pdbFldDes->name,
plink->value.pv_link.pvname,
- pca->nDisconnect,
- pca->nNoWrite);
+ pca ? pca->nDisconnect : 0,
+ pca ? pca->nNoWrite : 0);
}
}
}
diff --git a/src/ioc/db/dbConvert.c b/src/ioc/db/dbConvert.c
index 8d3a54c82..0fad81d5a 100644
--- a/src/ioc/db/dbConvert.c
+++ b/src/ioc/db/dbConvert.c
@@ -3940,10 +3940,9 @@ static long putFloatString(
char *pdest = (char *) paddr->pfield;
long status = 0;
int precision = 6;
- struct rset *prset = 0;
+ struct rset *prset = dbGetRset(paddr);
short size = paddr->field_size;
- if (paddr) prset = dbGetRset(paddr);
if (prset && (prset->get_precision))
status = (*prset->get_precision)(paddr,&precision);
if (nRequest==1 && offset==0) {
@@ -4154,10 +4153,9 @@ static long putDoubleString(
char *pdest = (char *) paddr->pfield;
long status = 0;
int precision = 6;
- struct rset *prset = 0;
+ struct rset *prset = dbGetRset(paddr);
short size = paddr->field_size;
- if (paddr) prset = dbGetRset(paddr);
if (prset && (prset->get_precision))
status = (*prset->get_precision)(paddr,&precision);
if (nRequest==1 && offset==0) {
diff --git a/src/ioc/db/db_test.c b/src/ioc/db/db_test.c
index b011c6819..bc9ac32a8 100644
--- a/src/ioc/db/db_test.c
+++ b/src/ioc/db/db_test.c
@@ -172,6 +172,7 @@ int pft(const char *pname, const char *pvalue)
ca_dump_dbr(DBR_ENUM,1, buffer);
}
printf("\n");
+ dbChannelDelete(chan);
return (0);
}
@@ -231,6 +232,7 @@ int tpn(const char *pname, const char *pvalue)
ppn = calloc(1, sizeof(processNotify));
if (!ppn) {
printf("calloc failed\n");
+ dbChannelDelete(chan);
return -1;
}
ppn->requestType = putProcessRequest;
@@ -241,6 +243,7 @@ int tpn(const char *pname, const char *pvalue)
ptpnInfo = calloc(1, sizeof(tpnInfo));
if (!ptpnInfo) {
printf("calloc failed\n");
+ dbChannelDelete(chan);
return -1;
}
ptpnInfo->ppn = ppn;
diff --git a/src/ioc/rsrv/camessage.c b/src/ioc/rsrv/camessage.c
index b5c265ca6..057731777 100644
--- a/src/ioc/rsrv/camessage.c
+++ b/src/ioc/rsrv/camessage.c
@@ -663,7 +663,7 @@ static void read_reply ( void *pArg, struct dbChannel *dbch,
static int read_action ( caHdrLargeArray *mp, void *pPayloadIn, struct client *pClient )
{
struct channel_in_use *pciu = MPTOPCIU ( mp );
- const int readAccess = asCheckGet ( pciu->asClientPVT );
+ int readAccess;
ca_uint32_t payloadSize;
void *pPayload;
int status;
@@ -675,6 +675,7 @@ static int read_action ( caHdrLargeArray *mp, void *pPayloadIn, struct client *p
logBadId ( pClient, mp, 0 );
return RSRV_ERROR;
}
+ readAccess = asCheckGet ( pciu->asClientPVT );
SEND_LOCK ( pClient );
@@ -748,7 +749,7 @@ static int read_action ( caHdrLargeArray *mp, void *pPayloadIn, struct client *p
*/
if ( mp->m_dataType == DBR_STRING && mp->m_count == 1 ) {
char * pStr = (char *) pPayload;
- size_t strcnt = strlen ( pStr );
+ size_t strcnt = epicsStrnLen( pStr, payloadSize );
if ( strcnt < payloadSize ) {
payloadSize = ( ca_uint32_t ) ( strcnt + 1u );
}
@@ -883,7 +884,7 @@ static int write_action ( caHdrLargeArray *mp,
static int host_name_action ( caHdrLargeArray *mp, void *pPayload,
struct client *client )
{
- size_t size;
+ ca_uint32_t size;
char *pName;
char *pMalloc;
int chanCount;
@@ -907,9 +908,9 @@ static int host_name_action ( caHdrLargeArray *mp, void *pPayload,
}
pName = (char *) pPayload;
- size = strlen(pName)+1;
- if (size > 512) {
- log_header ( "bad (very long) host name",
+ size = epicsStrnLen(pName, mp->m_postsize)+1;
+ if (size > 512 || size > mp->m_postsize) {
+ log_header ( "bad (very long) host name",
client, mp, pPayload, 0 );
SEND_LOCK(client);
send_err(
@@ -962,7 +963,7 @@ static int host_name_action ( caHdrLargeArray *mp, void *pPayload,
static int client_name_action ( caHdrLargeArray *mp, void *pPayload,
struct client *client )
{
- size_t size;
+ ca_uint32_t size;
char *pName;
char *pMalloc;
int chanCount;
@@ -986,9 +987,9 @@ static int client_name_action ( caHdrLargeArray *mp, void *pPayload,
}
pName = (char *) pPayload;
- size = strlen(pName)+1;
- if (size > 512) {
- log_header ("a very long user name was specified",
+ size = epicsStrnLen(pName, mp->m_postsize)+1;
+ if (size > 512 || size > mp->m_postsize) {
+ log_header ("a very long user name was specified",
client, mp, pPayload, 0);
SEND_LOCK(client);
send_err(
diff --git a/src/libCom/RTEMS/rtems_init.c b/src/libCom/RTEMS/rtems_init.c
index dd136b755..2b909ab3b 100644
--- a/src/libCom/RTEMS/rtems_init.c
+++ b/src/libCom/RTEMS/rtems_init.c
@@ -489,7 +489,7 @@ exitHandler(void)
rtems_task
Init (rtems_task_argument ignored)
{
- int i;
+ int result;
char *argv[3] = { NULL, NULL, NULL };
char *cp;
rtems_task_priority newpri;
@@ -612,8 +612,8 @@ Init (rtems_task_argument ignored)
set_directory (argv[1]);
epicsEnvSet ("IOC_STARTUP_SCRIPT", argv[1]);
atexit(exitHandler);
- i = main ((sizeof argv / sizeof argv[0]) - 1, argv);
+ result = main ((sizeof argv / sizeof argv[0]) - 1, argv);
printf ("***** IOC application terminating *****\n");
epicsThreadSleep(1.0);
- epicsExit(0);
+ epicsExit(result);
}
diff --git a/src/libCom/log/iocLogServer.c b/src/libCom/log/iocLogServer.c
index f9deb06e5..f5694fc0f 100644
--- a/src/libCom/log/iocLogServer.c
+++ b/src/libCom/log/iocLogServer.c
@@ -84,131 +84,132 @@ static int sighupPipe[2];
/*
*
- * main()
+ * main()
*
*/
int main(void)
{
- struct sockaddr_in serverAddr; /* server's address */
- struct timeval timeout;
- int status;
- struct ioc_log_server *pserver;
+ struct sockaddr_in serverAddr; /* server's address */
+ struct timeval timeout;
+ int status;
+ struct ioc_log_server *pserver;
- osiSockIoctl_t optval;
+ osiSockIoctl_t optval;
- status = getConfig();
- if(status<0){
- fprintf(stderr, "iocLogServer: EPICS environment underspecified\n");
- fprintf(stderr, "iocLogServer: failed to initialize\n");
- return IOCLS_ERROR;
- }
+ status = getConfig();
+ if (status<0) {
+ fprintf(stderr, "iocLogServer: EPICS environment underspecified\n");
+ fprintf(stderr, "iocLogServer: failed to initialize\n");
+ return IOCLS_ERROR;
+ }
- pserver = (struct ioc_log_server *)
- calloc(1, sizeof *pserver);
- if(!pserver){
- fprintf(stderr, "iocLogServer: %s\n", strerror(errno));
- return IOCLS_ERROR;
- }
+ pserver = (struct ioc_log_server *)
+ calloc(1, sizeof *pserver);
+ if (!pserver) {
+ fprintf(stderr, "iocLogServer: %s\n", strerror(errno));
+ return IOCLS_ERROR;
+ }
- pserver->pfdctx = (void *) fdmgr_init();
- if(!pserver->pfdctx){
- fprintf(stderr, "iocLogServer: %s\n", strerror(errno));
- return IOCLS_ERROR;
- }
+ pserver->pfdctx = (void *) fdmgr_init();
+ if (!pserver->pfdctx) {
+ fprintf(stderr, "iocLogServer: %s\n", strerror(errno));
+ return IOCLS_ERROR;
+ }
- /*
- * Open the socket. Use ARPA Internet address format and stream
- * sockets. Format described in .
- */
- pserver->sock = epicsSocketCreate(AF_INET, SOCK_STREAM, 0);
- if (pserver->sock==INVALID_SOCKET) {
+ /*
+ * Open the socket. Use ARPA Internet address format and stream
+ * sockets. Format described in .
+ */
+ pserver->sock = epicsSocketCreate(AF_INET, SOCK_STREAM, 0);
+ if (pserver->sock == INVALID_SOCKET) {
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
- fprintf(stderr, "iocLogServer: sock create err: %s\n", sockErrBuf);
- return IOCLS_ERROR;
- }
-
+ fprintf(stderr, "iocLogServer: sock create err: %s\n", sockErrBuf);
+ free(pserver);
+ return IOCLS_ERROR;
+ }
+
epicsSocketEnableAddressReuseDuringTimeWaitState ( pserver->sock );
- /* Zero the sock_addr structure */
- memset((void *)&serverAddr, 0, sizeof serverAddr);
- serverAddr.sin_family = AF_INET;
- serverAddr.sin_port = htons(ioc_log_port);
+ /* Zero the sock_addr structure */
+ memset((void *)&serverAddr, 0, sizeof serverAddr);
+ serverAddr.sin_family = AF_INET;
+ serverAddr.sin_port = htons(ioc_log_port);
- /* get server's Internet address */
- status = bind ( pserver->sock,
- (struct sockaddr *)&serverAddr,
- sizeof (serverAddr) );
- if (status<0) {
+ /* get server's Internet address */
+ status = bind ( pserver->sock,
+ (struct sockaddr *)&serverAddr,
+ sizeof (serverAddr) );
+ if (status < 0) {
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
- fprintf(stderr, "iocLogServer: bind err: %s\n", sockErrBuf );
- fprintf (stderr,
- "iocLogServer: a server is already installed on port %u?\n",
- (unsigned)ioc_log_port);
- return IOCLS_ERROR;
- }
+ fprintf(stderr, "iocLogServer: bind err: %s\n", sockErrBuf );
+ fprintf (stderr,
+ "iocLogServer: a server is already installed on port %u?\n",
+ (unsigned)ioc_log_port);
+ return IOCLS_ERROR;
+ }
- /* listen and accept new connections */
- status = listen(pserver->sock, 10);
- if (status<0) {
+ /* listen and accept new connections */
+ status = listen(pserver->sock, 10);
+ if (status < 0) {
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
- fprintf(stderr, "iocLogServer: listen err %s\n", sockErrBuf);
- return IOCLS_ERROR;
- }
+ fprintf(stderr, "iocLogServer: listen err %s\n", sockErrBuf);
+ return IOCLS_ERROR;
+ }
- /*
- * Set non blocking IO
- * to prevent dead locks
- */
- optval = TRUE;
- status = socket_ioctl(
- pserver->sock,
- FIONBIO,
- &optval);
- if(status<0){
+ /*
+ * Set non blocking IO
+ * to prevent dead locks
+ */
+ optval = TRUE;
+ status = socket_ioctl(
+ pserver->sock,
+ FIONBIO,
+ &optval);
+ if (status < 0){
char sockErrBuf[64];
epicsSocketConvertErrnoToString ( sockErrBuf, sizeof ( sockErrBuf ) );
- fprintf(stderr, "iocLogServer: ioctl FIONBIO err %s\n", sockErrBuf);
- return IOCLS_ERROR;
- }
+ fprintf(stderr, "iocLogServer: ioctl FIONBIO err %s\n", sockErrBuf);
+ return IOCLS_ERROR;
+ }
-# ifdef UNIX
- status = setupSIGHUP(pserver);
- if (status<0) {
- return IOCLS_ERROR;
- }
-# endif
+# ifdef UNIX
+ status = setupSIGHUP(pserver);
+ if (status < 0) {
+ return IOCLS_ERROR;
+ }
+# endif
- status = openLogFile(pserver);
- if (status<0) {
- fprintf(stderr,
- "File access problems to `%s' because `%s'\n",
- ioc_log_file_name,
- strerror(errno));
- return IOCLS_ERROR;
- }
+ status = openLogFile(pserver);
+ if (status < 0) {
+ fprintf(stderr,
+ "File access problems to `%s' because `%s'\n",
+ ioc_log_file_name,
+ strerror(errno));
+ return IOCLS_ERROR;
+ }
- status = fdmgr_add_callback(
- pserver->pfdctx,
- pserver->sock,
- fdi_read,
- acceptNewClient,
- pserver);
- if(status<0){
- fprintf(stderr,
- "iocLogServer: failed to add read callback\n");
- return IOCLS_ERROR;
- }
+ status = fdmgr_add_callback(
+ pserver->pfdctx,
+ pserver->sock,
+ fdi_read,
+ acceptNewClient,
+ pserver);
+ if (status < 0) {
+ fprintf(stderr,
+ "iocLogServer: failed to add read callback\n");
+ return IOCLS_ERROR;
+ }
- while(TRUE){
- timeout.tv_sec = 60; /* 1 min */
- timeout.tv_usec = 0;
- fdmgr_pend_event(pserver->pfdctx, &timeout);
- fflush(pserver->poutfile);
- }
+ while (TRUE) {
+ timeout.tv_sec = 60; /* 1 min */
+ timeout.tv_usec = 0;
+ fdmgr_pend_event(pserver->pfdctx, &timeout);
+ fflush(pserver->poutfile);
+ }
}
/*
@@ -964,6 +965,7 @@ static int getDirectory(void)
"Problem reading o/p from `%s' because `%s'\n",
ioc_log_file_command,
strerror(errno));
+ (void) pclose(pipe);
return IOCLS_ERROR;
}
(void) pclose(pipe);
diff --git a/src/libCom/misc/epicsString.c b/src/libCom/misc/epicsString.c
index f3cf828f4..a8098336c 100644
--- a/src/libCom/misc/epicsString.c
+++ b/src/libCom/misc/epicsString.c
@@ -256,6 +256,18 @@ int epicsStrPrintEscaped(FILE *fp, const char *s, size_t len)
return nout;
}
+/* Until Base requires POSIX 2008 we must provide our own implementation */
+size_t epicsStrnLen(const char *s, size_t maxlen)
+{
+ size_t i;
+
+ for (i=0; inode)) {
- if (ptp->priority == ptp->priority &&
+ if (ptp->priority == priority &&
!strcmp(ptp->name, name))
break;
}
diff --git a/src/libCom/osi/os/RTEMS/osdMessageQueue.c b/src/libCom/osi/os/RTEMS/osdMessageQueue.c
index ff7728fb2..a566de6f6 100644
--- a/src/libCom/osi/os/RTEMS/osdMessageQueue.c
+++ b/src/libCom/osi/os/RTEMS/osdMessageQueue.c
@@ -171,7 +171,7 @@ static int receiveMessage(
return -1;
}
rsize = receiveMessage(id, id->localBuf, id->maxSize, wait, delay);
- if ((rsize < 0) || (rsize > size))
+ if (rsize > size)
return -1;
memcpy(buffer, id->localBuf, rsize);
}
diff --git a/src/libCom/osi/os/RTEMS/osdThread.c b/src/libCom/osi/os/RTEMS/osdThread.c
index 212372073..c19279ecf 100644
--- a/src/libCom/osi/os/RTEMS/osdThread.c
+++ b/src/libCom/osi/os/RTEMS/osdThread.c
@@ -412,8 +412,6 @@ void epicsThreadGetName (epicsThreadId id, char *name, size_t size)
struct taskVar *v;
int haveName = 0;
- if (size <= 0)
- return;
taskVarLock ();
for (v=taskVarHead ; v != NULL ; v=v->forw) {
if (v->id == tid) {
diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c
index b8590086a..8cdb4a3f4 100644
--- a/src/libCom/osi/os/WIN32/osdThread.c
+++ b/src/libCom/osi/os/WIN32/osdThread.c
@@ -523,13 +523,8 @@ static win32ThreadParam * epicsThreadParmCreate ( const char *pName )
pParmWIN32 = calloc ( 1, sizeof ( *pParmWIN32 ) + strlen ( pName ) + 1 );
if ( pParmWIN32 ) {
- if ( pName ) {
- pParmWIN32->pName = (char *) ( pParmWIN32 + 1 );
- strcpy ( pParmWIN32->pName, pName );
- }
- else {
- pParmWIN32->pName = 0;
- }
+ pParmWIN32->pName = (char *) ( pParmWIN32 + 1 );
+ strcpy ( pParmWIN32->pName, pName );
pParmWIN32->isSuspended = 0;
}
return pParmWIN32;
diff --git a/src/libCom/test/epicsStringTest.c b/src/libCom/test/epicsStringTest.c
index 9c50d3c82..3e4aed7e7 100644
--- a/src/libCom/test/epicsStringTest.c
+++ b/src/libCom/test/epicsStringTest.c
@@ -87,7 +87,7 @@ MAIN(epicsStringTest)
char *s;
int status;
- testPlan(402);
+ testPlan(406);
testChars();
@@ -122,6 +122,11 @@ MAIN(epicsStringTest)
testOk1(epicsStrHash(abcd, 0) == epicsMemHash(abcde, 4, 0));
testOk1(epicsStrHash(abcd, 0) != epicsMemHash("abcd\0", 5, 0));
+ testOk1(epicsStrnLen("abcd", 5)==4);
+ testOk1(epicsStrnLen("abcd", 4)==4);
+ testOk1(epicsStrnLen("abcd", 3)==3);
+ testOk1(epicsStrnLen("abcd", 0)==0);
+
testGlob();
memset(result, 'x', sizeof(result));
diff --git a/src/template/base/top/caClientApp/caMonitor.c b/src/template/base/top/caClientApp/caMonitor.c
index 059fefb5e..9554cc744 100644
--- a/src/template/base/top/caClientApp/caMonitor.c
+++ b/src/template/base/top/caClientApp/caMonitor.c
@@ -109,6 +109,7 @@ int main(int argc,char **argv)
pmynode[npv] = callocMustSucceed(1, sizeof(MYNODE), "caMonitor");
npv++;
}
+ fclose(fp);
SEVCHK(ca_context_create(ca_disable_preemptive_callback),"ca_context_create");
SEVCHK(ca_add_exception_event(exceptionCallback,NULL),
"ca_add_exception_event");