[Pcsclite-cvs-commit] Drivers/ccid/src ifdhandler.c,1.30,1.31 debug.c,1.2,1.3 commands.h,1.6,1.7 commands.c,1.12,1.13 ccid_usb.h,1.7,1.8 ccid_usb.c,1.23,1.24 ccid_serial.h,1.3,1.4 ccid_serial.c,1.10,1.11 ccid.c,1.5,1.6

rousseau@haydn.debian.org rousseau@haydn.debian.org


Update of /cvsroot/pcsclite/Drivers/ccid/src
In directory haydn:/tmp/cvs-serv7581/src

Modified Files:
	ifdhandler.c debug.c commands.h commands.c ccid_usb.h 
	ccid_usb.c ccid_serial.h ccid_serial.c ccid.c 
Log Message:
recompile using gcc -pedantic and correct:
- some C++ syntax comments
- many signedness "problems"


Index: ifdhandler.c
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/ifdhandler.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- ifdhandler.c	24 May 2004 10:02:48 -0000	1.30
+++ ifdhandler.c	24 May 2004 12:58:43 -0000	1.31
@@ -71,11 +71,11 @@
 	if (CheckLun(Lun))
 		return IFD_COMMUNICATION_ERROR;
 
-	// Reset ATR buffer
+	/* Reset ATR buffer */
 	CcidSlots[LunToReaderIndex(Lun)].nATRLength = 0;
 	*CcidSlots[LunToReaderIndex(Lun)].pcATRBuffer = '\0';
 
-	// Reset PowerFlags
+	/* Reset PowerFlags */
 	CcidSlots[LunToReaderIndex(Lun)].bPowerFlags = POWERFLAGS_RAZ;
 
 #ifdef HAVE_PTHREAD
@@ -379,7 +379,7 @@
 	 * IFD_NOT_SUPPORTED
 	 */
 
-	int nlength;
+	unsigned int nlength;
 	RESPONSECODE return_value = IFD_SUCCESS;
 	unsigned char pcbuffer[RESP_BUF_SIZE];
 
@@ -487,7 +487,7 @@
 	 */
 
 	RESPONSECODE return_value;
-	int rx_length;
+	unsigned int rx_length;
 
 	DEBUG_INFO2("lun: %X", Lun);
 
@@ -539,7 +539,7 @@
 		}
 		else
 		{
-			int iBytesReturned;
+			unsigned int iBytesReturned;
 
 			iBytesReturned = RxLength;
 			return_value = CmdEscape(Lun, TxBuffer, TxLength, RxBuffer,
@@ -550,7 +550,7 @@
 
 	if (IOCTL_SMARTCARD_VENDOR_VERIFY_PIN == dwControlCode)
 	{
-		int iBytesReturned;
+		unsigned int iBytesReturned;
 
 		iBytesReturned = RxLength;
 		return_value = SecurePIN(Lun, TxBuffer, TxLength, RxBuffer,
@@ -641,7 +641,7 @@
 		/* if the reader is fast enough */
 		if (baudrate < ccid_desc->dwMaxDataRate)
 		{
-			int len = 3;
+			unsigned int len = 3;
 			BYTE pps[] = {
 				0xFF,	/* PTSS */
 				0x10,	/* PTS0: PTS1 present */
@@ -671,7 +671,6 @@
 		ATR_GetProtocolType(&atr, 2, &protocol);
 
 	/* SetParameters */
-	//if (! (ccid_desc->dwFeatures & CCID_CLASS_AUTO_BAUD))
 	{
 		int convention;
 

Index: debug.c
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/debug.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- debug.c	6 Apr 2004 13:18:11 -0000	1.2
+++ debug.c	24 May 2004 12:58:43 -0000	1.3
@@ -47,7 +47,7 @@
 void debug_xxd(const char *msg, const unsigned char *buffer, const int len)
 {
 	int i;
-	unsigned char *c, *debug_buf_end;
+	char *c, *debug_buf_end;
 
 	debug_buf_end = DebugBuffer + DEBUG_BUF_SIZE - 5;
 
@@ -56,7 +56,7 @@
 
 	for (i = 0; (i < len) && (c < debug_buf_end); ++i)
 	{
-		sprintf(c, "%02X ", buffer[i]);
+		sprintf(c, "%02X ", (unsigned char)buffer[i]);
 		c += strlen(c);
 	}
 

Index: commands.h
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/commands.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- commands.h	24 May 2004 10:02:48 -0000	1.6
+++ commands.h	24 May 2004 12:58:43 -0000	1.7
@@ -25,23 +25,28 @@
 #define STATUS_OFFSET 7
 #define ERROR_OFFSET 8
 
-RESPONSECODE CmdPowerOn(int lun, int * nlength, unsigned char buffer[]);
-RESPONSECODE SecurePIN(int lun, const unsigned char TxBuffer[], int TxLength,
-	unsigned char RxBuffer[], int *RxLength);
-RESPONSECODE CmdEscape(int lun, const unsigned char TxBuffer[], int TxLength,
-	unsigned char RxBuffer[], int *RxLength);
+RESPONSECODE CmdPowerOn(int lun, unsigned int * nlength,
+	unsigned char buffer[]);
+RESPONSECODE SecurePIN(int lun, const unsigned char TxBuffer[],
+	unsigned int TxLength, unsigned char RxBuffer[], unsigned int *RxLength);
+RESPONSECODE CmdEscape(int lun, const unsigned char TxBuffer[],
+	unsigned int TxLength, unsigned char RxBuffer[], unsigned int *RxLength);
 RESPONSECODE CmdPowerOff(int lun);
 RESPONSECODE CmdGetSlotStatus(int lun, unsigned char buffer[]);
-RESPONSECODE CmdXfrBlock(int lun, int tx_length, unsigned char tx_buffer[],
-	int *rx_length, unsigned char rx_buffer[], int protoccol);
-RESPONSECODE CCID_Transmit(int lun, int tx_length,
+RESPONSECODE CmdXfrBlock(int lun, unsigned int tx_length,
+	unsigned char tx_buffer[], unsigned int *rx_length,
+	unsigned char rx_buffer[], int protoccol);
+RESPONSECODE CCID_Transmit(int lun, unsigned int tx_length,
 	const unsigned char tx_buffer[]);
-RESPONSECODE CCID_Receive(int lun, int *rx_length, unsigned char rx_buffer[]);
-RESPONSECODE CmdXfrBlockTPDU_T0(int lun, int tx_length,
-	unsigned char tx_buffer[], int *rx_length, unsigned char rx_buffer[]);
-RESPONSECODE CmdXfrBlockTPDU_T1(int lun, int tx_length,
-	unsigned char tx_buffer[], int *rx_length, unsigned char rx_buffer[]);
-RESPONSECODE SetParameters(int lun, char protocol, int length,
+RESPONSECODE CCID_Receive(int lun, unsigned int *rx_length,
+	unsigned char rx_buffer[]);
+RESPONSECODE CmdXfrBlockTPDU_T0(int lun, unsigned int tx_length,
+	unsigned char tx_buffer[], unsigned int *rx_length,
+	unsigned char rx_buffer[]);
+RESPONSECODE CmdXfrBlockTPDU_T1(int lun, unsigned int tx_length,
+	unsigned char tx_buffer[], unsigned int *rx_length,
+	unsigned char rx_buffer[]);
+RESPONSECODE SetParameters(int lun, char protocol, unsigned int length,
 	unsigned char buffer[]);
 
 void i2dw(int value, unsigned char *buffer);

Index: commands.c
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/commands.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- commands.c	24 May 2004 10:02:48 -0000	1.12
+++ commands.c	24 May 2004 12:58:43 -0000	1.13
@@ -40,7 +40,7 @@
  *					CmdPowerOn
  *
  ****************************************************************************/
-RESPONSECODE CmdPowerOn(int lun, int * nlength, unsigned char buffer[])
+RESPONSECODE CmdPowerOn(int lun, unsigned int * nlength, unsigned char buffer[])
 {
 	unsigned char cmd[10];
 	status_t res;
@@ -83,7 +83,7 @@
 		{
 			unsigned char cmd[] = "\x1F\x01";
 			unsigned char res[1];
-			int res_length = sizeof(res);
+			unsigned int res_length = sizeof(res);
 
 			if ((return_value = CmdEscape(lun, cmd, sizeof(cmd)-1, res,
 				&res_length)) != IFD_SUCCESS)
@@ -117,8 +117,8 @@
  *					SecurePIN
  *
  ****************************************************************************/
-RESPONSECODE SecurePIN(int lun, const unsigned char TxBuffer[], int TxLength,
-	unsigned char RxBuffer[], int *RxLength)
+RESPONSECODE SecurePIN(int lun, const unsigned char TxBuffer[],
+	unsigned int TxLength, unsigned char RxBuffer[], unsigned int *RxLength)
 {
 	unsigned char cmd[11+14+CMD_BUF_SIZE];
 	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(lun);
@@ -183,12 +183,12 @@
  *					Escape
  *
  ****************************************************************************/
-RESPONSECODE CmdEscape(int lun, const unsigned char TxBuffer[], int TxLength,
-	unsigned char RxBuffer[], int *RxLength)
+RESPONSECODE CmdEscape(int lun, const unsigned char TxBuffer[],
+	unsigned int TxLength, unsigned char RxBuffer[], unsigned int *RxLength)
 {
 	unsigned char *cmd_in, *cmd_out;
 	status_t res;
-	int length_in, length_out;
+	unsigned int length_in, length_out;
 	RESPONSECODE return_value = IFD_SUCCESS;
 	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(lun);
 
@@ -256,7 +256,7 @@
 {
 	unsigned char cmd[10];
 	status_t res;
-	int length;
+	unsigned int length;
 	RESPONSECODE return_value = IFD_SUCCESS;
 	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(lun);
 
@@ -294,7 +294,7 @@
 {
 	unsigned char cmd[10];
 	status_t res;
-	int length;
+	unsigned int length;
 	RESPONSECODE return_value = IFD_SUCCESS;
 	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(lun);
 
@@ -328,8 +328,9 @@
  *					CmdXfrBlock
  *
  ****************************************************************************/
-RESPONSECODE CmdXfrBlock(int lun, int tx_length, unsigned char tx_buffer[],
-	int *rx_length, unsigned char rx_buffer[], int protocol)
+RESPONSECODE CmdXfrBlock(int lun, unsigned int tx_length,
+	unsigned char tx_buffer[], unsigned int *rx_length,
+	unsigned char rx_buffer[], int protocol)
 {
 	RESPONSECODE return_value = IFD_SUCCESS;
 	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(lun);
@@ -390,7 +391,7 @@
  *					CCID_Transmit
  *
  ****************************************************************************/
-RESPONSECODE CCID_Transmit(int lun, int tx_length,
+RESPONSECODE CCID_Transmit(int lun, unsigned int tx_length,
 	const unsigned char tx_buffer[])
 {
 	unsigned char cmd[10+CMD_BUF_SIZE];	/* CCID + APDU buffer */
@@ -415,10 +416,11 @@
  *					CCID_Receive
  *
  ****************************************************************************/
-RESPONSECODE CCID_Receive(int lun, int *rx_length, unsigned char rx_buffer[])
+RESPONSECODE CCID_Receive(int lun, unsigned int *rx_length,
+	unsigned char rx_buffer[])
 {
 	unsigned char cmd[10+CMD_BUF_SIZE];	/* CCID + APDU buffer */
-	int length;
+	unsigned int length;
 
 time_request:
 	length = sizeof(cmd);
@@ -454,8 +456,9 @@
  *					CmdXfrBlockTPDU_T0
  *
  ****************************************************************************/
-RESPONSECODE CmdXfrBlockTPDU_T0(int lun, int tx_length,
-	unsigned char tx_buffer[], int *rx_length, unsigned char rx_buffer[])
+RESPONSECODE CmdXfrBlockTPDU_T0(int lun, unsigned int tx_length,
+	unsigned char tx_buffer[], unsigned int *rx_length,
+	unsigned char rx_buffer[])
 {
 	RESPONSECODE return_value = IFD_SUCCESS;
 
@@ -474,8 +477,9 @@
  *					CmdXfrBlockTPDU_T1
  *
  ****************************************************************************/
-RESPONSECODE CmdXfrBlockTPDU_T1(int lun, int tx_length,
-	unsigned char tx_buffer[], int *rx_length, unsigned char rx_buffer[])
+RESPONSECODE CmdXfrBlockTPDU_T1(int lun, unsigned int tx_length,
+	unsigned char tx_buffer[], unsigned int *rx_length,
+	unsigned char rx_buffer[])
 {
 	RESPONSECODE return_value;
 	APDU_Cmd cmd;
@@ -517,7 +521,8 @@
  *					SetParameters
  *
  ****************************************************************************/
-RESPONSECODE SetParameters(int lun, char protocol, int length, unsigned char buffer[])
+RESPONSECODE SetParameters(int lun, char protocol, unsigned int length,
+	unsigned char buffer[])
 {
 	unsigned char cmd[10+CMD_BUF_SIZE];	/* CCID + APDU buffer */
 	_ccid_descriptor *ccid_descriptor = get_ccid_descriptor(lun);

Index: ccid_usb.h
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/ccid_usb.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ccid_usb.h	17 May 2004 14:37:08 -0000	1.7
+++ ccid_usb.h	24 May 2004 12:58:43 -0000	1.8
@@ -23,8 +23,8 @@
 
 status_t OpenUSB(int lun, int channel);
 status_t OpenUSBByName(int lun, char *device);
-status_t WriteUSB(int lun, int length, unsigned char *Buffer);
-status_t ReadUSB(int lun, int *length, unsigned char *Buffer);
+status_t WriteUSB(int lun, unsigned int length, unsigned char *Buffer);
+status_t ReadUSB(int lun, unsigned int *length, unsigned char *Buffer);
 status_t CloseUSB(int lun);
 
 #ifdef __USB_H__

Index: ccid_usb.c
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/ccid_usb.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- ccid_usb.c	17 May 2004 14:37:08 -0000	1.23
+++ ccid_usb.c	24 May 2004 12:58:43 -0000	1.24
@@ -80,9 +80,8 @@
 
 static int get_end_points(struct usb_device *dev, _usbDevice *usb_device);
 
-static _usbDevice usbDevice[PCSCLITE_MAX_READERS] = {
-	[ 0 ... (PCSCLITE_MAX_READERS-1) ] = { NULL, NULL, 0, 0 }
-};
+/* ne need to initialize to 0 since it is static */
+static _usbDevice usbDevice[PCSCLITE_MAX_READERS];
 
 #define PCSCLITE_MANUKEY_NAME                   "ifdVendorID"
 #define PCSCLITE_PRODKEY_NAME                   "ifdProductID"
@@ -115,7 +114,7 @@
 	char keyValue[TOKEN_MAX_VALUE_SIZE];
 	int vendorID, productID;
 	char infofile[FILENAME_MAX];
-	int device_vendor, device_product;
+	unsigned int device_vendor, device_product;
 	char *dirname = NULL, *filename = NULL;
 
 	DEBUG_COMM3("Lun: %X, Device: %s", lun, device);
@@ -366,7 +365,7 @@
  *					WriteUSB
  *
  ****************************************************************************/
-status_t WriteUSB(int lun, int length, unsigned char *buffer)
+status_t WriteUSB(int lun, unsigned int length, unsigned char *buffer)
 {
 	int rv;
 	int reader = LunToReaderIndex(lun);
@@ -380,7 +379,8 @@
 	DEBUG_XXD(debug_header, buffer, length);
 #endif
 
-	rv = usb_bulk_write(usbDevice[reader].handle, usbDevice[reader].bulk_out, buffer, length, USB_WRITE_TIMEOUT);
+	rv = usb_bulk_write(usbDevice[reader].handle, usbDevice[reader].bulk_out,
+		(char *)buffer, length, USB_WRITE_TIMEOUT);
 
 	if (rv < 0)
 	{
@@ -399,7 +399,7 @@
  *					ReadUSB
  *
  ****************************************************************************/
-status_t ReadUSB(int lun, int * length, unsigned char *buffer)
+status_t ReadUSB(int lun, unsigned int * length, unsigned char *buffer)
 {
 	int rv;
 	int reader = LunToReaderIndex(lun);
@@ -409,8 +409,8 @@
 	sprintf(debug_header, "<- %06X ", (int)lun);
 #endif
 
-
-	rv = usb_bulk_read(usbDevice[reader].handle, usbDevice[reader].bulk_in, buffer, *length, USB_READ_TIMEOUT);
+	rv = usb_bulk_read(usbDevice[reader].handle, usbDevice[reader].bulk_in,
+		(char *)buffer, *length, USB_READ_TIMEOUT);
 	*length = rv;
 
 	if (rv < 0)
@@ -452,9 +452,10 @@
 		usb_interface->altsetting->bInterfaceNumber :
 		usbDevice[reader].dev->config->interface->altsetting->bInterfaceNumber;
 	
-	usb_release_interface(usbDevice[reader].handle, interface);
-
+	/* reset so that bSeq starts at 0 again */
 	usb_reset(usbDevice[reader].handle);
+
+	usb_release_interface(usbDevice[reader].handle, interface);
 	usb_close(usbDevice[reader].handle);
 
 	/* mark the resource unused */

Index: ccid_serial.h
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/ccid_serial.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ccid_serial.h	27 Jan 2004 13:32:55 -0000	1.3
+++ ccid_serial.h	24 May 2004 12:58:43 -0000	1.4
@@ -23,8 +23,8 @@
 
 status_t OpenSerial(int lun, int channel);
 status_t OpenSerialByName(int lun, char *dev_name);
-status_t WriteSerial(int lun, int length, unsigned char *Buffer);
-status_t ReadSerial(int lun, int *length, unsigned char *Buffer);
+status_t WriteSerial(int lun, unsigned int length, unsigned char *Buffer);
+status_t ReadSerial(int lun, unsigned int *length, unsigned char *Buffer);
 int get_bytes(int lun, unsigned char *buffer, int length);
 int ReadChunk(int lun, unsigned char *buffer, int buffer_length, int min_length);
 status_t CloseSerial(int lun);

Index: ccid_serial.c
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/ccid_serial.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ccid_serial.c	17 May 2004 14:35:51 -0000	1.10
+++ ccid_serial.c	24 May 2004 12:58:43 -0000	1.11
@@ -132,16 +132,15 @@
 /* The _serialDevice structure must be defined before including ccid_serial.h */
 #include "ccid_serial.h"
 
-static _serialDevice serialDevice[PCSCLITE_MAX_READERS] = {
-	[ 0 ... (PCSCLITE_MAX_READERS-1) ] = { -1, NULL }
-};
+/* no need to initialize to 0 since it is static */
+static _serialDevice serialDevice[PCSCLITE_MAX_READERS];
 
 /*****************************************************************************
  * 
  *				WriteSerial: Send bytes to the card reader
  *
  *****************************************************************************/
-status_t WriteSerial(int lun, int length, unsigned char *buffer)
+status_t WriteSerial(int lun, unsigned int length, unsigned char *buffer)
 {
 	int i;
 	unsigned char lrc;
@@ -193,7 +192,7 @@
  *				ReadSerial: Receive bytes from the card reader
  *
  *****************************************************************************/
-status_t ReadSerial(int lun, int *length, unsigned char *buffer)
+status_t ReadSerial(int lun, unsigned int *length, unsigned char *buffer)
 {
 	unsigned char c;
 	int rv;
@@ -298,10 +297,7 @@
 		c ^= buffer[i];
 
 	if (c != (SYNC ^ CTRL_ACK))
-	{
 		DEBUG_CRITICAL2("Wrong LRC: 0x%02X", c);
-		//return STATUS_COMM_ERROR;
-	}
 
 	if (echo)
 	{
@@ -489,7 +485,7 @@
 
 	serialDevice[reader].fd = open(dev_name, O_RDWR | O_NOCTTY);
 
-	if (serialDevice[reader].fd <= 0)
+	if (-1 == serialDevice[reader].fd)
 	{
 		DEBUG_CRITICAL3("open %s: %s", dev_name, strerror(errno));
 		return STATUS_UNSUCCESSFUL;

Index: ccid.c
===================================================================
RCS file: /cvsroot/pcsclite/Drivers/ccid/src/ccid.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ccid.c	24 May 2004 09:58:43 -0000	1.5
+++ ccid.c	24 May 2004 12:58:43 -0000	1.6
@@ -60,7 +60,7 @@
 			{
 				unsigned char cmd[] = "\xA0\x02";
 				unsigned char res[10];
-				int length_res = sizeof(res);
+				unsigned int length_res = sizeof(res);
 
 				if (CmdEscape(lun, cmd, sizeof(cmd)-1, res, &length_res) == IFD_SUCCESS)
 				{