]> sigrok.org Git - libsigrok.git/blobdiff - output/float.c
Return SR_ERR_MALLOC upon allocation errors.
[libsigrok.git] / output / float.c
index 650decc793532d0cd92310bba7db5e180b32a5f7..7812413d7c7508ad4253172d1f85413d1e0646eb 100644 (file)
@@ -20,7 +20,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include <glib.h>
-#include "config.h"
 #include "libsigrok.h"
 #include "libsigrok-internal.h"
 
@@ -44,8 +43,10 @@ static int init(struct sr_output *o)
        if (!o->sdi->driver)
                return SR_ERR_ARG;
 
-       if (!(ctx = g_try_malloc0(sizeof(struct context))))
+       if (!(ctx = g_try_malloc0(sizeof(struct context)))) {
+               sr_err("output/float: Context malloc failed.");
                return SR_ERR_MALLOC;
+       }
 
        o->internal = ctx;
 
@@ -126,7 +127,7 @@ static int data(struct sr_output *o, const uint8_t *data_in,
        max = length_in / sizeof(float);
        for (i = 0; i < max;) {
                for (j = 0; j < ctx->num_enabled_probes; j++) {
-                       g_string_append_printf(outstr, "%s: %f\n",
+                       g_string_append_printf(outstr, "%s: %.12f\n",
                                        (char *)g_ptr_array_index(ctx->probelist, j),
                                        fdata[i++]);
                }