]> git.proxmox.com Git - qemu.git/blobdiff - hw/bt-sdp.c
target-sparc: Implement PDIST.
[qemu.git] / hw / bt-sdp.c
index 1d152f732ddc03ddcac553907fd8b7ad11c97b45..3e390ab5b98124b6329bfc4d2cb6cb48c2ffc81e 100644 (file)
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "qemu-common.h"
@@ -161,7 +159,7 @@ static ssize_t sdp_svc_search(struct bt_l2cap_sdp_state_s *sdp,
 
     if (len < 3)
         return -SDP_INVALID_SYNTAX;
-    end = (req[0] << 8) | req[1];
+    max = (req[0] << 8) | req[1];
     req += 2;
     len -= 2;
 
@@ -173,7 +171,7 @@ static ssize_t sdp_svc_search(struct bt_l2cap_sdp_state_s *sdp,
     } else
         start = 0;
 
-    if (len > 1);
+    if (len > 1)
         return -SDP_INVALID_SYNTAX;
 
     /* Output the results */
@@ -254,7 +252,7 @@ static ssize_t sdp_attr_get(struct bt_l2cap_sdp_state_s *sdp,
     /* Perform the search */
     if (len < 7)
         return -SDP_INVALID_SYNTAX;
-    memcpy(&handle, req, 6);
+    memcpy(&handle, req, 4);
     req += 4;
     len -= 4;
 
@@ -569,12 +567,12 @@ static void bt_l2cap_sdp_close_ch(void *opaque)
     int i;
 
     for (i = 0; i < sdp->services; i ++) {
-        qemu_free(sdp->service_list[i].attribute_list->pair);
-        qemu_free(sdp->service_list[i].attribute_list);
-        qemu_free(sdp->service_list[i].uuid);
+        g_free(sdp->service_list[i].attribute_list->pair);
+        g_free(sdp->service_list[i].attribute_list);
+        g_free(sdp->service_list[i].uuid);
     }
-    qemu_free(sdp->service_list);
-    qemu_free(sdp);
+    g_free(sdp->service_list);
+    g_free(sdp);
 }
 
 struct sdp_def_service_s {
@@ -711,10 +709,10 @@ static void sdp_service_record_build(struct sdp_service_record_s *record,
     }
     record->uuids = 1 << ffs(record->uuids - 1);
     record->attribute_list =
-            qemu_mallocz(record->attributes * sizeof(*record->attribute_list));
+            g_malloc0(record->attributes * sizeof(*record->attribute_list));
     record->uuid =
-            qemu_mallocz(record->uuids * sizeof(*record->uuid));
-    data = qemu_malloc(len);
+            g_malloc0(record->uuids * sizeof(*record->uuid));
+    data = g_malloc(len);
 
     record->attributes = 0;
     uuid = record->uuid;
@@ -755,7 +753,7 @@ static void sdp_service_db_build(struct bt_l2cap_sdp_state_s *sdp,
     while (service[sdp->services])
         sdp->services ++;
     sdp->service_list =
-            qemu_mallocz(sdp->services * sizeof(*sdp->service_list));
+            g_malloc0(sdp->services * sizeof(*sdp->service_list));
 
     sdp->services = 0;
     while (*service) {
@@ -788,11 +786,11 @@ static void sdp_service_db_build(struct bt_l2cap_sdp_state_s *sdp,
         .type       = SDP_DTYPE_UUID | SDP_DSIZE_16,   \
         .value.uint = val,                             \
     },
-#define TRUE   {                               \
+#define SDP_TRUE       {                               \
         .type       = SDP_DTYPE_BOOL | SDP_DSIZE_1,    \
         .value.uint = 1,                               \
     },
-#define FALSE  {                               \
+#define SDP_FALSE      {                               \
         .type       = SDP_DTYPE_BOOL | SDP_DSIZE_1,    \
         .value.uint = 0,                               \
     },
@@ -844,8 +842,8 @@ SERVICE(hid,
     /* TODO: extract from l2cap_device->device.class[0] */
     ATTRIBUTE(DEVICE_SUBCLASS,         UINT8(0x40))
     ATTRIBUTE(COUNTRY_CODE,            UINT8(0x15))
-    ATTRIBUTE(VIRTUAL_CABLE,           TRUE)
-    ATTRIBUTE(RECONNECT_INITIATE,      FALSE)
+    ATTRIBUTE(VIRTUAL_CABLE,           SDP_TRUE)
+    ATTRIBUTE(RECONNECT_INITIATE,      SDP_FALSE)
     /* TODO: extract from hid->usbdev->report_desc */
     ATTRIBUTE(DESCRIPTOR_LIST,         LIST(
         LIST(UINT8(0x22) ARRAY(
@@ -885,12 +883,12 @@ SERVICE(hid,
     ATTRIBUTE(LANG_ID_BASE_LIST,       LIST(
         LIST(UINT16(0x0409) UINT16(0x0100))
     ))
-    ATTRIBUTE(SDP_DISABLE,             FALSE)
-    ATTRIBUTE(BATTERY_POWER,           TRUE)
-    ATTRIBUTE(REMOTE_WAKEUP,           TRUE)
-    ATTRIBUTE(BOOT_DEVICE,             TRUE)   /* XXX: untested */
+    ATTRIBUTE(SDP_DISABLE,             SDP_FALSE)
+    ATTRIBUTE(BATTERY_POWER,           SDP_TRUE)
+    ATTRIBUTE(REMOTE_WAKEUP,           SDP_TRUE)
+    ATTRIBUTE(BOOT_DEVICE,             SDP_TRUE)       /* XXX: untested */
     ATTRIBUTE(SUPERVISION_TIMEOUT,     UINT16(0x0c80))
-    ATTRIBUTE(NORMALLY_CONNECTABLE,    TRUE)
+    ATTRIBUTE(NORMALLY_CONNECTABLE,    SDP_TRUE)
     ATTRIBUTE(PROFILE_VERSION,         UINT16(0x0100))
 )
 
@@ -938,18 +936,18 @@ SERVICE(pnp,
     /* Profile specific */
     ATTRIBUTE(SPECIFICATION_ID, UINT16(0x0100))
     ATTRIBUTE(VERSION,         UINT16(0x0100))
-    ATTRIBUTE(PRIMARY_RECORD,  TRUE)
+    ATTRIBUTE(PRIMARY_RECORD,  SDP_TRUE)
 )
 
 static int bt_l2cap_sdp_new_ch(struct bt_l2cap_device_s *dev,
                 struct bt_l2cap_conn_params_s *params)
 {
-    struct bt_l2cap_sdp_state_s *sdp = qemu_mallocz(sizeof(*sdp));
+    struct bt_l2cap_sdp_state_s *sdp = g_malloc0(sizeof(*sdp));
     struct sdp_def_service_s *services[] = {
         &sdp_service_sdp_s,
         &sdp_service_hid_s,
         &sdp_service_pnp_s,
-        0,
+        NULL,
     };
 
     sdp->channel = params;