]> rtime.felk.cvut.cz Git - frescor/fna.git/blobdiff - src_frescan/frescan.c
improve a bit some error messages
[frescor/fna.git] / src_frescan / frescan.c
index 30f02c2ed04827642710d4ccdb884d4c7846d9d5..c2f5c7ec18b1e81f8b3a37cf850318ebf4a53cb0 100644 (file)
@@ -121,6 +121,7 @@ int frescan_init(frescan_init_params_t *params)
         fd = open (can_path, O_RDWR);
         if (fd == -1) {
                 FRESCAN_ERROR ("could not open /dev/can%u\n", params->net);
+                FRESCAN_ERROR ("hint: check driver or card installation\n");
                 return -1;
         }
 
@@ -486,10 +487,15 @@ static int frescan_hook_frame_recv (const struct can_chip_t *chip,
         DEBUG(FRESCAN_RX_HOOK_ENABLE_DEBUG || FRESCAN_FRAG_ENABLE_DEBUG,
               "prio:%u dest:%u src:%u chan:%u id:%u flag:%u\n",
               prio, dest, src, channel, frag_id, frag_flag);
-
         DEBUG(FRESCAN_RX_HOOK_ENABLE_DEBUG,
               "enqueue the packet in ID queue\n");
+
         packet = frescan_packets_alloc();
+        if (packet == NULL) {
+                FRESCAN_ERROR("could not allocate packet\n");
+                return -1;
+        }
+
         packet->frame = frame;
 
         if (frag_id == FRESCAN_MX_IDS) {
@@ -503,6 +509,11 @@ static int frescan_hook_frame_recv (const struct can_chip_t *chip,
                                 FRESCAN_FRAG_ENABLE_DEBUG,
                 "allocate head for id=%u\n", frag_id);
                 head = frescan_packets_alloc();
+                if (head == NULL) {
+                        FRESCAN_ERROR("could not allocate packet\n");
+                        return -1;
+                }
+
                 INIT_LIST_HEAD(&head->msg_list);
 
                 if (frag_id == FRESCAN_MX_IDS) {