-indentation
[oweals/gnunet.git] / src / transport / gnunet-helper-transport-bluetooth.c
index 343aacd198d5177806147fb46108229410ea3d09..8ccfe6377308cad1f31fe1c126d34a3285715bc2 100644 (file)
     }
 #endif
 
+/**
+ * In bluez library, the maximum name length of a device is 8
+ */
+#define BLUEZ_DEVNAME_SIZE  8
+
 /**
  * struct for storing the information of the hardware.  There is only
  * one of these.
@@ -1070,6 +1075,7 @@ read_from_the_socket (void *sock,
   return count;
 }
 
+
 /**
  * Open the bluetooth interface for reading/writing
  *
@@ -1087,7 +1093,8 @@ open_device (struct HardwareInfos *dev)
     addr.btAddr = 0;
     addr.port = BT_PORT_ANY;
 
-    if (GNUNET_NETWORK_socket_bind (dev->handle, (const SOCKADDR*)&addr, sizeof (SOCKADDR_BTH), 0) != GNUNET_OK)
+    if (GNUNET_OK !=
+       GNUNET_NETWORK_socket_bind (dev->handle, (const SOCKADDR*)&addr, sizeof (SOCKADDR_BTH)))
     {
       fprintf (stderr, "Failed to bind the socket: ");
       if (GetLastError() == WSAENETDOWN)
@@ -1154,7 +1161,7 @@ open_device (struct HardwareInfos *dev)
 
       memset (&dev_info, 0, sizeof(struct hci_dev_info));
       dev_info.dev_id = request.dev[i].dev_id;
-      strncpy (dev_info.name, dev->iface, IFNAMSIZ);
+      strncpy (dev_info.name, dev->iface, BLUEZ_DEVNAME_SIZE);
 
       if (ioctl (fd_hci, HCIGETDEVINFO, (void *) &dev_info))
       {
@@ -1163,7 +1170,7 @@ open_device (struct HardwareInfos *dev)
         return 1;
       }
 
-      if (strcmp (dev_info.name, dev->iface) == 0)
+      if (strncmp (dev_info.name, dev->iface, BLUEZ_DEVNAME_SIZE) == 0)
       {
 
         dev_id = dev_info.dev_id; //the device was found