]> sigrok.org Git - libsigrok.git/commitdiff
sr: cleaned up session bus debug helper
authorBert Vermeulen <redacted>
Sun, 12 Feb 2012 23:08:23 +0000 (00:08 +0100)
committerBert Vermeulen <redacted>
Sun, 12 Feb 2012 23:08:23 +0000 (00:08 +0100)
session.c

index ed8cadc53bbe5505b2c6585ee100dc2935aaf27e..06c265a9afd3fbce5f79cd416245fc39d3092330 100644 (file)
--- a/session.c
+++ b/session.c
@@ -387,24 +387,15 @@ SR_API int sr_session_stop(void)
 }
 
 /**
- * TODO.
- *
- * TODO: Various error checks.
+ * @brief debug helper
  *
  * @param packet TODO.
- * @return SR_OK upon success, SR_ERR_ARG upon invalid arguments.
+ *
  */
-static int datafeed_dump(struct sr_datafeed_packet *packet)
+static void datafeed_dump(struct sr_datafeed_packet *packet)
 {
        struct sr_datafeed_logic *logic;
 
-       if (!packet) {
-               sr_err("session: %s: packet was NULL", __func__);
-               return SR_ERR_ARG;
-       }
-
-       /* TODO: Validity checks for packet contents. */
-
        switch (packet->type) {
        case SR_DF_HEADER:
                sr_dbg("bus: received SR_DF_HEADER");
@@ -421,12 +412,10 @@ static int datafeed_dump(struct sr_datafeed_packet *packet)
                sr_dbg("bus: received SR_DF_END");
                break;
        default:
-               /* TODO: Abort? */
-               sr_err("bus: received unknown packet type %d", packet->type);
+               sr_dbg("bus: received unknown packet type %d", packet->type);
                break;
        }
 
-       return SR_OK;
 }
 
 /**
@@ -462,9 +451,10 @@ SR_API int sr_session_bus(struct sr_device *device,
         * the callbacks as well.
         */
        for (l = session->datafeed_callbacks; l; l = l->next) {
+               if (sr_log_loglevel_get() >= SR_LOG_DBG)
+                       datafeed_dump(packet);
                cb = l->data;
                /* TODO: Check for cb != NULL. */
-               datafeed_dump(packet);
                cb(device, packet);
        }