summaryrefslogtreecommitdiffstats
path: root/src/OSSupport
diff options
context:
space:
mode:
Diffstat (limited to 'src/OSSupport')
-rw-r--r--src/OSSupport/Errors.cpp2
-rw-r--r--src/OSSupport/File.cpp20
-rw-r--r--src/OSSupport/GZipFile.cpp4
-rw-r--r--src/OSSupport/ListenThread.h20
-rw-r--r--src/OSSupport/Sleep.h2
-rw-r--r--src/OSSupport/SocketThreads.h2
-rw-r--r--src/OSSupport/Thread.h2
7 files changed, 27 insertions, 25 deletions
diff --git a/src/OSSupport/Errors.cpp b/src/OSSupport/Errors.cpp
index 2e05f1df1..6072b6ac6 100644
--- a/src/OSSupport/Errors.cpp
+++ b/src/OSSupport/Errors.cpp
@@ -22,7 +22,7 @@ AString GetOSErrorString( int a_ErrNo )
// According to http://linux.die.net/man/3/strerror_r there are two versions of strerror_r():
- #if ( _GNU_SOURCE ) && !defined(ANDROID_NDK) // GNU version of strerror_r()
+ #if !defined(__APPLE__) && ( _GNU_SOURCE ) && !defined(ANDROID_NDK) // GNU version of strerror_r()
char * res = strerror_r( errno, buffer, ARRAYCOUNT(buffer) );
if( res != NULL )
diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp
index 17070030f..7f0f0ad2f 100644
--- a/src/OSSupport/File.cpp
+++ b/src/OSSupport/File.cpp
@@ -152,7 +152,7 @@ int cFile::Read (void * iBuffer, int iNumBytes)
return -1;
}
- return fread(iBuffer, 1, iNumBytes, m_File); // fread() returns the portion of Count parameter actually read, so we need to send iNumBytes as Count
+ return (int)fread(iBuffer, 1, (size_t)iNumBytes, m_File); // fread() returns the portion of Count parameter actually read, so we need to send iNumBytes as Count
}
@@ -168,7 +168,7 @@ int cFile::Write(const void * iBuffer, int iNumBytes)
return -1;
}
- int res = fwrite(iBuffer, 1, iNumBytes, m_File); // fwrite() returns the portion of Count parameter actually written, so we need to send iNumBytes as Count
+ int res = (int)fwrite(iBuffer, 1, (size_t)iNumBytes, m_File); // fwrite() returns the portion of Count parameter actually written, so we need to send iNumBytes as Count
return res;
}
@@ -189,7 +189,7 @@ int cFile::Seek (int iPosition)
{
return -1;
}
- return ftell(m_File);
+ return (int)ftell(m_File);
}
@@ -206,7 +206,7 @@ int cFile::Tell (void) const
return -1;
}
- return ftell(m_File);
+ return (int)ftell(m_File);
}
@@ -222,7 +222,7 @@ int cFile::GetSize(void) const
return -1;
}
- int CurPos = ftell(m_File);
+ int CurPos = Tell();
if (CurPos < 0)
{
return -1;
@@ -231,8 +231,8 @@ int cFile::GetSize(void) const
{
return -1;
}
- int res = ftell(m_File);
- if (fseek(m_File, CurPos, SEEK_SET) != 0)
+ int res = Tell();
+ if (fseek(m_File, (long)CurPos, SEEK_SET) != 0)
{
return -1;
}
@@ -255,7 +255,7 @@ int cFile::ReadRestOfFile(AString & a_Contents)
int DataSize = GetSize() - Tell();
// HACK: This depends on the internal knowledge that AString's data() function returns the internal buffer directly
- a_Contents.assign(DataSize, '\0');
+ a_Contents.assign((size_t)DataSize, '\0');
return Read((void *)a_Contents.data(), DataSize);
}
@@ -350,7 +350,7 @@ int cFile::GetSize(const AString & a_FileName)
struct stat st;
if (stat(a_FileName.c_str(), &st) == 0)
{
- return st.st_size;
+ return (int)st.st_size;
}
return -1;
}
@@ -456,7 +456,7 @@ int cFile::Printf(const char * a_Fmt, ...)
va_start(args, a_Fmt);
AppendVPrintf(buf, a_Fmt, args);
va_end(args);
- return Write(buf.c_str(), buf.length());
+ return Write(buf.c_str(), (int)buf.length());
}
diff --git a/src/OSSupport/GZipFile.cpp b/src/OSSupport/GZipFile.cpp
index b13e519e0..7a8433f4f 100644
--- a/src/OSSupport/GZipFile.cpp
+++ b/src/OSSupport/GZipFile.cpp
@@ -78,7 +78,7 @@ int cGZipFile::ReadRestOfFile(AString & a_Contents)
while ((NumBytesRead = gzread(m_File, Buffer, sizeof(Buffer))) > 0)
{
TotalBytes += NumBytesRead;
- a_Contents.append(Buffer, NumBytesRead);
+ a_Contents.append(Buffer, (size_t)NumBytesRead);
}
// NumBytesRead is < 0 on error
return (NumBytesRead >= 0) ? TotalBytes : NumBytesRead;
@@ -102,7 +102,7 @@ bool cGZipFile::Write(const char * a_Contents, int a_Size)
return false;
}
- return (gzwrite(m_File, a_Contents, a_Size) != 0);
+ return (gzwrite(m_File, a_Contents, (unsigned int)a_Size) != 0);
}
diff --git a/src/OSSupport/ListenThread.h b/src/OSSupport/ListenThread.h
index 4e337d814..b2d806c82 100644
--- a/src/OSSupport/ListenThread.h
+++ b/src/OSSupport/ListenThread.h
@@ -29,43 +29,45 @@ class cListenThread :
typedef cIsThread super;
public:
- /// Used as the callback for connection events
+ /** Used as the callback for connection events */
class cCallback
{
public:
- /// This callback is called whenever a socket connection is accepted
+ virtual ~cCallback() {}
+
+ /** This callback is called whenever a socket connection is accepted */
virtual void OnConnectionAccepted(cSocket & a_Socket) = 0;
} ;
cListenThread(cCallback & a_Callback, cSocket::eFamily a_Family, const AString & a_ServiceName = "");
~cListenThread();
- /// Creates all the sockets, returns trus if successful, false if not.
+ /** Creates all the sockets, returns trus if successful, false if not. */
bool Initialize(const AString & a_PortsString);
bool Start(void);
void Stop(void);
- /// Call before Initialize() to set the "reuse" flag on the sockets
+ /** Call before Initialize() to set the "reuse" flag on the sockets */
void SetReuseAddr(bool a_Reuse = true);
protected:
typedef std::vector<cSocket> cSockets;
- /// The callback which to notify of incoming connections
+ /** The callback which to notify of incoming connections */
cCallback & m_Callback;
- /// Socket address family to use
+ /** Socket address family to use */
cSocket::eFamily m_Family;
- /// Sockets that are being monitored
+ /** Sockets that are being monitored */
cSockets m_Sockets;
- /// If set to true, the SO_REUSEADDR socket option is set to true
+ /** If set to true, the SO_REUSEADDR socket option is set to true */
bool m_ShouldReuseAddr;
- /// Name of the service that's listening on the ports; for logging purposes only
+ /** Name of the service that's listening on the ports; for logging purposes only */
AString m_ServiceName;
diff --git a/src/OSSupport/Sleep.h b/src/OSSupport/Sleep.h
index 5298c15da..0ec0adf9d 100644
--- a/src/OSSupport/Sleep.h
+++ b/src/OSSupport/Sleep.h
@@ -4,4 +4,4 @@ class cSleep
{
public:
static void MilliSleep( unsigned int a_MilliSeconds );
-}; \ No newline at end of file
+};
diff --git a/src/OSSupport/SocketThreads.h b/src/OSSupport/SocketThreads.h
index b2eb5950f..679e374e1 100644
--- a/src/OSSupport/SocketThreads.h
+++ b/src/OSSupport/SocketThreads.h
@@ -64,7 +64,7 @@ public:
virtual ~cCallback() {}
/** Called when data is received from the remote party */
- virtual void DataReceived(const char * a_Data, int a_Size) = 0;
+ virtual void DataReceived(const char * a_Data, size_t a_Size) = 0;
/** Called when data can be sent to remote party
The function is supposed to *set* outgoing data to a_Data (overwrite) */
diff --git a/src/OSSupport/Thread.h b/src/OSSupport/Thread.h
index 3c9316424..4153b2427 100644
--- a/src/OSSupport/Thread.h
+++ b/src/OSSupport/Thread.h
@@ -23,4 +23,4 @@ private:
cEvent* m_StopEvent;
AString m_ThreadName;
-}; \ No newline at end of file
+};