Fixed clang issues.
authorArmin Novak <anovak@thinstuff.com>
Fri, 30 Aug 2013 14:30:27 +0000 (16:30 +0200)
committerArmin Novak <anovak@thinstuff.com>
Thu, 5 Sep 2013 10:14:34 +0000 (12:14 +0200)
channels/smartcard/client/smartcard_operations.c

index c72f38d..695e533 100644 (file)
 #include "config.h"
 #endif
 
+#include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 #include <strings.h>
-#include <pthread.h>
-#include <semaphore.h>
 
 #define BOOL PCSC_BOOL
 #include <PCSC/pcsclite.h>
@@ -153,6 +151,7 @@ static void smartcard_output_buffer_limit(IRP* irp, char* buffer, unsigned int l
        }
        else
        {
+               assert(NULL != buffer);
                if (header < length)
                        length = header;
 
@@ -485,6 +484,11 @@ static UINT32 handle_GetStatusChange(IRP* irp, BOOL wide)
                                (unsigned) cur->pvUserData, (unsigned) cur->dwCurrentState,
                                (unsigned) cur->dwEventState);
 
+                       if (!cur->szReader)
+                       {
+                               DEBUG_WARN("cur->szReader=%p", cur->szReader);
+                               continue;
+                       }
                        if (strcmp(cur->szReader, "\\\\?PnP?\\Notification") == 0)
                                cur->dwCurrentState |= SCARD_STATE_IGNORE;
                }
@@ -966,15 +970,19 @@ static UINT32 handle_Transmit(IRP* irp)
 
                Stream_Write_UINT32(irp->output, 0);    /* pioRecvPci 0x00; */
 
-               smartcard_output_buffer_start(irp, cbRecvLength);       /* start of recvBuf output */
-
-               smartcard_output_buffer(irp, (char*) recvBuf, cbRecvLength);
+               if (recvBuf)
+               {
+                       smartcard_output_buffer_start(irp, cbRecvLength);       /* start of recvBuf output */
+                       smartcard_output_buffer(irp, (char*) recvBuf, cbRecvLength);
+               }
        }
 
        smartcard_output_alignment(irp, 8);
 
-       free(sendBuf);
-       free(recvBuf);
+       if (sendBuf)
+               free(sendBuf);
+       if (recvBuf)
+               free(recvBuf);
 
        return status;
 }
@@ -1277,6 +1285,11 @@ static UINT32 handle_LocateCardsByATR(IRP* irp, BOOL wide)
                                (unsigned) cur->pvUserData, (unsigned) cur->dwCurrentState,
                                (unsigned) cur->dwEventState);
 
+               if (!cur->szReader)
+               {
+                       DEBUG_WARN("cur->szReader=%p", cur->szReader);
+                       continue;
+               }
                if (strcmp(cur->szReader, "\\\\?PnP?\\Notification") == 0)
                        cur->dwCurrentState |= SCARD_STATE_IGNORE;
        }