Possible uninitialized variable returned.
[apps/agl-service-can-low-level.git] / CAN-binder / low-can-binding / binding / low-can-cb.cpp
index 0671f9e..fbe6e19 100644 (file)
@@ -85,10 +85,12 @@ int read_message(sd_event_source *event_source, int fd, uint32_t revents, void *
                utils::socketcan_bcm_t& s = can_subscription->get_socket();
                s >> cm;
 
-               push_n_notify(cm);
+               // Sure we got a valid CAN message ?
+               if(! cm.get_id() == 0 && ! cm.get_length() == 0)
+                       {push_n_notify(cm);}
        }
 
-       /* check if error or hangup */
+       // check if error or hangup
        if ((revents & (EPOLLERR|EPOLLRDHUP|EPOLLHUP)) != 0)
        {
                sd_event_source_unref(event_source);
@@ -132,7 +134,7 @@ static int create_event_handle(std::shared_ptr<low_can_subscription_t>& can_subs
 /// against the application framework using that event handle.
 static int subscribe_unsubscribe_signal(struct afb_req request, bool subscribe, std::shared_ptr<low_can_subscription_t>& can_subscription, std::map<int, std::shared_ptr<low_can_subscription_t> >& s)
 {
-       int ret;
+       int ret = -1;
        int sub_index = can_subscription->get_index();
 
        if (can_subscription && s.find(sub_index) != s.end())
@@ -142,6 +144,7 @@ static int subscribe_unsubscribe_signal(struct afb_req request, bool subscribe,
                        NOTICE(binder_interface, "%s: Event isn't valid, no need to unsubscribed.", __FUNCTION__);
                        ret = -1;
                }
+               ret = 0;
        }
        else
        {