]> sigrok.org Git - libsigrok.git/commitdiff
make output modules a bit more crashproof
authorBert Vermeulen <redacted>
Thu, 13 Jan 2011 01:05:39 +0000 (02:05 +0100)
committerBert Vermeulen <redacted>
Thu, 13 Jan 2011 06:55:35 +0000 (07:55 +0100)
the event handler in output modules is now optional.

output/output_binary.c
output/output_gnuplot.c
output/output_vcd.c

index 41a8caee721ec04cb2eefec58285f9537c9311b9..2e6603d583c398da62580aa7dd4181038f3ae108 100644 (file)
 #include <sigrok.h>
 #include "config.h"
 
-static int event(struct output *o, int event_type, char **data_out,
-                uint64_t *length_out)
-{
-       /* Prevent compiler warnings. */
-       o = o;
-
-       switch (event_type) {
-       case DF_TRIGGER:
-               /* TODO? Ignore? */
-               break;
-       case DF_END:
-               *data_out = NULL;
-               *length_out = 0;
-               break;
-       }
-
-       return SIGROK_OK;
-}
 
 static int data(struct output *o, char *data_in, uint64_t length_in,
                char **data_out, uint64_t *length_out)
@@ -67,5 +49,5 @@ struct output_format output_binary = {
        DF_LOGIC,
        NULL,
        data,
-       event,
+       NULL,
 };
index 94c566faf1bc0cbd71151f63e12217452ada02f3..5ad9cc5ba54079a0a796ddaebb6672e23e29717c 100644 (file)
@@ -127,16 +127,17 @@ static int event(struct output *o, int event_type, char **data_out,
        ctx = o->internal;
        switch (event_type) {
        case DF_TRIGGER:
-               /* TODO */
+               /* TODO: can a trigger mark be in a gnuplot data file? */
                break;
        case DF_END:
-               *data_out = NULL;
-               *length_out = 0;
                free(o->internal);
                o->internal = NULL;
                break;
        }
 
+       *data_out = NULL;
+       *length_out = 0;
+
        return SIGROK_OK;
 }
 
index 190e9e4561fa47c44baa6a788dddc6b9690572a9..34b150d48ad47bcb6a026f7612d18f9be74080b4 100644 (file)
@@ -135,7 +135,9 @@ static int event(struct output *o, int event_type, char **data_out,
        ctx = o->internal;
        switch (event_type) {
        case DF_TRIGGER:
-               /* TODO */
+               /* TODO: can a trigger mark be in a VCD file? */
+               *data_out = NULL;
+               *length_out = 0;
                break;
        case DF_END:
                outlen = strlen("$dumpoff\n$end\n");
@@ -149,6 +151,10 @@ static int event(struct output *o, int event_type, char **data_out,
                free(o->internal);
                o->internal = NULL;
                break;
+       default:
+               *data_out = NULL;
+               *length_out = 0;
+               break;
        }
 
        return SIGROK_OK;