summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Ohly <patrick.ohly@intel.com>2011-04-11 13:26:58 +0200
committerPatrick Ohly <patrick.ohly@intel.com>2011-04-11 13:26:58 +0200
commit14c8cc42193723bed64424409c37d0462ceceb86 (patch)
tree23d88706eee046e39692e3bc6865568097a1df0a
parent487d78832ca43879902dd0a119fcc2015c50e88c (diff)
fixed compiler warnings around "unsigned >= 0"
clang 2.9 detects comparisons which are always true, like "unsigned value >= 0", and warns about them. In some cases the usage of a signed type prevents detecting underflows (argidx = c-'1'), in another it means that error handling was never done (fread() returns 0 on error, not -1). Fixed by switching (back?) to signed types and casting to unsigned after sanity check and before comparison against other, real unsigned types.
-rwxr-xr-xsrc/sysync/scriptcontext.cpp4
-rwxr-xr-xsrc/sysync/stringutils.cpp4
-rwxr-xr-xsrc/sysync/syncappbase.cpp2
-rwxr-xr-xsrc/sysync_SDK/Sources/SDK_support.cpp6
4 files changed, 8 insertions, 8 deletions
diff --git a/src/sysync/scriptcontext.cpp b/src/sysync/scriptcontext.cpp
index 7ea4fac..35dff88 100755
--- a/src/sysync/scriptcontext.cpp
+++ b/src/sysync/scriptcontext.cpp
@@ -2448,8 +2448,8 @@ void TScriptContext::Tokenize(TSyncAppBase *aAppBaseP, cAppCharP aScriptName, sI
continue;
}
else if (isdigit(c)) {
- size_t argidx = c-'1';
- if (argidx>=0 && argidx<aMacroArgsP->size()) {
+ ssize_t argidx = c-'1';
+ if (argidx>=0 && (size_t)argidx<aMacroArgsP->size()) {
// found macro argument, replace in input string
itext.replace(i-1, 2, (*aMacroArgsP)[argidx]);
// no nested macro argument eval, just advance pointer behind replacement text
diff --git a/src/sysync/stringutils.cpp b/src/sysync/stringutils.cpp
index 6abacbd..1b42d76 100755
--- a/src/sysync/stringutils.cpp
+++ b/src/sysync/stringutils.cpp
@@ -796,7 +796,7 @@ void vStringObjPrintf(string &aStringObj, const char *aFormat, bool aAppend, va_
#else
const size_t bufsiz=2048;
#endif
- size_t actualsize;
+ ssize_t actualsize;
char buf[bufsiz];
buf[0]='\0';
@@ -810,7 +810,7 @@ void vStringObjPrintf(string &aStringObj, const char *aFormat, bool aAppend, va_
#endif
actualsize = vsnprintf(buf, bufsiz, aFormat, aArgs);
#ifndef NO_VSNPRINTF
- if (actualsize>=bufsiz) {
+ if (actualsize>=(ssize_t)bufsiz) {
// default buffer was too small, create bigger dynamic buffer
bufP = new char[actualsize+1];
actualsize = vsnprintf(bufP, actualsize+1, aFormat, args);
diff --git a/src/sysync/syncappbase.cpp b/src/sysync/syncappbase.cpp
index c8d50c4..d99965b 100755
--- a/src/sysync/syncappbase.cpp
+++ b/src/sysync/syncappbase.cpp
@@ -1805,7 +1805,7 @@ static int _CALLING_ CFileReader(
FILE *cfgfile = (FILE *)aContext;
// read from file
size_t len = fread(aBuffer, 1, aMaxSize, cfgfile);
- if (len<0) {
+ if (len<=0) {
if (!feof(cfgfile))
return appFalse; // not EOF, other error: failed
len=0; // nothing read, end of file
diff --git a/src/sysync_SDK/Sources/SDK_support.cpp b/src/sysync_SDK/Sources/SDK_support.cpp
index 49ef310..c54226d 100755
--- a/src/sysync_SDK/Sources/SDK_support.cpp
+++ b/src/sysync_SDK/Sources/SDK_support.cpp
@@ -571,15 +571,15 @@ CVersion VersionNr( string s )
bool SameBegin( string s, string cmp )
{
- uInt32 w= s.length()-cmp.length();
+ ssize_t w= s.length()-cmp.length();
return w>=0 && s.find ( cmp, 0 )==0;
} // SameBegin
bool SameEnd ( string s, string cmp )
{
- uInt32 w= s.length()-cmp.length();
- return w>=0 && s.find ( cmp, w )==w;
+ ssize_t w= s.length()-cmp.length();
+ return w>=0 && s.find ( cmp, w )==(size_t)w;
} // SameEnd