[Pcsclite-cvs-commit] r6737 - trunk/Drivers/ccid/src

ludovic.rousseau at free.fr ludovic.rousseau at free.fr
Fri Aug 23 08:41:11 UTC 2013


Author: rousseau
Date: 2013-08-23 08:41:11 +0000 (Fri, 23 Aug 2013)
New Revision: 6737

Modified:
   trunk/Drivers/ccid/src/ccid_usb.c
Log:
Fix "clang --analyze" warning

ccid_usb.c:1095:14: warning: Result of 'calloc' is converted to a pointer of
      type 'unsigned int', which is incompatible with sizeof operand type 'int'
        int_array = calloc(n+1, sizeof(int));
                    ^~~~~~      ~~~~~~~~~~~

- Change variable name int_array -> uint_array since the type is
  "unsigned int"
- Use sizeof(uint_array[0]) to always get the correct type of a
  uint_array[] element


Modified: trunk/Drivers/ccid/src/ccid_usb.c
===================================================================
--- trunk/Drivers/ccid/src/ccid_usb.c	2013-08-23 08:36:37 UTC (rev 6736)
+++ trunk/Drivers/ccid/src/ccid_usb.c	2013-08-23 08:41:11 UTC (rev 6737)
@@ -1055,7 +1055,7 @@
 {
 	int n, i, len;
 	unsigned char buffer[256*sizeof(int)];	/* maximum is 256 records */
-	unsigned int *int_array;
+	unsigned int *uint_array;
 
 	/* See CCID 3.7.3 page 25 */
 	n = ControlUSB(reader_index,
@@ -1092,8 +1092,8 @@
 			n = len;
 	}
 
-	int_array = calloc(n+1, sizeof(int));
-	if (NULL == int_array)
+	uint_array = calloc(n+1, sizeof(uint_array[0]));
+	if (NULL == uint_array)
 	{
 		DEBUG_CRITICAL("Memory allocation failed");
 		return NULL;
@@ -1102,14 +1102,14 @@
 	/* convert in correct endianess */
 	for (i=0; i<n; i++)
 	{
-		int_array[i] = dw2i(buffer, i*4);
-		DEBUG_INFO2("declared: %d bps", int_array[i]);
+		uint_array[i] = dw2i(buffer, i*4);
+		DEBUG_INFO2("declared: %d bps", uint_array[i]);
 	}
 
 	/* end of array marker */
-	int_array[i] = 0;
+	uint_array[i] = 0;
 
-	return int_array;
+	return uint_array;
 } /* get_data_rates */
 
 




More information about the Pcsclite-cvs-commit mailing list