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:	Sun, 19 Jun 2011 22:44:44 -0700
From:	matt mooney <mfm@...eddisk.com>
To:	Greg KH <greg@...ah.com>
Cc:	linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 14/22] staging: usbip: userspace: usbip list: edit output messages

Edit dbg and normal output messages for consistency and better
feedback.

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

diff --git a/drivers/staging/usbip/userspace/src/usbip_list.c b/drivers/staging/usbip/userspace/src/usbip_list.c
index 03f6210..afff469 100644
--- a/drivers/staging/usbip/userspace/src/usbip_list.c
+++ b/drivers/staging/usbip/userspace/src/usbip_list.c
@@ -49,7 +49,7 @@ static int get_exported_devices(int sockfd)
 {
 	char product_name[100];
 	char class_name[100];
-	struct op_devlist_reply rep;
+	struct op_devlist_reply reply;
 	uint16_t code = OP_REP_DEVLIST;
 	struct usbip_usb_device udev;
 	struct usbip_usb_interface uintf;
@@ -58,30 +58,30 @@ static int get_exported_devices(int sockfd)
 
 	rc = usbip_send_op_common(sockfd, OP_REQ_DEVLIST, 0);
 	if (rc < 0) {
-		dbg("usbip_send_op_common");
+		dbg("usbip_send_op_common failed");
 		return -1;
 	}
 
 	rc = usbip_recv_op_common(sockfd, &code);
 	if (rc < 0) {
-		dbg("usbip_recv_op_common");
+		dbg("usbip_recv_op_common failed");
 		return -1;
 	}
 
-	memset(&rep, 0, sizeof(rep));
-	rc = usbip_recv(sockfd, &rep, sizeof(rep));
+	memset(&reply, 0, sizeof(reply));
+	rc = usbip_recv(sockfd, &reply, sizeof(reply));
 	if (rc < 0) {
-		dbg("usbip_recv_op_devlist");
+		dbg("usbip_recv_op_devlist failed");
 		return -1;
 	}
-	PACK_OP_DEVLIST_REPLY(0, &rep);
-	dbg("exportable devices: %d", rep.ndev);
+	PACK_OP_DEVLIST_REPLY(0, &reply);
+	dbg("exportable devices: %d\n", reply.ndev);
 
-	for (i = 0; i < rep.ndev; i++) {
+	for (i = 0; i < reply.ndev; i++) {
 		memset(&udev, 0, sizeof(udev));
 		rc = usbip_recv(sockfd, &udev, sizeof(udev));
 		if (rc < 0) {
-			dbg("usbip_recv: usbip_usb_device[%d]", i);
+			dbg("usbip_recv failed: usbip_usb_device[%d]", i);
 			return -1;
 		}
 		pack_usb_device(0, &udev);
@@ -98,7 +98,7 @@ static int get_exported_devices(int sockfd)
 		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);
+				dbg("usbip_recv failed: usbip_usb_intf[%d]", j);
 				return -1;
 			}
 			pack_usb_interface(0, &uintf);
@@ -108,7 +108,6 @@ static int get_exported_devices(int sockfd)
 					      uintf.bInterfaceSubClass,
 					      uintf.bInterfaceProtocol);
 			printf("%8s: %2d - %s\n", "", j, class_name);
-
 		}
 		printf("\n");
 	}
@@ -123,16 +122,19 @@ static int list_exported_devices(char *host)
 
 	sockfd = usbip_net_tcp_connect(host, USBIP_PORT_STRING);
 	if (sockfd < 0) {
-		err("unable to connect to %s port %s: %s\n", host,
+		err("could not connect to %s:%s: %s", host,
 		    USBIP_PORT_STRING, gai_strerror(sockfd));
 		return -1;
 	}
-	dbg("connected to %s port %s\n", host, USBIP_PORT_STRING);
-	printf("- %s\n", host);
+	dbg("connected to %s:%s", host, USBIP_PORT_STRING);
+
+	printf("Exportable USB devices\n");
+	printf("======================\n");
+	printf(" - %s\n", host);
 
 	rc = get_exported_devices(sockfd);
 	if (rc < 0) {
-		dbg("get_exported_devices failed");
+		err("failed to get device list from %s", host);
 		return -1;
 	}
 
@@ -193,13 +195,14 @@ static int list_devices(bool parsable)
 
 	ubus = sysfs_open_bus(bus_type);
 	if (!ubus) {
-		err("sysfs_open_bus: %s", strerror(errno));
+		err("could not open %s bus: %s", bus_type, strerror(errno));
 		return -1;
 	}
 
 	devlist = sysfs_get_bus_devices(ubus);
 	if (!devlist) {
-		err("sysfs_get_bus_devices: %s", strerror(errno));
+		err("could not get %s bus devices: %s", bus_type,
+		    strerror(errno));
 		goto err_out;
 	}
 
@@ -215,8 +218,11 @@ static int list_devices(bool parsable)
 		idProduct  = sysfs_get_device_attr(dev, "idProduct");
 		bConfValue = sysfs_get_device_attr(dev, "bConfigurationValue");
 		bNumIntfs  = sysfs_get_device_attr(dev, "bNumInterfaces");
-		if (!idVendor || !idProduct || !bConfValue || !bNumIntfs)
+		if (!idVendor || !idProduct || !bConfValue || !bNumIntfs) {
+			err("problem getting device attributes: %s",
+			    strerror(errno));
 			goto err_out;
+		}
 
 		print_device(dev->bus_id, idVendor->value, idProduct->value,
 			     parsable);
@@ -225,8 +231,11 @@ static int list_devices(bool parsable)
 			snprintf(busid, sizeof(busid), "%s:%.1s.%d",
 				 dev->bus_id, bConfValue->value, i);
 			intf = sysfs_open_device(bus_type, busid);
-			if (!intf)
+			if (!intf) {
+				err("could not open device interface: %s",
+				    strerror(errno));
 				goto err_out;
+			}
 			print_interface(busid, intf->driver_name, parsable);
 			sysfs_close_device(intf);
 		}
@@ -244,11 +253,12 @@ err_out:
 int usbip_list(int argc, char *argv[])
 {
 	static const struct option opts[] = {
-		{ "parsable", no_argument, NULL, 'p' },
-		{ "remote", required_argument, NULL, 'r' },
-		{ "local", no_argument, NULL, 'l' },
-		{ NULL, 0, NULL, 0 }
+		{ "parsable", no_argument,       NULL, 'p' },
+		{ "remote",   required_argument, NULL, 'r' },
+		{ "local",    no_argument,       NULL, 'l' },
+		{ NULL,       0,                 NULL,  0  }
 	};
+
 	bool parsable = false;
 	int opt;
 	int ret = -1;
-- 
1.7.5.2

--
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