lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 27 May 2011 01:44:15 -0700
From:	matt mooney <mfm@...eddisk.com>
To:	Greg Kroah-Hartman <greg@...ah.com>
Cc:	usbip-devel@...ts.sourceforge.net, linux-kernel@...r.kernel.org
Subject: [PATCH 6/6] staging: usbip: userspace: usbip_list.c: cleanup exported device functions

Rename functions and cleanup coding style.

Signed-off-by: matt mooney <mfm@...eddisk.com>
---
 drivers/staging/usbip/userspace/src/usbip_list.c |   90 ++++++++++------------
 1 files changed, 42 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c
index e69c457..03f6210 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -45,45 +45,43 @@ void usbip_list_usage(void)
 	printf("usage: %s", usbip_list_usage_string);
 }
 
-static int query_exported_devices(int sockfd)
+static int get_exported_devices(int sockfd)
 {
-	int ret;
+	char product_name[100];
+	char class_name[100];
 	struct op_devlist_reply rep;
 	uint16_t code = OP_REP_DEVLIST;
-
-	memset(&rep, 0, sizeof(rep));
-
-	ret = usbip_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
-	if (ret < 0) {
-		err("send op_common");
+	struct usbip_usb_device udev;
+	struct usbip_usb_interface uintf;
+	unsigned int i;
+	int j, rc;
+
+	rc = usbip_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
+	if (rc < 0) {
+		dbg("usbip_send_op_common");
 		return -1;
 	}
 
-	ret = usbip_recv_op_common(sockfd, &code);
-	if (ret < 0) {
-		err("recv op_common");
+	rc = usbip_recv_op_common(sockfd, &code);
+	if (rc < 0) {
+		dbg("usbip_recv_op_common");
 		return -1;
 	}
 
-	ret = usbip_recv(sockfd, (void *) &rep, sizeof(rep));
-	if (ret < 0) {
-		err("recv op_devlist");
+	memset(&rep, 0, sizeof(rep));
+	rc = usbip_recv(sockfd, &rep, sizeof(rep));
+	if (rc < 0) {
+		dbg("usbip_recv_op_devlist");
 		return -1;
 	}
-
 	PACK_OP_DEVLIST_REPLY(0, &rep);
-	dbg("exportable %d devices", rep.ndev);
-
-	for (unsigned int i=0; i < rep.ndev; i++) {
-		char product_name[100];
-		char class_name[100];
-		struct usbip_usb_device udev;
+	dbg("exportable devices: %d", rep.ndev);
 
+	for (i = 0; i < rep.ndev; i++) {
 		memset(&udev, 0, sizeof(udev));
-
-		ret = usbip_recv(sockfd, (void *) &udev, sizeof(udev));
-		if (ret < 0) {
-			err("recv usbip_usb_device[%d]", i);
+		rc = usbip_recv(sockfd, &udev, sizeof(udev));
+		if (rc < 0) {
+			dbg("usbip_recv: usbip_usb_device[%d]", i);
 			return -1;
 		}
 		pack_usb_device(0, &udev);
@@ -93,38 +91,34 @@ static int query_exported_devices(int sockfd)
 		usbip_names_get_class(class_name, sizeof(class_name),
 				      udev.bDeviceClass, udev.bDeviceSubClass,
 				      udev.bDeviceProtocol);
-
 		printf("%8s: %s\n", udev.busid, product_name);
-		printf("%8s: %s\n", " ", udev.path);
-		printf("%8s: %s\n", " ", class_name);
-
-		for (int j=0; j < udev.bNumInterfaces; j++) {
-			struct usbip_usb_interface uinf;
+		printf("%8s: %s\n", "", udev.path);
+		printf("%8s: %s\n", "", class_name);
 
-			ret = usbip_recv(sockfd, (void *) &uinf, sizeof(uinf));
-			if (ret < 0) {
-				err("recv usbip_usb_interface[%d]", j);
+		for (j = 0; j < udev.bNumInterfaces; j++) {
+			rc = usbip_recv(sockfd, &uintf, sizeof(uintf));
+			if (rc < 0) {
+				dbg("usbip_recv: usbip_usb_interface[%d]", j);
 				return -1;
 			}
+			pack_usb_interface(0, &uintf);
 
-			pack_usb_interface(0, &uinf);
 			usbip_names_get_class(class_name, sizeof(class_name),
-					      uinf.bInterfaceClass,
-					      uinf.bInterfaceSubClass,
-					      uinf.bInterfaceProtocol);
+					      uintf.bInterfaceClass,
+					      uintf.bInterfaceSubClass,
+					      uintf.bInterfaceProtocol);
+			printf("%8s: %2d - %s\n", "", j, class_name);
 
-			printf("%8s: %2d - %s\n", " ", j, class_name);
 		}
-
 		printf("\n");
 	}
 
-	return rep.ndev;
+	return 0;
 }
 
-static int show_exported_devices(char *host)
+static int list_exported_devices(char *host)
 {
-	int ret;
+	int rc;
 	int sockfd;
 
 	sockfd = usbip_net_tcp_connect(host, USBIP_PORT_STRING);
@@ -134,16 +128,16 @@ static int show_exported_devices(char *host)
 		return -1;
 	}
 	dbg("connected to %s port %s\n", host, USBIP_PORT_STRING);
-
 	printf("- %s\n", host);
 
-	ret = query_exported_devices(sockfd);
-	if (ret < 0) {
-		err("query");
+	rc = get_exported_devices(sockfd);
+	if (rc < 0) {
+		dbg("get_exported_devices failed");
 		return -1;
 	}
 
 	close(sockfd);
+
 	return 0;
 }
 
@@ -273,7 +267,7 @@ int usbip_list(int argc, char *argv[])
 			parsable = true;
 			break;
 		case 'r':
-			ret = show_exported_devices(optarg);
+			ret = list_exported_devices(optarg);
 			goto out;
 		case 'l':
 			ret = list_devices(parsable);
-- 
1.7.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ