Print mailbox error response data only if data_size > 0.
authorFlorian Pose <fp@gh.de>
Tue, 03 May 2016 14:17:39 +0200
changeset 2643 adc81813fe16
parent 2642 9dc0b2262f90
child 2644 0c3987a1b3ee
Print mailbox error response data only if data_size > 0.
master/mailbox.c
--- a/master/mailbox.c	Tue May 03 14:13:11 2016 +0200
+++ b/master/mailbox.c	Tue May 03 14:17:39 2016 +0200
@@ -178,6 +178,13 @@
         return ERR_PTR(-EPROTO);
     }
 
+#if 0
+    if (slave->master->debug_level) {
+        EC_SLAVE_DBG(slave, 1, "Mailbox data:\n");
+        ec_print_data(datagram->data, EC_MBOX_HEADER_SIZE + data_size);
+    }
+#endif
+
     *type = EC_READ_U8(datagram->data + 5) & 0x0F;
     *size = data_size;
 
@@ -195,11 +202,13 @@
             break;
         }
 
-        if (!mbox_msg->code)
+        if (!mbox_msg->code) {
             printk("Unknown error reply code 0x%04X.\n", code);
-
-        if (slave->master->debug_level)
+        }
+
+        if (slave->master->debug_level && data_size > 0) {
             ec_print_data(datagram->data + EC_MBOX_HEADER_SIZE, data_size);
+        }
 
         return ERR_PTR(-EPROTO);
     }