|
1 Fix unnecessary free(), active config value and descriptor, and identifier. |
|
2 |
|
3 --- libusb-1.0.20/libusb/os/sunos_usb.h 2016-04-06 20:05:55.785721970 -0700 |
|
4 +++ libusb/libusb/os/sunos_usb.h 2016-04-06 20:02:21.487553309 -0700 |
|
5 @@ -1,6 +1,6 @@ |
|
6 /* |
|
7 * |
|
8 - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
|
9 + * Copyright (c) 2016, Oracle and/or its affiliates. |
|
10 * |
|
11 * This library is free software; you can redistribute it and/or |
|
12 * modify it under the terms of the GNU Lesser General Public |
|
13 @@ -17,8 +17,8 @@ |
|
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
15 */ |
|
16 |
|
17 -#ifndef __SUNOS_H__ |
|
18 -#define __SUNOS_H__ |
|
19 +#ifndef LIBUSB_SUNOS_H |
|
20 +#define LIBUSB_SUNOS_H |
|
21 |
|
22 #include <libdevinfo.h> |
|
23 #include <pthread.h> |
|
24 @@ -71,4 +71,4 @@ |
|
25 struct aiocb aiocb; |
|
26 }; |
|
27 |
|
28 -#endif /* __SUNOS_H__ */ |
|
29 +#endif /* LIBUSB_SUNOS_H */ |
|
30 --- libusb-1.0.20/libusb/os/sunos_usb.c 2016-04-06 20:05:55.785428005 -0700 |
|
31 +++ libusb/libusb/os/sunos_usb.c 2016-04-06 20:02:21.487451492 -0700 |
|
32 @@ -1,6 +1,6 @@ |
|
33 /* |
|
34 * |
|
35 - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
|
36 + * Copyright (c) 2016, Oracle and/or its affiliates. |
|
37 * |
|
38 * This library is free software; you can redistribute it and/or |
|
39 * modify it under the terms of the GNU Lesser General Public |
|
40 @@ -122,6 +122,8 @@ |
|
41 return (LIBUSB_ERROR_NO_MEM); |
|
42 } else { |
|
43 bcopy(rdata, dpriv->raw_cfgdescr, proplen); |
|
44 + dpriv->cfgvalue = ((struct libusb_config_descriptor *) |
|
45 + rdata)->bConfigurationValue; |
|
46 } |
|
47 |
|
48 n = di_prop_lookup_ints(DDI_DEV_T_ANY, node, "reg", &port_prop); |
|
49 @@ -651,12 +653,40 @@ |
|
50 { |
|
51 sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)dev->os_priv; |
|
52 struct libusb_config_descriptor *cfg; |
|
53 + int proplen; |
|
54 + di_node_t node; |
|
55 + uint8_t *rdata; |
|
56 + |
|
57 + /* |
|
58 + * Keep raw configuration descriptors updated, in case config |
|
59 + * has ever been changed through setCfg. |
|
60 + */ |
|
61 + if ((node = di_init(dpriv->phypath, DINFOCPYALL)) == DI_NODE_NIL) { |
|
62 + usbi_dbg("di_int() failed: %s", strerror(errno)); |
|
63 + return (LIBUSB_ERROR_IO); |
|
64 + } |
|
65 + proplen = di_prop_lookup_bytes(DDI_DEV_T_ANY, node, |
|
66 + "usb-raw-cfg-descriptors", &rdata); |
|
67 + if (proplen <= 0) { |
|
68 + usbi_dbg("can't find raw config descriptors"); |
|
69 + |
|
70 + return (LIBUSB_ERROR_IO); |
|
71 + } |
|
72 + dpriv->raw_cfgdescr = realloc(dpriv->raw_cfgdescr, proplen); |
|
73 + if (dpriv->raw_cfgdescr == NULL) { |
|
74 + return (LIBUSB_ERROR_NO_MEM); |
|
75 + } else { |
|
76 + bcopy(rdata, dpriv->raw_cfgdescr, proplen); |
|
77 + dpriv->cfgvalue = ((struct libusb_config_descriptor *) |
|
78 + rdata)->bConfigurationValue; |
|
79 + } |
|
80 + di_fini(node); |
|
81 |
|
82 cfg = (struct libusb_config_descriptor *)dpriv->raw_cfgdescr; |
|
83 len = MIN(len, libusb_le16_to_cpu(cfg->wTotalLength)); |
|
84 memcpy(buf, dpriv->raw_cfgdescr, len); |
|
85 *host_endian = 0; |
|
86 - usbi_dbg("len %d", len); |
|
87 + usbi_dbg("path:%s len %d", dpriv->phypath, len); |
|
88 |
|
89 return (len); |
|
90 } |
|
91 @@ -685,7 +715,10 @@ |
|
92 sunos_set_configuration(struct libusb_device_handle *handle, int config) |
|
93 { |
|
94 sunos_dev_priv_t *dpriv = (sunos_dev_priv_t *)handle->dev->os_priv; |
|
95 + sunos_dev_handle_priv_t *hpriv; |
|
96 + |
|
97 usbi_dbg("bConfigurationValue %d", config); |
|
98 + hpriv = (sunos_dev_handle_priv_t *)handle->os_priv; |
|
99 |
|
100 if (dpriv->ugenpath == NULL) |
|
101 return (LIBUSB_ERROR_NOT_SUPPORTED); |
|
102 @@ -694,6 +727,7 @@ |
|
103 return (LIBUSB_ERROR_INVALID_PARAM); |
|
104 |
|
105 dpriv->cfgvalue = config; |
|
106 + hpriv->config_index = config - 1; |
|
107 |
|
108 return (LIBUSB_SUCCESS); |
|
109 } |
|
110 @@ -797,7 +831,6 @@ |
|
111 |
|
112 /* async notification */ |
|
113 usbi_signal_transfer_completion(LIBUSB_TRANSFER_TO_USBI_TRANSFER(xfer)); |
|
114 - free(aiocb); |
|
115 } |
|
116 |
|
117 static int |