[PATCH v5 10/11] usbip: added const qualifier to arguments of some functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds 'const' qualifier to 'char*' arguments of library 
interfaces to make acceptable std::string.c_str(). Essentially, these 
qualifiers are better to be used even if not to use C++. Although, I 
just added to functions related to previous patch.

Also, it changes C++ reserved words (ie. new and class) in list.h.

Signed-off-by: Nobuo Iwata <nobuo.iwata@xxxxxxxxxxxxxxx>
---
 tools/usb/usbip/libsrc/list.h              | 24 ++++++++++++----------
 tools/usb/usbip/libsrc/names.c             | 15 +++++++-------
 tools/usb/usbip/libsrc/usbip_common.c      | 16 +++++++--------
 tools/usb/usbip/libsrc/usbip_common.h      |  6 +++---
 tools/usb/usbip/libsrc/usbip_host_driver.c | 10 +++++----
 tools/usb/usbip/libsrc/usbip_host_driver.h |  2 +-
 tools/usb/usbip/libsrc/vhci_driver.c       | 11 ++++++----
 tools/usb/usbip/libsrc/vhci_driver.h       |  6 ++++--
 tools/usb/usbip/src/usbip.h                | 16 ++++++++-------
 tools/usb/usbip/src/usbip_attach.c         |  4 ++--
 tools/usb/usbip/src/usbip_bind.c           |  6 +++---
 tools/usb/usbip/src/usbip_connect.c        |  4 ++--
 tools/usb/usbip/src/usbip_detach.c         |  2 +-
 tools/usb/usbip/src/usbip_disconnect.c     |  5 +++--
 tools/usb/usbip/src/usbip_list.c           |  7 +++----
 tools/usb/usbip/src/usbip_netconn.c        |  2 +-
 tools/usb/usbip/src/usbip_network.c        | 12 +++++++----
 tools/usb/usbip/src/usbip_unbind.c         |  2 +-
 tools/usb/usbip/src/usbipd.c               |  4 ++--
 tools/usb/usbip/src/usbipd.h               |  2 +-
 tools/usb/usbip/src/usbipd_app.c           |  9 ++++----
 tools/usb/usbip/src/usbipd_dev.c           |  2 +-
 tools/usb/usbip/src/utils.c                |  2 +-
 tools/usb/usbip/src/utils.h                |  2 +-
 24 files changed, 94 insertions(+), 77 deletions(-)

diff --git a/tools/usb/usbip/libsrc/list.h b/tools/usb/usbip/libsrc/list.h
index 5eaaa78..b46a98f 100644
--- a/tools/usb/usbip/libsrc/list.h
+++ b/tools/usb/usbip/libsrc/list.h
@@ -36,14 +36,14 @@ static inline void INIT_LIST_HEAD(struct list_head *list)
  * This is only for internal list manipulation where we know
  * the prev/next entries already!
  */
-static inline void __list_add(struct list_head *new,
+static inline void __list_add(struct list_head *neo,
 			      struct list_head *prev,
 			      struct list_head *next)
 {
-	next->prev = new;
-	new->next = next;
-	new->prev = prev;
-	prev->next = new;
+	next->prev = neo;
+	neo->next = next;
+	neo->prev = prev;
+	prev->next = neo;
 }
 
 /**
@@ -54,9 +54,9 @@ static inline void __list_add(struct list_head *new,
  * Insert a new entry after the specified head.
  * This is good for implementing stacks.
  */
-static inline void list_add(struct list_head *new, struct list_head *head)
+static inline void list_add(struct list_head *neo, struct list_head *head)
 {
-	__list_add(new, head, head->next);
+	__list_add(neo, head, head->next);
 }
 
 /*
@@ -73,8 +73,8 @@ static inline void __list_del(struct list_head * prev, struct list_head * next)
 }
 
 #define POISON_POINTER_DELTA 0
-#define LIST_POISON1  ((void *) 0x00100100 + POISON_POINTER_DELTA)
-#define LIST_POISON2  ((void *) 0x00200200 + POISON_POINTER_DELTA)
+#define LIST_POISON1  ((char *) 0x00100100 + POISON_POINTER_DELTA)
+#define LIST_POISON2  ((char *) 0x00200200 + POISON_POINTER_DELTA)
 
 /**
  * list_del - deletes entry from list.
@@ -90,8 +90,8 @@ static inline void __list_del_entry(struct list_head *entry)
 static inline void list_del(struct list_head *entry)
 {
 	__list_del(entry->prev, entry->next);
-	entry->next = LIST_POISON1;
-	entry->prev = LIST_POISON2;
+	entry->next = (struct list_head *)LIST_POISON1;
+	entry->prev = (struct list_head *)LIST_POISON2;
 }
 
 /**
@@ -120,7 +120,9 @@ static inline void list_del(struct list_head *entry)
 	for (pos = (head)->next, n = pos->next; pos != (head); \
 		pos = n, n = pos->next)
 
+#ifndef offsetof
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
 
 /**
  * container_of - cast a member of a structure out to the containing structure
diff --git a/tools/usb/usbip/libsrc/names.c b/tools/usb/usbip/libsrc/names.c
index 7d65d28..656005f 100644
--- a/tools/usb/usbip/libsrc/names.c
+++ b/tools/usb/usbip/libsrc/names.c
@@ -23,6 +23,8 @@
  *
  *	Copyright (C) 2005 Takahiro Hirofuchi
  *		- names_deinit() is added.
+ *	Copyright (C) 2015 Nobuo Iwata
+ *		- some modifications for portability.
  *
  */
 
@@ -38,7 +40,6 @@
 #include <ctype.h>
 
 #include "names.h"
-#include "usbip_common.h"
 
 struct vendor {
 	struct vendor *next;
@@ -52,8 +53,8 @@ struct product {
 	char name[1];
 };
 
-struct class {
-	struct class *next;
+struct clazz {
+	struct clazz *next;
 	u_int8_t classid;
 	char name[1];
 };
@@ -94,7 +95,7 @@ static unsigned int hashnum(unsigned int num)
 
 static struct vendor *vendors[HASHSZ] = { NULL, };
 static struct product *products[HASHSZ] = { NULL, };
-static struct class *classes[HASHSZ] = { NULL, };
+static struct clazz *classes[HASHSZ] = { NULL, };
 static struct subclass *subclasses[HASHSZ] = { NULL, };
 static struct protocol *protocols[HASHSZ] = { NULL, };
 
@@ -122,7 +123,7 @@ const char *names_product(u_int16_t vendorid, u_int16_t productid)
 
 const char *names_class(u_int8_t classid)
 {
-	struct class *c;
+	struct clazz *c;
 
 	c = classes[hashnum(classid)];
 	for (; c; c = c->next)
@@ -247,14 +248,14 @@ static int new_product(const char *name, u_int16_t vendorid,
 
 static int new_class(const char *name, u_int8_t classid)
 {
-	struct class *c;
+	struct clazz *c;
 	unsigned int h = hashnum(classid);
 
 	c = classes[h];
 	for (; c; c = c->next)
 		if (c->classid == classid)
 			return -1;
-	c = my_malloc(sizeof(struct class) + strlen(name));
+	c = my_malloc(sizeof(struct clazz) + strlen(name));
 	if (!c)
 		return -1;
 	strcpy(c->name, name);
diff --git a/tools/usb/usbip/libsrc/usbip_common.c b/tools/usb/usbip/libsrc/usbip_common.c
index 54efa10..bf577b7 100644
--- a/tools/usb/usbip/libsrc/usbip_common.c
+++ b/tools/usb/usbip/libsrc/usbip_common.c
@@ -260,29 +260,29 @@ void usbip_names_get_product(char *buff, size_t size, uint16_t vendor,
 	snprintf(buff, size, "%s : %s (%04x:%04x)", vend, prod, vendor, product);
 }
 
-void usbip_names_get_class(char *buff, size_t size, uint8_t class,
+void usbip_names_get_class(char *buff, size_t size, uint8_t clazz,
 			   uint8_t subclass, uint8_t protocol)
 {
 	const char *c, *s, *p;
 
-	if (class == 0 && subclass == 0 && protocol == 0) {
-		snprintf(buff, size, "(Defined at Interface level) (%02x/%02x/%02x)", class, subclass, protocol);
+	if (clazz == 0 && subclass == 0 && protocol == 0) {
+		snprintf(buff, size, "(Defined at Interface level) (%02x/%02x/%02x)", clazz, subclass, protocol);
 		return;
 	}
 
-	p = names_protocol(class, subclass, protocol);
+	p = names_protocol(clazz, subclass, protocol);
 	if (!p)
 		p = "unknown protocol";
 
-	s = names_subclass(class, subclass);
+	s = names_subclass(clazz, subclass);
 	if (!s)
 		s = "unknown subclass";
 
-	c = names_class(class);
+	c = names_class(clazz);
 	if (!c)
 		c = "unknown class";
 
-	snprintf(buff, size, "%s / %s / %s (%02x/%02x/%02x)", c, s, p, class, subclass, protocol);
+	snprintf(buff, size, "%s / %s / %s (%02x/%02x/%02x)", c, s, p, clazz, subclass, protocol);
 }
 
 void usbip_sock_init(usbip_sock_t *sock, int fd, void *arg,
@@ -300,7 +300,7 @@ void usbip_sock_init(usbip_sock_t *sock, int fd, void *arg,
 usbip_connection_operations_t usbip_conn_ops = {NULL, NULL};
 
 void usbip_conn_init(
-	usbip_sock_t *(*open)(char *host, char *port),
+	usbip_sock_t *(*open)(const char *host, const char *port),
 	void (*close)(usbip_sock_t *sock))
 {
 	usbip_conn_ops.open = open;
diff --git a/tools/usb/usbip/libsrc/usbip_common.h b/tools/usb/usbip/libsrc/usbip_common.h
index 07c411f..e7cfa29 100644
--- a/tools/usb/usbip/libsrc/usbip_common.h
+++ b/tools/usb/usbip/libsrc/usbip_common.h
@@ -132,7 +132,7 @@ int usbip_names_init(char *);
 void usbip_names_free(void);
 void usbip_names_get_product(char *buff, size_t size, uint16_t vendor,
 			     uint16_t product);
-void usbip_names_get_class(char *buff, size_t size, uint8_t class,
+void usbip_names_get_class(char *buff, size_t size, uint8_t clazz,
 			   uint8_t subclass, uint8_t protocol);
 
 typedef struct usbip_sock {
@@ -149,14 +149,14 @@ void usbip_sock_init(usbip_sock_t *sock, int fd, void *arg,
 	void (*shutdown)(void *arg));
 
 typedef struct usbip_connection_operations {
-	usbip_sock_t *(*open)(char *host, char *port);
+	usbip_sock_t *(*open)(const char *host, const char *port);
 	void (*close)(usbip_sock_t *sock);
 } usbip_connection_operations_t;
 
 extern usbip_connection_operations_t usbip_conn_ops;
 
 void usbip_conn_init(
-	usbip_sock_t *(*open)(char *host, char *port),
+	usbip_sock_t *(*open)(const char *host, const char *port),
 	void (*close)(usbip_sock_t *sock));
 
 #endif /* __USBIP_COMMON_H */
diff --git a/tools/usb/usbip/libsrc/usbip_host_driver.c b/tools/usb/usbip/libsrc/usbip_host_driver.c
index de5541a..bf29a04 100644
--- a/tools/usb/usbip/libsrc/usbip_host_driver.c
+++ b/tools/usb/usbip/libsrc/usbip_host_driver.c
@@ -73,7 +73,8 @@ struct usbip_exported_device *usbip_exported_device_new(const char *sdevpath)
 	size_t size;
 	int i;
 
-	edev = calloc(1, sizeof(struct usbip_exported_device));
+	edev = (struct usbip_exported_device *)
+		calloc(1, sizeof(struct usbip_exported_device));
 
 	edev->sudev = udev_device_new_from_syspath(udev_context, sdevpath);
 	if (!edev->sudev) {
@@ -92,7 +93,7 @@ struct usbip_exported_device *usbip_exported_device_new(const char *sdevpath)
 		edev->udev.bNumInterfaces * sizeof(struct usbip_usb_interface);
 
 	edev_old = edev;
-	edev = realloc(edev, size);
+	edev = (struct usbip_exported_device *)realloc(edev, size);
 	if (!edev) {
 		edev = edev_old;
 		dbg("realloc failed");
@@ -172,7 +173,8 @@ int usbip_host_driver_open(void)
 		return -1;
 	}
 
-	host_driver = calloc(1, sizeof(*host_driver));
+	host_driver = (struct usbip_host_driver *)
+			calloc(1, sizeof(*host_driver));
 
 	host_driver->ndevs = 0;
 	INIT_LIST_HEAD(&host_driver->edev_list);
@@ -279,7 +281,7 @@ struct usbip_exported_device *usbip_host_get_device(int num)
 	return NULL;
 }
 
-struct usbip_exported_device *usbip_host_find_device(char *busid)
+struct usbip_exported_device *usbip_host_find_device(const char *busid)
 {
 	struct list_head *i;
 	struct usbip_exported_device *edev;
diff --git a/tools/usb/usbip/libsrc/usbip_host_driver.h b/tools/usb/usbip/libsrc/usbip_host_driver.h
index 69c65a6..7963974 100644
--- a/tools/usb/usbip/libsrc/usbip_host_driver.h
+++ b/tools/usb/usbip/libsrc/usbip_host_driver.h
@@ -45,6 +45,6 @@ void usbip_host_driver_close(void);
 int usbip_host_refresh_device_list(void);
 int usbip_host_export_device(struct usbip_exported_device *edev, int sockfd);
 struct usbip_exported_device *usbip_host_get_device(int num);
-struct usbip_exported_device *usbip_host_find_device(char *busid);
+struct usbip_exported_device *usbip_host_find_device(const char *busid);
 
 #endif /* __USBIP_HOST_DRIVER_H */
diff --git a/tools/usb/usbip/libsrc/vhci_driver.c b/tools/usb/usbip/libsrc/vhci_driver.c
index a390047..b0d3c18 100644
--- a/tools/usb/usbip/libsrc/vhci_driver.c
+++ b/tools/usb/usbip/libsrc/vhci_driver.c
@@ -175,7 +175,7 @@ static int read_record(int rhport, char *host, unsigned long host_len,
 	int max_len[] = {(int)host_len, (int)port_len, SYSFS_BUS_ID_SIZE};
 	size_t buffer_len = host_len + port_len + SYSFS_BUS_ID_SIZE + 4;
 
-	buffer = malloc(buffer_len);
+	buffer = (char*)malloc(buffer_len);
 	if (!buffer)
 		return -1;
 
@@ -248,7 +248,8 @@ int usbip_vhci_driver_open(void)
 		return -1;
 	}
 
-	vhci_driver = calloc(1, sizeof(struct usbip_vhci_driver));
+	vhci_driver = (struct usbip_vhci_driver *)
+			calloc(1, sizeof(struct usbip_vhci_driver));
 
 	if (open_hc_device(OPEN_HC_MODE_FIRST)) {
 		goto err_free_driver;
@@ -325,7 +326,8 @@ struct usbip_imported_device *usbip_vhci_get_device(int port)
 	return NULL;
 }
 
-struct usbip_imported_device *usbip_vhci_find_device(char *host, char *busid)
+struct usbip_imported_device *usbip_vhci_find_device(
+				const char *host, const char *busid)
 {
 	int ret;
 	char rhost[NI_MAXHOST] = "unknown host";
@@ -457,7 +459,8 @@ int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev)
 }
 
 #define MAX_BUFF 100
-int usbip_vhci_create_record(char *host, char *port, char *busid, int rhport)
+int usbip_vhci_create_record(const char *host, const char *port,
+			     const char *busid, int rhport)
 {
 	int fd;
 	char path[PATH_MAX+1];
diff --git a/tools/usb/usbip/libsrc/vhci_driver.h b/tools/usb/usbip/libsrc/vhci_driver.h
index 2a9e9c1..a8ff4e8 100644
--- a/tools/usb/usbip/libsrc/vhci_driver.h
+++ b/tools/usb/usbip/libsrc/vhci_driver.h
@@ -47,7 +47,8 @@ int  usbip_vhci_refresh_device_list(void);
 
 int usbip_vhci_get_free_port(void);
 struct usbip_imported_device *usbip_vhci_get_device(int port);
-struct usbip_imported_device *usbip_vhci_find_device(char *host, char *busid);
+struct usbip_imported_device *usbip_vhci_find_device(
+                const char *host, const char *busid);
 int usbip_vhci_attach_device2(uint8_t port, int sockfd, uint32_t devid,
 		uint32_t speed);
 
@@ -57,7 +58,8 @@ int usbip_vhci_attach_device(uint8_t port, int sockfd, uint8_t busnum,
 
 int usbip_vhci_detach_device(uint8_t port);
 
-int usbip_vhci_create_record(char *host, char *port, char *busid, int rhport);
+int usbip_vhci_create_record(const char *host, const char *port,
+		const char *busid, int rhport);
 int usbip_vhci_delete_record(int rhport);
 
 int usbip_vhci_imported_device_dump(struct usbip_imported_device *idev);
diff --git a/tools/usb/usbip/src/usbip.h b/tools/usb/usbip/src/usbip.h
index 1d642cc..3df2da1 100644
--- a/tools/usb/usbip/src/usbip.h
+++ b/tools/usb/usbip/src/usbip.h
@@ -34,15 +34,17 @@ int usbip_port_show(int argc, char *argv[]);
 int usbip_connect(int argc, char *argv[]);
 int usbip_disconnect(int argc, char *argv[]);
 
-int usbip_attach_device(char *host, char *port, char *busid);
-int usbip_detach_port(char *port);
-int usbip_bind_device(char *busid);
-int usbip_unbind_device(char *busid);
+int usbip_attach_device(const char *host, const char *port, const char *busid);
+int usbip_detach_port(const char *port);
+int usbip_bind_device(const char *busid);
+int usbip_unbind_device(const char *busid);
 int usbip_list_imported_devices(void);
-int usbip_list_importable_devices(char *host, char *port);
+int usbip_list_importable_devices(const char *host, const char *port);
 int usbip_list_devices(int parsable);
-int usbip_connect_device(char *host, char *port, char *busid);
-int usbip_disconnect_device(char *host, char *port, char *busid);
+int usbip_connect_device(const char *host, const char *port,
+			const char *busid);
+int usbip_disconnect_device(const char *host, const char *port,
+			const char *busid);
 
 void usbip_attach_usage(void);
 void usbip_detach_usage(void);
diff --git a/tools/usb/usbip/src/usbip_attach.c b/tools/usb/usbip/src/usbip_attach.c
index aa09b5d..9d242ab 100644
--- a/tools/usb/usbip/src/usbip_attach.c
+++ b/tools/usb/usbip/src/usbip_attach.c
@@ -80,7 +80,7 @@ static int import_device(usbip_sock_t *sock, struct usbip_usb_device *udev)
 	return port;
 }
 
-static int query_import_device(usbip_sock_t *sock, char *busid)
+static int query_import_device(usbip_sock_t *sock, const char *busid)
 {
 	int rc;
 	struct op_import_request request;
@@ -132,7 +132,7 @@ static int query_import_device(usbip_sock_t *sock, char *busid)
 	return import_device(sock, &reply.udev);
 }
 
-int usbip_attach_device(char *host, char *port, char *busid)
+int usbip_attach_device(const char *host, const char *port, const char *busid)
 {
 	usbip_sock_t *sock;
 	usbip_ux_t *ux;
diff --git a/tools/usb/usbip/src/usbip_bind.c b/tools/usb/usbip/src/usbip_bind.c
index 3b58dbb..4df662c 100644
--- a/tools/usb/usbip/src/usbip_bind.c
+++ b/tools/usb/usbip/src/usbip_bind.c
@@ -52,7 +52,7 @@ void usbip_bind_usage(void)
 #endif
 
 /* call at unbound state */
-static int bind_usbip(char *busid)
+static int bind_usbip(const char *busid)
 {
 	char attr_name[] = "bind";
 	char bind_attr_path[SYSFS_PATH_MAX];
@@ -73,7 +73,7 @@ static int bind_usbip(char *busid)
 }
 
 /* buggy driver may cause dead lock */
-static int unbind_other(char *busid)
+static int unbind_other(const char *busid)
 {
 	enum unbind_status status = UNBIND_ST_OK;
 
@@ -144,7 +144,7 @@ out:
 	return status;
 }
 
-int usbip_bind_device(char *busid)
+int usbip_bind_device(const char *busid)
 {
 	int rc;
 	struct udev *udev;
diff --git a/tools/usb/usbip/src/usbip_connect.c b/tools/usb/usbip/src/usbip_connect.c
index f627c70..63adbdf 100644
--- a/tools/usb/usbip/src/usbip_connect.c
+++ b/tools/usb/usbip/src/usbip_connect.c
@@ -98,7 +98,7 @@ static int send_export_device(usbip_sock_t *sock, struct usbip_usb_device *udev)
 	return 0;
 }
 
-static int export_device(char *busid, usbip_sock_t *sock)
+static int export_device(const char *busid, usbip_sock_t *sock)
 {
 	int rc;
 	struct usbip_exported_device *edev;
@@ -142,7 +142,7 @@ static int export_device(char *busid, usbip_sock_t *sock)
 	return 0;
 }
 
-int usbip_connect_device(char *host, char *port, char *busid)
+int usbip_connect_device(const char *host, const char *port, const char *busid)
 {
 	usbip_sock_t *sock;
 	usbip_ux_t *ux;
diff --git a/tools/usb/usbip/src/usbip_detach.c b/tools/usb/usbip/src/usbip_detach.c
index 7784edf..63d0107 100644
--- a/tools/usb/usbip/src/usbip_detach.c
+++ b/tools/usb/usbip/src/usbip_detach.c
@@ -46,7 +46,7 @@ void usbip_detach_usage(void)
 }
 #endif
 
-int usbip_detach_port(char *port)
+int usbip_detach_port(const char *port)
 {
 	int ret;
 	uint8_t portnum;
diff --git a/tools/usb/usbip/src/usbip_disconnect.c b/tools/usb/usbip/src/usbip_disconnect.c
index 3f50018..3acf136 100644
--- a/tools/usb/usbip/src/usbip_disconnect.c
+++ b/tools/usb/usbip/src/usbip_disconnect.c
@@ -98,7 +98,7 @@ static int send_unexport_device(usbip_sock_t *sock, struct usbip_usb_device *ude
 	return 0;
 }
 
-static int unexport_device(char *busid, usbip_sock_t *sock)
+static int unexport_device(const char *busid, usbip_sock_t *sock)
 {
 	int rc;
 	struct usbip_exported_device *edev;
@@ -135,7 +135,8 @@ static int unexport_device(char *busid, usbip_sock_t *sock)
 	return 0;
 }
 
-int usbip_disconnect_device(char *host, char *port, char *busid)
+int usbip_disconnect_device(const char *host, const char *port,
+			    const char *busid)
 {
 	usbip_sock_t *sock;
 	int rc;
diff --git a/tools/usb/usbip/src/usbip_list.c b/tools/usb/usbip/src/usbip_list.c
index a197bbe..3620f77 100644
--- a/tools/usb/usbip/src/usbip_list.c
+++ b/tools/usb/usbip/src/usbip_list.c
@@ -48,7 +48,7 @@ void usbip_list_usage(void)
 }
 #endif
 
-static int get_importable_devices(char *host, usbip_sock_t *sock)
+static int get_importable_devices(const char *host, usbip_sock_t *sock)
 {
 	char product_name[100];
 	char class_name[100];
@@ -130,7 +130,7 @@ static int get_importable_devices(char *host, usbip_sock_t *sock)
 	return 0;
 }
 
-int usbip_list_importable_devices(char *host, char* port)
+int usbip_list_importable_devices(const char *host, const char *port)
 {
 	int rc;
 	usbip_sock_t *sock;
@@ -156,7 +156,6 @@ int usbip_list_importable_devices(char *host, char* port)
 	usbip_names_free();
 
 	return 0;
-
 err_conn_close:
 	usbip_conn_ops.close(sock);
 err_names_free:
@@ -173,7 +172,7 @@ static void print_device(const char *busid, const char *vendor,
 		printf(" - busid %s (%.4s:%.4s)\n", busid, vendor, product);
 }
 
-static void print_product_name(char *product_name, int parsable)
+static void print_product_name(const char *product_name, int parsable)
 {
 	if (!parsable)
 		printf("   %s\n", product_name);
diff --git a/tools/usb/usbip/src/usbip_netconn.c b/tools/usb/usbip/src/usbip_netconn.c
index 339df59..bf5b98e 100644
--- a/tools/usb/usbip/src/usbip_netconn.c
+++ b/tools/usb/usbip/src/usbip_netconn.c
@@ -32,7 +32,7 @@
 /*
  * IPv6 Ready
  */
-static usbip_sock_t *net_tcp_open(char *hostname, char *service)
+static usbip_sock_t *net_tcp_open(const char *hostname, const char *service)
 {
 	struct addrinfo hints, *res, *rp;
 	int sockfd;
diff --git a/tools/usb/usbip/src/usbip_network.c b/tools/usb/usbip/src/usbip_network.c
index beb34ae..a730fe4 100644
--- a/tools/usb/usbip/src/usbip_network.c
+++ b/tools/usb/usbip/src/usbip_network.c
@@ -222,7 +222,8 @@ int usbip_net_set_reuseaddr(int sockfd)
 	const int val = 1;
 	int ret;
 
-	ret = setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
+	ret = setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR,
+			 (const void*)&val, sizeof(val));
 	if (ret < 0)
 		dbg("setsockopt: SO_REUSEADDR");
 
@@ -234,7 +235,8 @@ int usbip_net_set_nodelay(int sockfd)
 	const int val = 1;
 	int ret;
 
-	ret = setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof(val));
+	ret = setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY,
+			 (const void*)&val, sizeof(val));
 	if (ret < 0)
 		dbg("setsockopt: TCP_NODELAY");
 
@@ -246,7 +248,8 @@ int usbip_net_set_keepalive(int sockfd)
 	const int val = 1;
 	int ret;
 
-	ret = setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &val, sizeof(val));
+	ret = setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE,
+			 (const void*)&val, sizeof(val));
 	if (ret < 0)
 		dbg("setsockopt: SO_KEEPALIVE");
 
@@ -258,7 +261,8 @@ int usbip_net_set_v6only(int sockfd)
 	const int val = 1;
 	int ret;
 
-	ret = setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY, &val, sizeof(val));
+	ret = setsockopt(sockfd, IPPROTO_IPV6, IPV6_V6ONLY,
+			 (const void*)&val, sizeof(val));
 	if (ret < 0)
 		dbg("setsockopt: IPV6_V6ONLY");
 
diff --git a/tools/usb/usbip/src/usbip_unbind.c b/tools/usb/usbip/src/usbip_unbind.c
index 4edd458..9f88311 100644
--- a/tools/usb/usbip/src/usbip_unbind.c
+++ b/tools/usb/usbip/src/usbip_unbind.c
@@ -44,7 +44,7 @@ void usbip_unbind_usage(void)
 }
 #endif
 
-int usbip_unbind_device(char *busid)
+int usbip_unbind_device(const char *busid)
 {
 	char bus_type[] = "usb";
 	int rc, ret = -1;
diff --git a/tools/usb/usbip/src/usbipd.c b/tools/usb/usbip/src/usbipd.c
index 98fbf17..6113a9f 100644
--- a/tools/usb/usbip/src/usbipd.c
+++ b/tools/usb/usbip/src/usbipd.c
@@ -229,7 +229,7 @@ static int listen_all_addrinfo(struct addrinfo *ai_head, int sockfdlist[],
 	return nsockfd;
 }
 
-static struct addrinfo *do_getaddrinfo(char *host, int ai_family)
+static struct addrinfo *do_getaddrinfo(const char *host, int ai_family)
 {
 	struct addrinfo hints, *ai_head;
 	int rc;
@@ -353,7 +353,7 @@ static int do_standalone_mode(int daemonize, int ipv4, int ipv6)
 
 	dbg("listening on %d address%s", nsockfd, (nsockfd == 1) ? "" : "es");
 
-	fds = calloc(nsockfd, sizeof(struct pollfd));
+	fds = (struct pollfd *)calloc(nsockfd, sizeof(struct pollfd));
 	for (i = 0; i < nsockfd; i++) {
 		fds[i].fd = sockfdlist[i];
 		fds[i].events = POLLIN;
diff --git a/tools/usb/usbip/src/usbipd.h b/tools/usb/usbip/src/usbipd.h
index d9ab8fa..04a533d 100644
--- a/tools/usb/usbip/src/usbipd.h
+++ b/tools/usb/usbip/src/usbipd.h
@@ -30,7 +30,7 @@
 extern char *usbip_progname;
 extern char *usbip_default_pid_file;
 
-int usbip_recv_pdu(usbip_sock_t *sock, char *host, char *port);
+int usbip_recv_pdu(usbip_sock_t *sock, const char *host, const char *port);
 inline void usbip_break_connections(void) { usbip_ux_interrupt_pgrp(); }
 int usbip_driver_open(void);
 void usbip_driver_close(void);
diff --git a/tools/usb/usbip/src/usbipd_app.c b/tools/usb/usbip/src/usbipd_app.c
index 536987b..06bcb10 100644
--- a/tools/usb/usbip/src/usbipd_app.c
+++ b/tools/usb/usbip/src/usbipd_app.c
@@ -76,7 +76,8 @@ static int import_device(usbip_sock_t *sock, struct usbip_usb_device *udev)
 	return port;
 }
 
-static int recv_request_export(usbip_sock_t *sock, char *host, char *port)
+static int recv_request_export(usbip_sock_t *sock,
+			       const char *host, const char *port)
 {
 	struct op_export_request req;
 	struct op_export_reply reply;
@@ -144,7 +145,7 @@ static int recv_request_export(usbip_sock_t *sock, char *host, char *port)
 	return 0;
 }
 
-static int unimport_device(char *host, struct usbip_usb_device *udev)
+static int unimport_device(const char *host, struct usbip_usb_device *udev)
 {
 	int rc;
 	struct usbip_imported_device *idev;
@@ -163,7 +164,7 @@ static int unimport_device(char *host, struct usbip_usb_device *udev)
 	return idev->port;
 }
 
-static int recv_request_unexport(usbip_sock_t *sock, char *host)
+static int recv_request_unexport(usbip_sock_t *sock, const char *host)
 {
 	struct op_unexport_request req;
 	struct op_unexport_reply reply;
@@ -215,7 +216,7 @@ static int recv_request_unexport(usbip_sock_t *sock, char *host)
 	return 0;
 }
 
-int usbip_recv_pdu(usbip_sock_t *sock, char *host, char *port)
+int usbip_recv_pdu(usbip_sock_t *sock, const char *host, const char *port)
 {
 	uint16_t code = OP_UNSPEC;
 	int ret;
diff --git a/tools/usb/usbip/src/usbipd_dev.c b/tools/usb/usbip/src/usbipd_dev.c
index 0a50485..4ab396d 100644
--- a/tools/usb/usbip/src/usbipd_dev.c
+++ b/tools/usb/usbip/src/usbipd_dev.c
@@ -224,7 +224,7 @@ static int recv_request_devlist(usbip_sock_t *sock)
 	return 0;
 }
 
-int usbip_recv_pdu(usbip_sock_t *sock, char *host, char *port)
+int usbip_recv_pdu(usbip_sock_t *sock, const char *host, const char *port)
 {
 	uint16_t code = OP_UNSPEC;
 	int ret;
diff --git a/tools/usb/usbip/src/utils.c b/tools/usb/usbip/src/utils.c
index 2b3d6d2..861be15 100644
--- a/tools/usb/usbip/src/utils.c
+++ b/tools/usb/usbip/src/utils.c
@@ -24,7 +24,7 @@
 #include "utils.h"
 #include "sysfs_utils.h"
 
-int modify_match_busid(char *busid, int add)
+int modify_match_busid(const char *busid, int add)
 {
 	char attr_name[] = "match_busid";
 	char command[SYSFS_BUS_ID_SIZE + 4];
diff --git a/tools/usb/usbip/src/utils.h b/tools/usb/usbip/src/utils.h
index 5916fd3..ecd2fe3 100644
--- a/tools/usb/usbip/src/utils.h
+++ b/tools/usb/usbip/src/utils.h
@@ -19,7 +19,7 @@
 #ifndef __UTILS_H
 #define __UTILS_H
 
-int modify_match_busid(char *busid, int add);
+int modify_match_busid(const char *busid, int add);
 
 #endif /* __UTILS_H */
 
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux