Pointer checking in MSocketDevice::readData

From: Erik Hovland <erik@hovland.org>

Much like the fix in writeData, it is not necessary to do anything but
return 0 if the read length given is zero. This provides a fast path if
users actually want to use the member function that way.

Then the conditional for checking the pointer to the data to read can
be checked for validity w/out the need to check length.

Since my writeData patch ended up in the _win version as well, I am
submitting this patch w/ the same change to _win (although it is
untested by me).
---

 mythtv/libs/libmythdb/msocketdevice_unix.cpp |    6 +++++-
 mythtv/libs/libmythdb/msocketdevice_win.cpp  |    6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)


diff --git a/mythtv/libs/libmythdb/msocketdevice_unix.cpp b/mythtv/libs/libmythdb/msocketdevice_unix.cpp
index d969fa5..4353c7e 100644
--- a/mythtv/libs/libmythdb/msocketdevice_unix.cpp
+++ b/mythtv/libs/libmythdb/msocketdevice_unix.cpp
@@ -734,9 +734,13 @@ qint64 MSocketDevice::waitForMore( int msecs, bool *timeout ) const
 */
 qint64 MSocketDevice::readData( char *data, qint64 maxlen )
 {
-    if ( data == 0 && maxlen != 0 ) {
+    if ( maxlen == 0 )
+        return 0;
+
+    if ( data == 0 ) {
         VERBOSE(VB_SOCKET|VB_EXTRA,
                 "MSocketDevice::readBlock: Null pointer error");
+        return -1;
     }
     if ( !isValid() ) {
         VERBOSE(VB_SOCKET|VB_EXTRA,
diff --git a/mythtv/libs/libmythdb/msocketdevice_win.cpp b/mythtv/libs/libmythdb/msocketdevice_win.cpp
index 28a71cf..0f516e2 100644
--- a/mythtv/libs/libmythdb/msocketdevice_win.cpp
+++ b/mythtv/libs/libmythdb/msocketdevice_win.cpp
@@ -691,9 +691,13 @@ qint64 MSocketDevice::waitForMore( int msecs, bool *timeout ) const
 
 qint64 MSocketDevice::readData( char *data, qint64 maxlen )
 {
+    if ( maxlen == 0 )
+        return 0;
+
 #if defined(QT_CHECK_NULL)
-    if ( data == 0 && maxlen != 0 ) {
+    if ( data == 0 ) {
 	qWarning( "MSocketDevice::readBlock: Null pointer error" );
+        return -1;
     }
 #endif
 #if defined(QT_CHECK_STATE)
