Check that you are not present in trail twice
[oweals/gnunet.git] / src / transport / gnunet-helper-transport-bluetooth.c
index 42bb96f539da5f1bd3f87199b8ba8c74a132b87c..b5556c7d682ef34c6b117c4c0815c1cb0e665814 100644 (file)
@@ -965,7 +965,7 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len)
     sdp_list_t *search_list = 0, *attrid_list = 0, *response_list = 0, *it = 0;
     uuid_t svc_uuid;
     uint32_t range = 0x0000ffff;
-    uint8_t channel = -1;
+    int channel = -1;
 
     /* Connect to the local SDP server */
     session = sdp_connect (BDADDR_ANY, &dest, 0);
@@ -1002,9 +1002,12 @@ check_crc_buf_osdep (const unsigned char *buf, size_t len)
 
     sdp_close (session);
 
-    if (channel == -1)
-      fprintf (stderr, "Failed to find the listening channel for interface `%.*s': %s\n",
-              IFNAMSIZ, dev->iface, strerror (errno));
+    if (-1 == channel)
+      fprintf (stderr,
+               "Failed to find the listening channel for interface `%.*s': %s\n",
+               IFNAMSIZ,
+               dev->iface,
+               strerror (errno));
 
     return channel;
   }
@@ -1948,13 +1951,13 @@ main (int argc, char *argv[])
           fprintf (stderr, "LOG : %s sends a message to STDOUT\n", dev.iface); //FIXME: debugging message
 
         }
-        if (sendsocket != -1)
+        if (-1 != sendsocket)
         {
           if (FD_ISSET (sendsocket , &wfds))
           {
-            ssize_t ret =
-        write (sendsocket, write_pout.buf + write_std.pos,
-               write_pout.size - write_pout.pos);
+            ssize_t ret = write (sendsocket,
+                                 write_pout.buf + write_std.pos,
+                                 write_pout.size - write_pout.pos);
             if (0 > ret) //FIXME should I first check the error type?
             {
               fprintf (stderr, "Failed to write to bluetooth device: %s. Closing the socket!\n",
@@ -2101,7 +2104,8 @@ main (int argc, char *argv[])
     stdin_mst = NULL;
     sdp_close (dev.session);
     (void) close (dev.fd_rfcomm);
-    (void) close (sendsocket);
+    if (-1 != sendsocket)
+      (void) close (sendsocket);
 
     for (i = 0; i < crt_rfds; i++)
       (void) close (rfds_list[i]);