]> sigrok.org Git - libsigrok.git/blobdiff - strutil.c
configure.ac: Drop std-options, unneeded.
[libsigrok.git] / strutil.c
index 2c4d5c814e9503012a5a42d7ecddb66e4772c72a..ad9f64974fe8c477df34f9749700ad1f11bddd1e 100644 (file)
--- a/strutil.c
+++ b/strutil.c
@@ -165,8 +165,8 @@ SR_API char *sr_period_string(uint64_t frequency)
  */
 SR_API char *sr_voltage_string(struct sr_rational *voltage)
 {
-       char *o;
        int r;
+       char *o;
 
        if (!(o = g_try_malloc0(30 + 1))) {
                sr_err("%s: o malloc failed", __func__);
@@ -178,7 +178,7 @@ SR_API char *sr_voltage_string(struct sr_rational *voltage)
        else if (voltage->q == 1)
                r = snprintf(o, 30, "%" PRIu64 "V", voltage->p);
        else
-               r = -1;
+               r = snprintf(o, 30, "%gV", (float)voltage->p / (float)voltage->q);
 
        if (r < 0) {
                /* Something went wrong... */
@@ -230,7 +230,7 @@ SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
                return NULL;
        }
 
-       if (sdi->driver->info_get(SR_DI_TRIGGER_TYPES,
+       if (sdi->driver->config_list(SR_CONF_TRIGGER_TYPE,
                        (const void **)&trigger_types, sdi) != SR_OK) {
                sr_err("%s: Device doesn't support any triggers.", __func__);
                return NULL;
@@ -404,11 +404,11 @@ SR_API int sr_parse_period(const char *periodstr, struct sr_rational *r)
                while (*s == ' ')
                        s++;
                if (!strcmp(s, "fs"))
-                       r->q = 1000000000000000L;
+                       r->q = 1000000000000000ULL;
                else if (!strcmp(s, "ps"))
-                       r->q = 1000000000000L;
+                       r->q = 1000000000000ULL;
                else if (!strcmp(s, "ns"))
-                       r->q = 1000000000L;
+                       r->q = 1000000000ULL;
                else if (!strcmp(s, "us"))
                        r->q = 1000000;
                else if (!strcmp(s, "ms"))