Fix: threads launching with wrong arguments
authorRomain Forlot <romain.forlot@iot.bzh>
Tue, 21 Feb 2017 12:58:09 +0000 (12:58 +0000)
committerRomain Forlot <romain.forlot@iot.bzh>
Tue, 21 Feb 2017 12:58:09 +0000 (12:58 +0000)
Fix: wrong type identifier to returned sendto
function

Change-Id: I33bcb84211c665720422573b04b32ca71e13d3e5
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
src/can-utils.cpp
src/low-can-binding.cpp

index 7144c02..55daf44 100644 (file)
@@ -17,7 +17,6 @@
 
 #include "can-utils.hpp"
 
-
 /********************************************************************************
 *
 *              CanMessage method implementation
@@ -235,7 +234,7 @@ canfd_frame can_bus_dev_t::read(const struct afb_binding_interface* interface)
  */
 void can_bus_dev_t::start_reading()
 {
-       th_reading_ = std::thread(can_reader, this);
+       th_reading_ = std::thread(can_reader, *this);
        is_running_ = true;
 }
 
@@ -300,7 +299,7 @@ bool can_bus_dev_t::has_can_message() const
  */
 int can_bus_dev_t::send_can_message(can_message_t& can_msg, const struct afb_binding_interface* interface)
 {
-       size_t nbytes;
+       ssize_t nbytes;
        canfd_frame f;
 
        f = can_msg.convert_to_canfd_frame();
@@ -340,8 +339,8 @@ can_bus_t::can_bus_t(const afb_binding_interface *itf, int& conf_file)
  */
 void can_bus_t::start_threads()
 {
-       th_decoding_ = std::thread(can_decoder, this);
-       th_pushing_ = std::thread(can_event_push, this);
+       th_decoding_ = std::thread(can_decode_message, *this);
+       th_pushing_ = std::thread(can_event_push, *this);
 }
 
 /**
@@ -387,7 +386,7 @@ std::vector<std::string> can_bus_t::read_conf()
 {
        std::vector<std::string> ret;
        json_object *jo, *canbus;
-       int n, i, ok;
+       int n, i;
 
        FILE *fd = fdopen(conf_file_, "r");
        if (fd)
@@ -411,9 +410,8 @@ std::vector<std::string> can_bus_t::read_conf()
                else
                {
                        n = json_object_array_length(canbus);
-                       ok = 0;
                        for (i = 0 ; i < n ; i++)
-                       ret.push_back(json_object_get_string(json_object_array_get_idx(canbus, i)));
+                               ret.push_back(json_object_get_string(json_object_array_get_idx(canbus, i)));
                }
                return ret;
        }
index aaa9e54..4e58dd4 100644 (file)
@@ -34,6 +34,7 @@ static int subscribe_unsubscribe_signal(struct afb_req request, bool subscribe,
 {
        int ret;
 
+       // TODO: lock the subscribed_signals when insert/remove
        const auto& ss_i = subscribed_signals.find(sig.genericName);
        if (ss_i != subscribed_signals.end())
        {
@@ -78,15 +79,15 @@ static int subscribe_unsubscribe_signal(struct afb_req request, bool subscribe,
 
 static int subscribe_unsubscribe_signals(struct afb_req request, bool subscribe, const std::vector<CanSignal>& signals)
 {
-       int ret;
+       int ret = 0;
 
-       // TODO: lock the subscribed_signals when insert/remove
        for(const auto& signal_i : signals)
        {
                ret = subscribe_unsubscribe_signal(request, subscribe, signal_i);
                if(ret == 0)
                        return ret;
        }
+       return ret;
 }
 
 static int subscribe_unsubscribe_all(struct afb_req request, bool subscribe)