PERFORCE change 164519 for review

Sylvestre Gallon syl at FreeBSD.org
Tue Jun 16 17:45:33 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=164519

Change 164519 by syl at syl_atuin on 2009/06/16 17:45:06

	Fix debug. Remove unintialised variable and possible bad derefence.
	Now all the test rework.

Affected files ...

.. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#36 edit
.. //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_desc.c#16 edit

Differences ...

==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10.c#36 (text+ko) ====

@@ -160,24 +160,29 @@
 	if (usb_backend == NULL)
 		return (-1);
 
+	printf("1\n");
 	pdev = NULL;
 	i = 0;
 	while ((pdev = libusb20_be_device_foreach(usb_backend, pdev)))
 		i++;
 
+	printf("2\n");
 	if (list == NULL) {
 		libusb20_be_free(usb_backend);
 		return (LIBUSB_ERROR_INVALID_PARAM);
 	}
 	*list = malloc((i + 1) * sizeof(void *));
+	printf("3\n");
 	if (*list == NULL) {
 		libusb20_be_free(usb_backend);
 		return (LIBUSB_ERROR_NO_MEM);
 	}
+	printf("4\n");
 	i = 0;
 	while ((pdev = libusb20_be_device_foreach(usb_backend, NULL))) {
 		/* get device into libUSB v1.0 list */
 		libusb20_be_dequeue_device(usb_backend, pdev);
+		printf("5\n");
 
 		ddesc = libusb20_dev_get_device_desc(pdev);
 		dev = malloc(sizeof(*dev));
@@ -205,6 +210,7 @@
 		i++;
 	}
 	(*list)[i] = NULL;
+	printf("6\n");
 
 	libusb20_be_free(usb_backend);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_list leave");
@@ -221,6 +227,7 @@
 	int i;
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_device_list enter");
 
@@ -240,6 +247,7 @@
 {
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_bus_number enter");
 
@@ -254,6 +262,7 @@
 {
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_address enter");
 
@@ -273,6 +282,7 @@
 	libusb_context *ctx;
 	int i, j, k, ret;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_max_packet_size enter");
 
@@ -308,6 +318,7 @@
 {
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_ref_device enter");
 
@@ -327,6 +338,7 @@
 {
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_unref_device enter");
 
@@ -510,6 +522,7 @@
 {
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device enter");
 
@@ -525,6 +538,7 @@
 {
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_configuration enter");
 
@@ -548,6 +562,7 @@
 	struct libusb20_device *pdev;
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_configuration enter");
 
@@ -568,6 +583,7 @@
 	libusb_context *ctx;
 	int ret = 0;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_claim_interface enter");
 
@@ -595,6 +611,7 @@
 	libusb_context *ctx;
 	int ret;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_release_interface enter");
 
@@ -624,6 +641,7 @@
 	libusb_context *ctx;
 	int ret;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_set_interface_alt_setting enter");
 
@@ -655,6 +673,7 @@
 	libusb_context *ctx;
 	int ret; 
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_clear_halt enter");
 
@@ -681,6 +700,7 @@
 {
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_reset_device enter");
 
@@ -697,6 +717,7 @@
 {
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_kernel_driver_active enter");
 
@@ -713,6 +734,7 @@
 	struct libusb20_device *pdev;
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_detach_kernel_driver enter");
 
@@ -736,6 +758,7 @@
 {
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_attach_kernel_driver enter");
 
@@ -756,6 +779,7 @@
 	libusb_context *ctx;
 	int len;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_alloc_transfer enter");
 
@@ -783,6 +807,7 @@
 	struct usb_transfer *bxfer;
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_transfer enter");
 
@@ -1086,6 +1111,7 @@
 {
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_cancel_transfer enter");
 

==== //depot/projects/soc2009/syl_usb/src/lib/libusb/libusb10_desc.c#16 (text+ko) ====

@@ -44,6 +44,7 @@
 	struct libusb20_device *pdev;
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_device_descriptor enter");
 
@@ -80,6 +81,7 @@
 	libusb_context *ctx;
 	uint8_t idx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_active_config_descriptor enter");
 
@@ -108,6 +110,7 @@
 	uint8_t nif, nend, nalt, i, j, k;
 	uint32_t if_idx, endp_idx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_config_descriptor enter");
 
@@ -235,8 +238,10 @@
 	libusb_context *ctx;
 	int i;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_config_descriptor_by_value enter");
+
 	if (dev == NULL || config == NULL)
 		return (LIBUSB_ERROR_INVALID_PARAM);
 	
@@ -262,6 +267,7 @@
 {
 	libusb_context *ctx;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_free_config_descriptor enter");
 
@@ -277,6 +283,7 @@
 	libusb_context *ctx;
 	int ret;
 
+	ctx = NULL;
 	GET_CONTEXT(ctx);
 	dprintf(ctx, LIBUSB_DEBUG_FUNCTION, "libusb_get_string_descriptor_ascii enter");
 


More information about the p4-projects mailing list