diff --git a/SICSmain.c b/SICSmain.c index 4d221526..3df779cc 100644 --- a/SICSmain.c +++ b/SICSmain.c @@ -91,9 +91,10 @@ int main(int argc, char *argv[]) printf("Unrecoverable error on server startup, exiting.........\n"); exit(1); } + /* if (daemonize == 1) daemon(1, 1); - +*/ RunServer(pServ); diff --git a/ascon.c b/ascon.c index 233478d1..1eb23b90 100644 --- a/ascon.c +++ b/ascon.c @@ -40,7 +40,7 @@ static int CreateSocketAdress(struct sockaddr_in *sockaddrPtr, /* Socket addres (char *) hostent->h_addr_list[0], (size_t) hostent->h_length); } else { addr.s_addr = inet_addr(host); - if (addr.s_addr == (unsigned long) -1) { + if (addr.s_addr == (unsigned int) -1) { return 0; /* error */ } } @@ -73,7 +73,7 @@ void AsconError(Ascon *a, char *msg, int errorno) char *state; char num[8]; - if (a->state < 0 || a->state >= AsconMaxState) { + if ( a->state >= AsconMaxState) { state = "bad state"; } else { state = stateText[a->state]; diff --git a/asyncqueue.c b/asyncqueue.c index fc075718..f42684e8 100644 --- a/asyncqueue.c +++ b/asyncqueue.c @@ -146,7 +146,7 @@ static int CreateSocketAdress(struct sockaddr_in *sockaddrPtr, /* Socket addres (char *) hostent->h_addr_list[0], (size_t) hostent->h_length); } else { addr.s_addr = inet_addr(host); - if (addr.s_addr == (unsigned long) -1) { + if (addr.s_addr == (unsigned int) -1) { return 0; /* error */ } } diff --git a/asynnet.c b/asynnet.c index 7b707e61..67f4d7c6 100644 --- a/asynnet.c +++ b/asynnet.c @@ -238,7 +238,7 @@ int ANETconnect(char *name, int iPort) } else { /* check for aaa.bbbb.ccc.dddd */ addr.s_addr = inet_addr(name); - if(addr.s_addr == (unsigned long) -1) { + if(addr.s_addr == (unsigned int) -1) { anetLog(ANETERROR, "Failed to locate host: %s", name); return ANETOPENFAIL; } diff --git a/chadapter.c b/chadapter.c index cb8557ec..6842b3b0 100644 --- a/chadapter.c +++ b/chadapter.c @@ -3,7 +3,7 @@ This is a drivable adapter for the ChopperController object (or also generic controller object). It allows to modify one of the variables supported by - the controller through the normal SICS drive command. For more information + the controller through the normal SICS drive command. For more information see file choco.w or choco.tex. @@ -174,8 +174,9 @@ static void KillAdapter(void *pData) if (self->pInt) free(self->pInt); - if (self->pParName) + if (self->pParName){ free(self->pParName); + } free(self); } @@ -302,7 +303,7 @@ int CHAdapterAction(SConnection * pCon, SicsInterp * pSics, void *pData, } /*========================================================================= - An environment driver based on top of a controller object. + An environment driver based on top of a controller object. -------------------------------------------------------------------------*/ static int AVEVSetValue(pEVDriver self, float fNew) { @@ -429,7 +430,7 @@ pEVDriver MakeControllerEnvironmentDriver(int argc, char *argv[]) pDummy pDum = NULL; pChoco pChop; - /* + /* Two arguments are needed: the name of the controller and the name of the parameter */ @@ -449,7 +450,7 @@ pEVDriver MakeControllerEnvironmentDriver(int argc, char *argv[]) } /* alright: I think we got a controller now, let us create our - act + act */ pNew = CreateEVDriver(argc, argv); if (!pNew) { diff --git a/confvirtualmot.c b/confvirtualmot.c index 8cd82c2f..4cb60028 100644 --- a/confvirtualmot.c +++ b/confvirtualmot.c @@ -709,7 +709,7 @@ int ConfigurableVirtualMotorAction(SConnection * pCon, SicsInterp * pSics, SCSendOK(pCon); return 1; } else { - snprintf(pBueffel, 5120, "ERROR: subcommand %s to %s unknown", + snprintf(pBueffel, sizeof(pBueffel), "ERROR: subcommand %s to %s unknown", argv[1], argv[0]); SCWrite(pCon, pBueffel, eError); return 0; diff --git a/devexec.c b/devexec.c index e1f3e7b5..8fd81cea 100644 --- a/devexec.c +++ b/devexec.c @@ -496,7 +496,7 @@ int StopExe(pExeList self, char *name) assert(self); /* if not active, nothing to do */ - if ((self->pOwner == NULL) ) { + if (self->pOwner == NULL ) { self->iRun = 0; return 1; } diff --git a/devexec.tex b/devexec.tex index fa2bd6ba..1fa46764 100644 --- a/devexec.tex +++ b/devexec.tex @@ -118,6 +118,8 @@ $\langle$devcheck {\footnotesize ?}$\rangle\equiv$ \mbox{}\verb@ int DevExecTask(void *pEL);@\\ \mbox{}\verb@ void DevExecSignal(void *pEL, int iSignal, void *pSigData);@\\ \mbox{}\verb@@\\ +\mbox{}\verb@ int GetDevExecInstStatus(pExeList self);@\\ +\mbox{}\verb@@\\ \mbox{}\verb@@$\Diamond$ \end{list} \vspace{-1ex} diff --git a/drive.c b/drive.c index ed12d626..563de10a 100644 --- a/drive.c +++ b/drive.c @@ -361,7 +361,7 @@ int DriveWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, ClearExecutor(GetExecutor()); return 0; } - SCWrite(pCon, "Driving finished sucessfully", eValue); + SCWrite(pCon, "Driving finished successfully", eValue); return 1; } @@ -398,7 +398,7 @@ int RunWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, return 0; } - /* interprete arguments as pairs name value and try to start */ + /* interpret arguments as pairs name value and try to start */ for (i = 1; i < argc; i += 2) { if (argv[i + 1] == NULL) { snprintf(pBueffel,511, "ERROR: no value found for driving %s", argv[i]); diff --git a/fourmess.c b/fourmess.c index d5090529..20bf2e73 100644 --- a/fourmess.c +++ b/fourmess.c @@ -393,7 +393,7 @@ static int FourMessStoreIntern(pSICSOBJ self, SConnection * pCon, double fHkl[3], double fPosition[4], char *extra) { pFourMess priv = self->pPrivate; - float fSum, fSigma, fTemp, fMF, fStep, fPreset; + float fSum, fSigma, fTemp, fStep = .0, fPreset =.0, fMF; int i, iLF, iRet, iNP, ii; long *lCounts = NULL; pEVControl pEva = NULL; diff --git a/frame.c b/frame.c index 09e06ea1..f30ed071 100644 --- a/frame.c +++ b/frame.c @@ -19,8 +19,8 @@ #include "HistMem.h" #include "HistMem.i" #include "HistDriv.i" -#include "sicspsi/hardsup/sinqhm.h" -#include "sicspsi/sinqhmdriv.i" +#include +#include #include "nxdict.h" #include "frame.h" diff --git a/histmem.c b/histmem.c index 4e92896c..8e106428 100644 --- a/histmem.c +++ b/histmem.c @@ -1129,7 +1129,7 @@ void HMListOption(pHistMem self, SConnection * pCon) static pDynString formatTOF(pHistMem self) { const float *timebin; - int iLength, i, delay, delta; + int iLength, i, delay, delta = .0; char number[20]; pDynString result = NULL; diff --git a/hmdata.c b/hmdata.c index 5584d910..68cf22b3 100644 --- a/hmdata.c +++ b/hmdata.c @@ -469,9 +469,6 @@ long sumHMDataRectangle(pHistMem hist, SConnection * pCon, return -1; break; } - if (lSum < 0) { - lSum = -lSum; - } return lSum; } diff --git a/initializer.c b/initializer.c index f64e53d8..05c1b240 100644 --- a/initializer.c +++ b/initializer.c @@ -162,7 +162,7 @@ static int RemoveObject(SConnection * con, SicsInterp * sics, p = strchr(className, ' '); if (p) { snprintf(shortClassName, sizeof shortClassName, "%.*s", - p - className, className); + (int)(p - className), className); cmdin = (CmdInitializer) GetInitializer("Object", shortClassName); } } diff --git a/integrate.c b/integrate.c index c9a8751d..5f29f7c0 100644 --- a/integrate.c +++ b/integrate.c @@ -211,7 +211,7 @@ static int FindLimit(pIntegData self, int iStart, int iSign) --------------------------------------------------------------------------*/ static int DoIntegrate(pIntegData self, float *fSum, float *fVariance) { - long lLeftBack, lRightBack, lBackMean; + long lLeftBack = 0, lRightBack, lBackMean; int i, iRes = 1; float fScan, fBackVar, fLeft, fRight, fN, fNP, fNB, fSumm; float fMLeft, fMRight; @@ -224,13 +224,11 @@ static int DoIntegrate(pIntegData self, float *fSum, float *fVariance) for (i = 0, lLeftBack = 0; i < self->iLeft; i++) { lLeftBack += self->lCounts[i]; } - lLeftBack = lLeftBack; /* sum the right background */ for (i = self->iRight, lRightBack = 0; i < self->iCounts; i++) { lRightBack += self->lCounts[i]; } - lRightBack = lRightBack; /* sum all of it */ diff --git a/linux_def b/linux_def index e312d828..fe008112 100644 --- a/linux_def +++ b/linux_def @@ -10,4 +10,5 @@ MFLAGS=-f makefile_linux$(DUMMY) HDFROOT=/usr/local -TCLINC=/usr/include/tcl \ No newline at end of file +TCLINC=/usr/include/tcl +EPICS=/usr/local/epics \ No newline at end of file diff --git a/macosx_def b/macosx_def index 0085c42a..60789d3c 100644 --- a/macosx_def +++ b/macosx_def @@ -8,6 +8,9 @@ #FORTIFYOBJ= fortify.o strdup.o #DFORTIFY= -pg -MFLAGS=-f makefile_linux$(DUMMY) +MFLAGS=-f makefile_macosx + +HDFROOT=/usr/pkg +EPICS=/usr/local/epics +EPICSLIBS=-L$(EPICS)/lib/darwin-x86 -lca -lCom -HDFROOT=/Users/Shared diff --git a/make_gen b/make_gen index 7018008d..f44212af 100644 --- a/make_gen +++ b/make_gen @@ -5,8 +5,8 @@ # Markus Zolliker March 2003 #--------------------------------------------------------------------------- -EPICSOBJ=epicsmotor.o -#EPICSOBJ= +#EPICSOBJ=epicsmotor.o +EPICSOBJ= COBJ = Sclient.o network.o ifile.o intcli.o $(FORTIFYOBJ) SOBJ = network.o ifile.o conman.o SCinter.o splitter.o passwd.o \ @@ -70,7 +70,7 @@ all: libmat libhlib libpsi SICServer full: purge all SICServer: $(OBJ) $(SUBLIBS) - g++ $(DBG) -o SICServer $(OBJ) $(LIBS) + $(CC) $(DBG) -o SICServer $(OBJ) $(LIBS) matrix/libmatrix.a: libmat diff --git a/makefile_linux b/makefile_linux index f8ee79c5..92978e55 100644 --- a/makefile_linux +++ b/makefile_linux @@ -14,7 +14,7 @@ NI= #NIOBJ= nigpib.o #NILIB=$(SINQDIR)/lib/cib.o -include linux_def +include $(SICSROOT)/sics/linux_def CC = gcc CFLAGS = -I$(HDFROOT)/include -I/usr/include/hdf -I$(TCLINC) -DHDF4 -DHDF5 \ diff --git a/makefile_macosx b/makefile_macosx index 6e81a4bf..e2d81ad4 100644 --- a/makefile_macosx +++ b/makefile_macosx @@ -5,6 +5,7 @@ # Mark Koennecke 1996-2001 # Markus Zolliker, March 2003 # Mark Koennecke, July 2008 +# Mark Koennecke, March 2014 for Maverick #========================================================================== # assign if the National Instrument GPIB driver is available SINQDIR=/Users/Shared @@ -12,22 +13,21 @@ SINQDIR=/Users/Shared #NIOBJ= nigpib.o #NILIB=$(SINQDIR)/sl5/lib/cib.o +SICSROOT=/Users/konnecke/src include macosx_def -CC = gcc -CFLAGS = -I$(HDFROOT)/include -I/sw/include -DNXXML -DHDF5 -DHDF4 $(NI) -DMACOSX \ - -Ipsi/hardsup -I. \ +CC = clang +CFLAGS = -I$(HDFROOT)/include -I/usr/local/include -DNXXML -DHDF5 $(NI) -DMACOSX \ + -I$(SICSROOT)/psi/hardsup -I$(SICSROOT)/sicspsi -I. -I/usr/pkg/include \ -Werror -DNONINTF -g $(DFORTIFY) \ -Wall -Wno-unused -Wno-comment -Wno-switch BINTARGET = bin EXTRA=nintf.o -SUBLIBS = psi/libpsi.a psi/hardsup/libhlib.a matrix/libmatrix.a -LIBS = -L$(HDFROOT)/lib -L/sw/lib $(SUBLIBS) $(NILIB)\ - -ltcl $(HDFROOT)/lib/libhdf5.a -lmfhdf -ldf \ - $(HDFROOT)/lib/libsz.a \ - $(HDFROOT)/lib/libjson.a -ljpeg \ - -ldl -lz -lmxml $(HDFROOT)/lib/libghttp.a -lm -lc +SUBLIBS = $(SICSROOT)/sicspsi/libpsi.a $(SICSROOT)/sicspsi/hardsup/libhlib.a matrix/libmatrix.a \ + $(SICSROOT)/sicspsi/tecs/libtecsl.a +LIBS = -L$(HDFROOT)/lib -L/usr/local/lib $(SUBLIBS) $(NILIB) -L$(EPICS)/lib/darwin-x86 \ + -ltcl -lhdf5 -lNeXus -ljson -lghttp $(EPICSLIBS) -ldl -lz -lmxml -lm -lc include make_gen diff --git a/makefile_slinux b/makefile_slinux index 6be471f6..995207fe 100644 --- a/makefile_slinux +++ b/makefile_slinux @@ -13,15 +13,15 @@ NIOBJ= nigpib.o NILIB=$(SINQDIR)/sl6/lib/cib.o EPICSDIR=$(SINQDIR)/sl6/lib/linux-x86 -EPICSLIBS=$(EPICSDIR)/libezca.a $(EPICSDIR)/libca.a $(EPICSDIR)/libCom.a -lreadline -lhistory -#EPICSLIBS=-L$(EPICSDIR) -lezca -lca -lCom +#EPICSLIBS=$(EPICSDIR)/libezca.a $(EPICSDIR)/libca.a $(EPICSDIR)/libCom.a -lreadline -lhistory +EPICSLIBS=-L$(EPICSDIR) -lezca -lca -lCom include sllinux_def CC = gcc CFLAGS = -I$(HDFROOT)/include -DNXXML -DHDF5 $(NI) \ - -I$(SICSROOT)/sicspsi/hardsup -I$(SICSROOT) -I. -MMD \ + -I$(SICSROOT)/sicspsi -I$(SICSROOT) -I. -MMD \ -Werror -DCYGNUS -DNONINTF $(DBG) $(DFORTIFY) \ -Wall -Wno-unused -Wunused-value -Wno-comment -Wno-switch diff --git a/matrix/Makefile b/matrix/Makefile deleted file mode 100644 index 2902297e..00000000 --- a/matrix/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -#--------------------------------------------------------------------------- -# Makefile for the Matrix library -# -# Mark Koennecke, November 1996 -#-------------------------------------------------------------------------- -OBJ= matadd.o matcreat.o matdet.o matdump.o matdurbn.o materr.o \ - matinv.o matmul.o matsolve.o matsub.o matsubx.o mattoepz.o \ - mattran.o - -#---------- for Redhat linux -#CC= gcc -#CFLAGS= -I/usr/local/include -I. -I../ -DLINUX -g -c - -#------------ for DigitalUnix -CC=cc -CFLAGS= -I/data/koenneck/include -I. -I../ -std1 -g -c -#------------ for DigitalUnix with Fortify -#CFLAGS= -I/data/koenneck/include -DFORTIFY -I. -I../ -std1 -g -c - -#------------ for CYGNUS toolchain on Win32 -#CC=gcc -#CFLAGS= -I. -I../ -DCYGNUS -g -c - -.c.o: - $(CC) $(CFLAGS) $*.c - -matrix: $(OBJ) - - rm -f libmatrix.a - ar cr libmatrix.a $(OBJ) - ranlib libmatrix.a - -clean: - rm -f *.o - rm -f *.a diff --git a/matrix/makefile b/matrix/makefile index 03dfa3af..2902297e 100644 --- a/matrix/makefile +++ b/matrix/makefile @@ -1,21 +1,34 @@ -# M. Zolliker 03.2005 +#--------------------------------------------------------------------------- +# Makefile for the Matrix library +# +# Mark Koennecke, November 1996 +#-------------------------------------------------------------------------- +OBJ= matadd.o matcreat.o matdet.o matdump.o matdurbn.o materr.o \ + matinv.o matmul.o matsolve.o matsub.o matsubx.o mattoepz.o \ + mattran.o -%: usage - @echo +#---------- for Redhat linux +#CC= gcc +#CFLAGS= -I/usr/local/include -I. -I../ -DLINUX -g -c -%.o: usage - @echo +#------------ for DigitalUnix +CC=cc +CFLAGS= -I/data/koenneck/include -I. -I../ -std1 -g -c +#------------ for DigitalUnix with Fortify +#CFLAGS= -I/data/koenneck/include -DFORTIFY -I. -I../ -std1 -g -c -default: usage +#------------ for CYGNUS toolchain on Win32 +#CC=gcc +#CFLAGS= -I. -I../ -DCYGNUS -g -c -usage: - @ echo "" - @ echo "Usage:" - @ echo "" - @ echo " make -f makefile_xxx [target]" - @ echo "" - @ echo ' where makefile_xxx is one of' - @ echo "" - @ ls -1 makefile_* | pr -t -o 4 +.c.o: + $(CC) $(CFLAGS) $*.c +matrix: $(OBJ) + - rm -f libmatrix.a + ar cr libmatrix.a $(OBJ) + ranlib libmatrix.a +clean: + rm -f *.o + rm -f *.a diff --git a/matrix/makefile_macosx b/matrix/makefile_macosx new file mode 100644 index 00000000..4faeb12a --- /dev/null +++ b/matrix/makefile_macosx @@ -0,0 +1,16 @@ +#--------------------------------------------------------------------------- +# Makefile for the Matrix library +# +# Mark Koennecke, November 1996 +# Markus Zolliker, March 2003 +#-------------------------------------------------------------------------- + +include ../linux_def + +CC = clang +CFLAGS = -g $(DFORTIFY) -MMD + +include make_gen + +-include $(OBJ:.o=.d) + diff --git a/motor.c b/motor.c index c5e13ec2..458614f0 100644 --- a/motor.c +++ b/motor.c @@ -1076,22 +1076,6 @@ int MotorCreate(SConnection * pCon, SicsInterp * pSics, void *pData, SCWrite(pCon, pBueffel, eLogError); return 0; } - } else if (strcmp(argv[2], "epics") == 0) { - if(argc > 3){ - pDriver = epicsMakeMotorDriver(argv[3]); - if (!pDriver) { - return 0; - } - pNew = MotorInit("epics", argv[1], pDriver); - if (!pNew) { - snprintf(pBueffel,sizeof(pBueffel)-1, "Failure to create motor %s", argv[1]); - SCWrite(pCon, pBueffel, eLogError); - return 0; - } - } else { - SCWrite(pCon,"ERROR: missing basename argument to create EPICS motor",eError); - return 0; - } } else { site = getSite(); if (site != NULL) { diff --git a/multicounter.c b/multicounter.c index 63fb285d..2e190df9 100644 --- a/multicounter.c +++ b/multicounter.c @@ -123,7 +123,7 @@ static int MMCCStart(void *pData, SConnection * pCon) static int MMCCStatus(void *pData, SConnection * pCon) { - int status, i; + int status = HWIdle, i; pCounter pCount = NULL, pMaster = NULL;; pMultiCounter self = NULL; pDummy pDum = NULL; diff --git a/mumo.c b/mumo.c index 96b2d9cc..c3ab138e 100644 --- a/mumo.c +++ b/mumo.c @@ -396,7 +396,7 @@ static int ParseAlias(psParser pParse, SConnection * pCon, pMulMot self) return 1; break; default: - snprintf(pBueffel,1024, "ERROR: Unexpected symbol %s", pParse->Token); + snprintf(pBueffel,sizeof(pBueffel), "ERROR: Unexpected symbol %s", pParse->Token); SCWrite(pCon, pBueffel, eError); return 0; } diff --git a/network.c b/network.c index ea8c0f94..944ecacf 100644 --- a/network.c +++ b/network.c @@ -98,7 +98,7 @@ static int CreateSocketAdress(struct sockaddr_in *sockaddrPtr, /* Socket addres (char *) hostent->h_addr_list[0], (size_t) hostent->h_length); } else { addr.s_addr = inet_addr(host); - if (addr.s_addr == (unsigned long) -1) { + if (addr.s_addr == (unsigned int) -1) { return 0; /* error */ } } diff --git a/nread.c b/nread.c index 97f74e3d..476ab22f 100644 --- a/nread.c +++ b/nread.c @@ -1355,7 +1355,7 @@ static int TelnetAcceptCB(int handle, void *userData) /*------------------------------------------------------------------------------------*/ static void NREADlog(int level, char *txt, void *userData) { - traceSys("anet",txt); + traceSys("anet","%s",txt); SICSLogWrite(txt, (level == ANETERROR) ? eLogError : eLog); } diff --git a/nxinter_wrap.c b/nxinter_wrap.c index a2aaf7d7..3e76b0d0 100644 --- a/nxinter_wrap.c +++ b/nxinter_wrap.c @@ -3829,7 +3829,6 @@ SWIGRUNTIME void SWIG_InitializeModule(void *clientdata) swig_module_info *module_head, *iter; int found; - clientdata = clientdata; /* check to see if the circular list has been setup, if not, set it up */ if (swig_module.next == 0) { diff --git a/protocol.c b/protocol.c index 800698e9..cf62e8e2 100644 --- a/protocol.c +++ b/protocol.c @@ -149,13 +149,12 @@ void DeleteProtocol(void *self) if (pOld->version) { free(pOld->version); } - if (pOld->pProList) { - i = 0; - while (NULL != pOld->pProList[i]) { + i = 0; + while (NULL != pOld->pProList[i]) { free(pOld->pProList[i]); i++; - } } + free(pOld); } diff --git a/remob.c b/remob.c index 9c97e712..55a3ae01 100644 --- a/remob.c +++ b/remob.c @@ -1019,7 +1019,7 @@ int RemobCreate(SConnection * pCon, SicsInterp * pSics, void *pData, SCPrintf(pCon, eError, "ERROR: illegal host:port"); return 0; } - snprintf(host, sizeof host, "%.*s", p - argv[3], argv[3]); + snprintf(host, sizeof host, "%.*s", (int)(p - argv[3]), argv[3]); remserver = RemServerInit(argv[2], host, atoi(p + 1)); } if (!remserver) { diff --git a/sansbc.c b/sansbc.c index 2d0d0f83..05b710ea 100644 --- a/sansbc.c +++ b/sansbc.c @@ -188,7 +188,7 @@ static int StatCmd(pSICSOBJ self, SConnection *pCon, pHdb commandNode, return 0; } max = -9999; - min = 99999.99; + min = 99999; length = dim[0]*dim[1]; for(i = 0, sum = 0; i < length; i++){ sum += data[i]; diff --git a/scan.c b/scan.c index 97ca1140..4e989264 100644 --- a/scan.c +++ b/scan.c @@ -152,6 +152,8 @@ pScanData CreateScanObject(char *pRecover, char *pHeader, pCounter pCount, /* assign various things */ if (pRecover) { strlcpy(pNew->pRecover, pRecover,1024); + } else { + memset(pNew->pRecover,0,sizeof(pNew->pRecover)); } if (pHeader) { strlcpy(pNew->pHeaderFile, pHeader,1024); @@ -597,7 +599,7 @@ static int ScanLoop(pScanData self) InvokeCallBack(self->pCall, SCANPOINT, self); self->WriteScanPoints(self, i); - if (self->pRecover) { + if (strlen(self->pRecover) > 10) { WriteRecover(self); } } @@ -1281,7 +1283,7 @@ static int ScanDynInterest(int iEvent, void *pEventData, void *pUser) if (pCount != NULL) { lVal = pCount->lCount; } else { - lVal = -9999.99; + lVal = -9999; } snprintf(pBueffel, 255, "%s.scanpoint = {%d %f %ld}", self->objectName, i, fVal, lVal); @@ -1628,7 +1630,7 @@ int ScanWrapper(SConnection * pCon, SicsInterp * pSics, void *pData, float *fData = NULL; int lNP; int iChannel; - int iRet, iMode, i; + int iRet = 0, iMode, i; char *pPtr = NULL, pItem[20]; long *lData = NULL, lID; int *iData; diff --git a/scriptcontext.c b/scriptcontext.c index e32fe750..f6deac5b 100644 --- a/scriptcontext.c +++ b/scriptcontext.c @@ -146,7 +146,7 @@ static void SetProp(Hdb * node, Hdb * cNode, char *key, char *value) { Hdb *propNode; char *val; - + val = GetPropAndNode(node, cNode, key, &propNode); if (value == NULL) { if (val != NULL) { @@ -176,7 +176,7 @@ int SctCommand(SConnection * con, SicsInterp * sics, void *object, Hdb *cNode = NULL; hdbValue v; SctController *controller; - + assert(sct == object); if (sct->nodes != NULL) { node = sct->nodes->node; @@ -187,7 +187,7 @@ int SctCommand(SConnection * con, SicsInterp * sics, void *object, argv[0]); return 0; } - + /* * get path (pure sct command) */ @@ -339,7 +339,7 @@ int SctCallInContext(SConnection * con, char *script, Hdb * node, char *result = NULL; int iRet = 1; int verbose = controller->verbose; - + PushContext(node, controller); if (verbose) { SCPrintf(con, eLog, "%6.3f script: %s", secondsOfMinute(), script); @@ -417,7 +417,7 @@ static char *SctActionHandler(void *actionData, char *lastReply, int ret; char timeKey[50], timeVal[50]; int iMacro; - + assert(data->name); if (queueData != NULL && queueData->conCtx != NULL) { con = queueData->conCtx; @@ -427,9 +427,9 @@ static char *SctActionHandler(void *actionData, char *lastReply, data->busy = 1; /* - * Check if this is a followup call. - * If this is a followup call, the I/O system will have set the - * property result to the data from the device. Read this now and + * Check if this is a followup call. + * If this is a followup call, the I/O system will have set the + * property result to the data from the device. Read this now and * print it if diagnostics is required. */ script = NULL; @@ -451,11 +451,11 @@ static char *SctActionHandler(void *actionData, char *lastReply, } /* - * Make sure that the state property is set to the name of the property - * which holds the name of the script to run at this stage. - * When this is a followup, we use the content of the - * state field as the property storing the next script to - * run. If this is the start of a chain this is set to the + * Make sure that the state property is set to the name of the property + * which holds the name of the script to run at this stage. + * When this is a followup, we use the content of the + * state field as the property storing the next script to + * run. If this is the start of a chain this is set to the * data->name which is mostly either read or write */ state = GetProp(node, controller->node, "state"); @@ -463,16 +463,16 @@ static char *SctActionHandler(void *actionData, char *lastReply, state = data->name; SetProp(node, controller->node, "state", state); } - + /* - * Sometimes one wishes to call multiple scripts in succession - * before returning into I/O. Such scripts then do not set the - * send property. The loop is taking care of this. Not more + * Sometimes one wishes to call multiple scripts in succession + * before returning into I/O. Such scripts then do not set the + * send property. The loop is taking care of this. Not more * then 10 scripts can be chained in this way. */ for (i = 0; i < 10; i++) { /* - * read the script to invoke from the property living + * read the script to invoke from the property living * in state */ script = GetProp(node, controller->node, state); @@ -552,8 +552,8 @@ static char *SctActionHandler(void *actionData, char *lastReply, l = blank - origScript; } else { l = strlen(origScript); - } - snprintf(eprop, sizeof eprop, "error_in_%s", origScript); + } + snprintf(eprop, sizeof eprop, "error_in_%.*s", (int)l, origScript); emsg = GetHdbProp(node, eprop); cnt = 0; if (emsg != NULL) { @@ -582,12 +582,12 @@ static char *SctActionHandler(void *actionData, char *lastReply, goto finish; } /* - * The script executed OK. + * The script executed OK. * The next state is the result */ state = result; /* - * if the new state is idle, clean everything up + * if the new state is idle, clean everything up * and terminate the script chain */ if (strcasecmp(state, "idle") == 0 || strcasecmp(state, "unpoll") == 0) { @@ -595,7 +595,7 @@ static char *SctActionHandler(void *actionData, char *lastReply, SetHdbProperty(node, "requested", NULL); if (!data->answered) { if (queueData->inMacro == 0) { - /* + /* * send an O.k. if there was no other reply on write's */ iMacro = SCinMacro(con); @@ -629,8 +629,8 @@ static char *SctActionHandler(void *actionData, char *lastReply, free(script); script = NULL; /* - * If there is data to send, check it and do so. This also exits the - * quick script loop by returning the data to send to Devser. + * If there is data to send, check it and do so. This also exits the + * quick script loop by returning the data to send to Devser. */ if (sct->sendCalled) { send = GetProp(node, controller->node, "send"); @@ -653,8 +653,8 @@ static char *SctActionHandler(void *actionData, char *lastReply, SCPrintf(con, eLogError, "ERROR: too many quick scripts chained"); finish: /* - * This section is always called when the script chain ends: either due to - * error or by successfull termination. + * This section is always called when the script chain ends: either due to + * error or by successfull termination. */ if (strcmp(data->name, "write") == 0) { if (GetHdbProp(node, "writestatus") != NULL) { @@ -712,7 +712,7 @@ static void SctEndData(void *d) { /* no kill, only decrement sync counter */ SctData *data = d; - + if (data->syncid > 0) { SyncedDecr(data->syncid); data->syncid = SYNCED_NO_ID; @@ -720,7 +720,7 @@ static void SctEndData(void *d) } /* - * This is the callback for all nodes participating in the + * This is the callback for all nodes participating in the * scriptcontext system */ static hdbCallbackReturn SctMainCallback(Hdb * node, void *userData, @@ -767,7 +767,7 @@ static hdbCallbackReturn SctMainCallback(Hdb * node, void *userData, con = mm->callData; geterror = GetHdbProp(node, "geterror"); if (geterror != NULL) { - snprintf(error,255,"ERROR: %s", geterror); + snprintf(error,255,"ERROR: %s", geterror); SCWrite(con, error, eError); if (mm->v->dataType == HIPTEXT) { if (mm->v->v.text != NULL) { @@ -783,9 +783,9 @@ static hdbCallbackReturn SctMainCallback(Hdb * node, void *userData, return hdbContinue; } /* - * This is the callback registered for nodes which + * This is the callback registered for nodes which * are written too. - */ + */ static hdbCallbackReturn SctActionCallback(Hdb * node, void *userData, hdbMessage * msg) { @@ -805,7 +805,7 @@ static hdbCallbackReturn SctActionCallback(Hdb * node, void *userData, char path[MAX_HDB_PATH]; char *sicsCommand; int iMacro; - + pm = GetKillPtrMessage(msg); if (pm != NULL) { if (data->controller == pm->pPtr) { @@ -859,7 +859,7 @@ static hdbCallbackReturn SctActionCallback(Hdb * node, void *userData, prio = WritePRIO; } - /* + /* * check for duplicate sets on a node. */ if (data->conCtx != NULL) { @@ -871,7 +871,7 @@ static hdbCallbackReturn SctActionCallback(Hdb * node, void *userData, GetCharArray(text)); } /* - * the node has already been queued for execution. But as we never + * the node has already been queued for execution. But as we never * know if the script chain is already running, the only clean * solution is to requeue the node. */ @@ -958,7 +958,7 @@ static void SctKillData(void *d) SyncedDecr(data->syncid); data->syncid = SYNCED_NO_ID; } - + if (data->name) { free(data->name); data->name = NULL; @@ -1198,7 +1198,7 @@ void SctQueueNode(SctController * controller, Hdb * node, data->name = strdup(action); data->conCtx = NULL; data->answered = 1; - + data->syncid = SyncedIncr(0); data->busy = 1; if (DevQueue(data->controller->devser, data, prio, @@ -1258,7 +1258,7 @@ static void SctKillUpdatescript(void *d) } /* - * This is the callback for update scripts + * This is the callback for update scripts */ static hdbCallbackReturn SctUpdatescriptCallback(Hdb * node, void *userData, @@ -1274,7 +1274,7 @@ static hdbCallbackReturn SctUpdatescriptCallback(Hdb * node, char path[MAX_HDB_PATH]; pDynString text; char *arg; - + pm = GetKillPtrMessage(msg); if (pm != NULL) { if (us->controller == pm->pPtr) { @@ -1304,7 +1304,7 @@ static hdbCallbackReturn SctUpdatescriptCallback(Hdb * node, script = GetProp(node, us->controller->node, us->name); if (script == NULL) script = us->name; - + text = formatValue(*(mm->v), node); arg = GetCharArray(text); arg = Arg2Tcl(1, &arg, NULL, 0); @@ -1536,7 +1536,7 @@ static int SctTransactCmd(pSICSOBJ ccmd, SConnection * con, st->controller = c; st->sent = 0; st->reply = NULL; - + DevQueue(c->devser, st, WritePRIO, TransactionHandler, SctTransactMatch, NULL, SctTransactInfo); while (st->sent != 2) { @@ -1616,7 +1616,7 @@ static int SctProcessCmd(pSICSOBJ ccmd, SConnection * con, data->conCtx = SCCopyConnection(con); data->busy = 1; data->inMacro = SCinMacro(con); - + startTime = time(NULL); DevQueue(c->devser, data, WritePRIO, SctWriteHandler, SctTransactMatch, NULL, SctDataInfo); @@ -1728,7 +1728,7 @@ static int SctTimeout(pSICSOBJ ccmd, SConnection * con, SctController *c; char *result; hdbValue *v = &cmdNode->child->value; - + c = (SctController *) ccmd->pPrivate; v->v.doubleValue = DevGetSetTimeout(c->devser, v->v.doubleValue, nPar); SCPrintf(con, eValue, "%.6g", v->v.doubleValue); @@ -1742,7 +1742,7 @@ static int SctReconnectInterval(pSICSOBJ ccmd, SConnection * con, char *result; hdbValue *v = &cmdNode->child->value; int interval; - + c = (SctController *) ccmd->pPrivate; if (nPar == 0) { interval = -1; /* read only */ @@ -1906,11 +1906,11 @@ static int SctMakeController(SConnection * con, SicsInterp * sics, controller->devser = DevMake(con, argc - 2, argv + 2); if (!controller->devser) return 0; - + SetHdbProperty(controller->node, "controllerName", objName); SetHdbProperty(controller->node, "sicsdev", objName); - + AddCommand(pServ->pSics, objName, InterInvokeSICSOBJ, KillSICSOBJ, ccmd); RegisterSICSOBJKillCmd(ccmd, objName); SetDescriptorKey(ccmd->pDes, "creationCommand", "0"); diff --git a/sctcomtask.c b/sctcomtask.c index 4a067b86..74deec1c 100644 --- a/sctcomtask.c +++ b/sctcomtask.c @@ -27,7 +27,7 @@ #include "sicsutil.h" #include "sicshipadaba.h" -static unsigned int mamaID = 0L; +static int mamaID = 0L; extern char *ParText(Hdb * cmdNode, char *name, int nPar, char *defaultValue); diff --git a/selector.c b/selector.c index 16a8c76b..ff74ef35 100644 --- a/selector.c +++ b/selector.c @@ -376,7 +376,7 @@ int MonoAction(SConnection * pCon, SicsInterp * pSics, void *pData, pSicsSelector pSelf = NULL; TokenList *pList = NULL; TokenList *pCurrent; - int iRet; + int iRet = 0; char pBueffel[132]; char pName[132]; float fVal; diff --git a/sicsget.c b/sicsget.c index b1dcd638..f4feb803 100644 --- a/sicsget.c +++ b/sicsget.c @@ -90,7 +90,7 @@ static int SICSGetCommand(SConnection * pCon, SicsInterp * pSics, void *pData, } } else { if(v.dataType == HIPTEXT && strstr(v.v.text,"ERROR") != NULL){ - SCPrintf(pCon,eError,v.v.text); + SCPrintf(pCon,eError,"%s",v.v.text); } else { SCPrintf(pCon,eError,"ERROR: value for %s not found", argv[1]); } diff --git a/sicshdbfactory.c b/sicshdbfactory.c index ef6356cc..e6db0511 100644 --- a/sicshdbfactory.c +++ b/sicshdbfactory.c @@ -108,7 +108,7 @@ static int MakePlainNode(pHdb parent, char *name, SConnection * pCon, static int MakeScriptNode(pHdb parent, char *name, SConnection * pCon, int argc, char *argv[]) { - int type, length; + int type, length = 0; pHdb child = NULL; hdbValue v; diff --git a/sicshipadaba.c b/sicshipadaba.c index 81c2d024..b10a9a92 100644 --- a/sicshipadaba.c +++ b/sicshipadaba.c @@ -2603,7 +2603,7 @@ static int ZipGetHdbNode(SConnection * pCon, SicsInterp * pSics, { pHdb targetNode = NULL; char error[512], oriPath[512]; - int status; + int status = 0; hdbValue newValue; pDynString parData = NULL, result= NULL; Protocol protocol = normal_protocol; @@ -2651,7 +2651,7 @@ static int ZipReadHdbNode(SConnection * pCon, SicsInterp * pSics, { pHdb targetNode = NULL; char error[512], oriPath[512]; - int status; + int status = 0; pDynString parData = NULL, result= NULL; Protocol protocol = normal_protocol; OutCode outCode; diff --git a/singlex.c b/singlex.c index 56a80fe2..848fe039 100644 --- a/singlex.c +++ b/singlex.c @@ -70,7 +70,7 @@ static MotorFunction TextToFunc(char *txt) } count++; } - return -1; + return None; } /*---------------------------------------------------------------------------*/ @@ -112,7 +112,7 @@ static int ConfigureCmd(pSICSOBJ self, SConnection * pCon, } mf = TextToFunc(v.v.text); - if (mf < 0) { + if (mf == None) { SCPrintf(pCon, eError, "ERROR: failed to map %s to configuration parameter", v.v.text); @@ -167,7 +167,7 @@ static int MotorCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode, } mf = TextToFunc(par[0]->value.v.text); - if (mf < 0) { + if (mf == None) { SCPrintf(pCon, eError, "ERROR: %s is not a four circle motor", par[0]->value.v.text); return 0; @@ -198,7 +198,7 @@ static int MotorNamCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode, } mf = TextToFunc(par[0]->value.v.text); - if (mf < 0) { + if (mf == None) { SCPrintf(pCon, eError, "ERROR: %s is not a four circle motor", par[0]->value.v.text); return 0; @@ -450,7 +450,7 @@ static int SymRefCmd(pSICSOBJ self, SConnection * pCon, pHdb commandNode, hkl[2] = equiv.l[i]; if (priv->diffractometer-> calculateSettings(priv->diffractometer, hkl, settings) == 1) { - snprintf(buffer, 512, "%d,%d,%d", equiv.h[i], equiv.k[i], + snprintf(buffer, sizeof(buffer), "%d,%d,%d", equiv.h[i], equiv.k[i], equiv.l[i]); SCWrite(pCon, buffer, eValue); return 1; diff --git a/singlex.h b/singlex.h index a1fcf6d8..35f5557f 100644 --- a/singlex.h +++ b/singlex.h @@ -16,7 +16,7 @@ #include "singlediff.h" typedef enum { - TwoTheta, Omega, Chi, Phi, Nu, Sgu, Sgl + TwoTheta, Omega, Chi, Phi, Nu, Sgu, Sgl, None } MotorFunction; pMotor SXGetMotor(MotorFunction m); const char *SXGetMotorName(MotorFunction m); diff --git a/splitter.c b/splitter.c index 562cdda3..c802a037 100644 --- a/splitter.c +++ b/splitter.c @@ -56,7 +56,7 @@ static TokenList *CreateToken(TokenList * pN, TokenList * pP) static CharType CheckSpecial(char *pWord) { - CharType eRes = eText; + CharType eRes = eeText; int iFlag = 0; if (isspace(pWord[0])) diff --git a/stdscan.c b/stdscan.c index d01a3ad0..43698b61 100644 --- a/stdscan.c +++ b/stdscan.c @@ -498,11 +498,11 @@ int WriteScanPoints(pScanData self, int iPoint) strlcat(pSteps, pItem,255); } } - strlcat(pLine, " Counts ",1024); - strlcat(pLine, "Monitor1 ",1024); - strlcat(pLine, "Monitor2 ",1024); - strlcat(pLine, "Monitor3 ",1024); - strlcat(pLine, "Time ",1024); + strlcat(pLine, " Counts ",sizeof(pLine)); + strlcat(pLine, "Monitor1 ",sizeof(pLine)); + strlcat(pLine, "Monitor2 ",sizeof(pLine)); + strlcat(pLine, "Monitor3 ",sizeof(pLine)); + strlcat(pLine, "Time ",sizeof(pLine)); strlcat(pInfo, pSteps,1024); snprintf(pItem,sizeof(pItem)-1, "\n%d Points,", self->iNP); strlcat(pInfo, pItem,1024); @@ -525,7 +525,7 @@ int WriteScanPoints(pScanData self, int iPoint) pVar = (pVarEntry) pPtr; if (pVar) { snprintf(pItem,sizeof(pItem)-1, "%-9.4f ", GetScanVarPos(pVar, i)); - strlcat(pLine, pItem,1024); + strlcat(pLine, pItem,sizeof(pLine)); } } /* print Counts & Monitor */ @@ -533,15 +533,15 @@ int WriteScanPoints(pScanData self, int iPoint) pData = (pCountEntry) pPtr; if (pData) { snprintf(pItem,sizeof(pItem)-1, " %-11ld ", pData->lCount); - strlcat(pLine, pItem,1024); + strlcat(pLine, pItem,sizeof(pLine)); snprintf(pItem,sizeof(pItem)-1, "%-11ld ", pData->Monitors[0]); - strlcat(pLine, pItem,1024); + strlcat(pLine, pItem,sizeof(pLine)); snprintf(pItem,sizeof(pItem)-1, "%-11ld ", pData->Monitors[1]); - strlcat(pLine, pItem,1024); + strlcat(pLine, pItem,sizeof(pLine)); snprintf(pItem,sizeof(pItem)-1, "%-11ld ", pData->Monitors[2]); - strlcat(pLine, pItem,1024); + strlcat(pLine, pItem,sizeof(pLine)); snprintf(pItem,sizeof(pItem)-1, "%-8.3f ", pData->fTime); - strlcat(pLine, pItem,1024); + strlcat(pLine, pItem,sizeof(pLine)); } fprintf(self->fd, "%s\n", pLine); } diff --git a/tasscanub.c b/tasscanub.c index c721a7aa..19a4a5d3 100644 --- a/tasscanub.c +++ b/tasscanub.c @@ -184,7 +184,7 @@ static float GetVarFloat(char *name) static int TASUBHeader(pScanData self) { pTASdata pTAS = (pTASdata) self->pSpecial; - int i, iCount, status, iFileNO; + int i, iCount, status, iFileNO = 0; char pBueffel[1024], pHeader[1024], pWork[132], pWork2[60], pTen[12], *pcPtr; time_t iDate; @@ -201,7 +201,7 @@ static int TASUBHeader(pScanData self) tasReflection r; double kfix; pSicsVariable sVar = NULL; - float f1, f2, f3, f4; + float f1=.0, f2=.0, f3=.0, f4=.0; assert(self); assert(pTAS); diff --git a/tasscanub.h b/tasscanub.h index faf0bb89..868af18c 100644 --- a/tasscanub.h +++ b/tasscanub.h @@ -5,7 +5,7 @@ Mark Koennecke, May 2005, using code from an earlier TASAMAD emulation core. ------------------------------------------------------------------------*/ -#ifndef SICUBSTAS +#ifndef SICSUBTAS #define SICSUBTAS #include #include "tasub.h" diff --git a/tasublib.c b/tasublib.c index 768d0086..a8ea3907 100644 --- a/tasublib.c +++ b/tasublib.c @@ -163,7 +163,7 @@ double tasAngleBetweenReflections(MATRIX B, tasReflection r1, tasReflection r2) { MATRIX chi1, chi2, h1, h2; - double angle; + double angle = .0; h1 = makeVector(); if (h1 == NULL) { diff --git a/test/testini.tcl b/test/testini.tcl index 097ad774..5d31871c 100644 --- a/test/testini.tcl +++ b/test/testini.tcl @@ -500,12 +500,12 @@ proc schneggestatus {} { if {$runtime > $starttime} { sct writestatus evalcheck } - return busy + return run } evalcheck { set tst [hval /sics/farm/schneggerunning] if {$tst == 1} { - return busy + return run } else { return idle } diff --git a/trace.c b/trace.c index aa1da596..a9ae51ee 100644 --- a/trace.c +++ b/trace.c @@ -421,7 +421,7 @@ static int TraceLogTask(void *data) memset(pBuffer, 0, sizeof(pBuffer)); strftime(pBuffer, sizeof(pBuffer)-1, "%Y-%m-%d@%H-%M-%S", psTime); lastTen = tenmin; - traceSys("TIMESTAMP",pBuffer); + traceSys("TIMESTAMP","%s",pBuffer); } return 1; diff --git a/ubfour.c b/ubfour.c index 2e38f220..e76578d4 100644 --- a/ubfour.c +++ b/ubfour.c @@ -588,7 +588,7 @@ int searchIndex(lattice direct, double lambda, double two_theta, double angleBetweenReflections(MATRIX B, reflection r1, reflection r2) { MATRIX chi1, chi2, h1, h2; - double angle; + double angle = .0; h1 = makeVector(); if (h1 == NULL) {