Various subsystems: Use message logging helpers.
This commit is contained in:
parent
a944a84b17
commit
a885ce3ee9
33
datastore.c
33
datastore.c
|
@ -24,6 +24,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "datastore: "
|
||||
#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
|
@ -65,18 +74,18 @@ static gpointer new_chunk(struct sr_datastore **ds);
|
|||
SR_API int sr_datastore_new(int unitsize, struct sr_datastore **ds)
|
||||
{
|
||||
if (!ds) {
|
||||
sr_err("ds: %s: ds was NULL", __func__);
|
||||
sr_err("%s: ds was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (unitsize <= 0) {
|
||||
sr_err("ds: %s: unitsize was %d, but it must be >= 1",
|
||||
sr_err("%s: unitsize was %d, but it must be >= 1",
|
||||
__func__, unitsize);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(*ds = g_try_malloc(sizeof(struct sr_datastore)))) {
|
||||
sr_err("ds: %s: ds malloc failed", __func__);
|
||||
sr_err("%s: ds malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -102,7 +111,7 @@ SR_API int sr_datastore_destroy(struct sr_datastore *ds)
|
|||
GSList *chunk;
|
||||
|
||||
if (!ds) {
|
||||
sr_err("ds: %s: ds was NULL", __func__);
|
||||
sr_err("%s: ds was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
|
@ -149,36 +158,36 @@ SR_API int sr_datastore_put(struct sr_datastore *ds, void *data,
|
|||
gpointer chunk;
|
||||
|
||||
if (!ds) {
|
||||
sr_err("ds: %s: ds was NULL", __func__);
|
||||
sr_err("%s: ds was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
/* Unitsize must not be 0, we'll divide by 0 otherwise. */
|
||||
if (ds->ds_unitsize == 0) {
|
||||
sr_err("ds: %s: ds->ds_unitsize was 0", __func__);
|
||||
sr_err("%s: ds->ds_unitsize was 0", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!data) {
|
||||
sr_err("ds: %s: data was NULL", __func__);
|
||||
sr_err("%s: data was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (in_unitsize < 1) {
|
||||
sr_err("ds: %s: in_unitsize was %d, but it must be >= 1",
|
||||
sr_err("%s: in_unitsize was %d, but it must be >= 1",
|
||||
__func__, in_unitsize);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!probelist) {
|
||||
sr_err("ds: %s: probelist was NULL", __func__);
|
||||
sr_err("%s: probelist was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
/* Get the last chunk in the list, or create a new one if needed. */
|
||||
if (ds->chunklist == NULL) {
|
||||
if (!(chunk = new_chunk(&ds))) {
|
||||
sr_err("ds: %s: couldn't allocate new chunk", __func__);
|
||||
sr_err("%s: couldn't allocate new chunk", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
} else {
|
||||
|
@ -197,7 +206,7 @@ SR_API int sr_datastore_put(struct sr_datastore *ds, void *data,
|
|||
/* No more free space left, allocate a new chunk. */
|
||||
if (chunk_bytes_free == 0) {
|
||||
if (!(chunk = new_chunk(&ds))) {
|
||||
sr_err("ds: %s: couldn't allocate new chunk",
|
||||
sr_err("%s: couldn't allocate new chunk",
|
||||
__func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
@ -246,7 +255,7 @@ static gpointer new_chunk(struct sr_datastore **ds)
|
|||
|
||||
chunk = g_try_malloc0(DATASTORE_CHUNKSIZE * (*ds)->ds_unitsize);
|
||||
if (!chunk) {
|
||||
sr_err("ds: %s: chunk malloc failed (ds_unitsize was %u)",
|
||||
sr_err("%s: chunk malloc failed (ds_unitsize was %u)",
|
||||
__func__, (*ds)->ds_unitsize);
|
||||
return NULL; /* TODO: SR_ERR_MALLOC later? */
|
||||
}
|
||||
|
|
19
device.c
19
device.c
|
@ -23,6 +23,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "device: "
|
||||
#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
|
@ -44,7 +53,7 @@ SR_PRIV struct sr_probe *sr_probe_new(int index, int type,
|
|||
struct sr_probe *probe;
|
||||
|
||||
if (!(probe = g_try_malloc0(sizeof(struct sr_probe)))) {
|
||||
sr_err("hwdriver: probe malloc failed");
|
||||
sr_err("Probe malloc failed.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -208,7 +217,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
|
|||
struct sr_dev_inst *sdi;
|
||||
|
||||
if (!(sdi = g_try_malloc(sizeof(struct sr_dev_inst)))) {
|
||||
sr_err("hwdriver: %s: sdi malloc failed", __func__);
|
||||
sr_err("%s: sdi malloc failed", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -254,7 +263,7 @@ SR_PRIV struct sr_usb_dev_inst *sr_usb_dev_inst_new(uint8_t bus,
|
|||
struct sr_usb_dev_inst *udi;
|
||||
|
||||
if (!(udi = g_try_malloc(sizeof(struct sr_usb_dev_inst)))) {
|
||||
sr_err("hwdriver: %s: udi malloc failed", __func__);
|
||||
sr_err("%s: udi malloc failed", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -282,7 +291,7 @@ SR_PRIV struct sr_serial_dev_inst *sr_serial_dev_inst_new(const char *port,
|
|||
struct sr_serial_dev_inst *serial;
|
||||
|
||||
if (!(serial = g_try_malloc(sizeof(struct sr_serial_dev_inst)))) {
|
||||
sr_err("hwdriver: %s: serial malloc failed", __func__);
|
||||
sr_err("%s: serial malloc failed", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -304,7 +313,7 @@ SR_API int sr_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
|||
int ret;
|
||||
|
||||
if (!sdi || !sdi->driver || !sdi->driver->dev_config_set) {
|
||||
sr_err("hwdriver: unable to set config option");
|
||||
sr_err("Unable to set config option.");
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
|
|
21
filter.c
21
filter.c
|
@ -23,6 +23,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "filter: "
|
||||
#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
|
@ -96,22 +105,22 @@ SR_API int sr_filter_probes(int in_unitsize, int out_unitsize,
|
|||
uint64_t sample_in, sample_out;
|
||||
|
||||
if (!probelist) {
|
||||
sr_err("filter: %s: probelist was NULL", __func__);
|
||||
sr_err("%s: probelist was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!data_in) {
|
||||
sr_err("filter: %s: data_in was NULL", __func__);
|
||||
sr_err("%s: data_in was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!data_out) {
|
||||
sr_err("filter: %s: data_out was NULL", __func__);
|
||||
sr_err("%s: data_out was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!length_out) {
|
||||
sr_err("filter: %s: length_out was NULL", __func__);
|
||||
sr_err("%s: length_out was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
|
@ -121,13 +130,13 @@ SR_API int sr_filter_probes(int in_unitsize, int out_unitsize,
|
|||
|
||||
/* Are there more probes than the target unit size supports? */
|
||||
if (num_enabled_probes > out_unitsize * 8) {
|
||||
sr_err("filter: %s: too many probes (%d) for the target unit "
|
||||
sr_err("%s: too many probes (%d) for the target unit "
|
||||
"size (%d)", __func__, num_enabled_probes, out_unitsize);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(*data_out = g_try_malloc(length_in))) {
|
||||
sr_err("filter: %s: data_out malloc failed", __func__);
|
||||
sr_err("%s: data_out malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "virtual-session: "
|
||||
#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
|
||||
|
||||
/* size of payloads sent across the session bus */
|
||||
/** @cond PRIVATE */
|
||||
#define CHUNKSIZE (512 * 1024)
|
||||
|
@ -62,7 +71,7 @@ static int receive_data(int fd, int revents, void *cb_data)
|
|||
(void)fd;
|
||||
(void)revents;
|
||||
|
||||
sr_dbg("session_driver: feed chunk");
|
||||
sr_dbg("Feed chunk.");
|
||||
|
||||
got_data = FALSE;
|
||||
for (l = dev_insts; l; l = l->next) {
|
||||
|
@ -73,7 +82,7 @@ static int receive_data(int fd, int revents, void *cb_data)
|
|||
continue;
|
||||
|
||||
if (!(buf = g_try_malloc(CHUNKSIZE))) {
|
||||
sr_err("session driver: %s: buf malloc failed", __func__);
|
||||
sr_err("%s: buf malloc failed", __func__);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -110,7 +119,6 @@ static int hw_cleanup(void);
|
|||
|
||||
static int hw_init(void)
|
||||
{
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
|
@ -128,9 +136,8 @@ static int hw_cleanup(void)
|
|||
|
||||
static int hw_dev_open(struct sr_dev_inst *sdi)
|
||||
{
|
||||
|
||||
if (!(sdi->priv = g_try_malloc0(sizeof(struct session_vdev)))) {
|
||||
sr_err("session driver: %s: sdi->priv malloc failed", __func__);
|
||||
sr_err("%s: sdi->priv malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -174,18 +181,15 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
|||
case SR_HWCAP_SAMPLERATE:
|
||||
tmp_u64 = value;
|
||||
vdev->samplerate = *tmp_u64;
|
||||
sr_info("session driver: setting samplerate to %" PRIu64,
|
||||
vdev->samplerate);
|
||||
sr_info("Setting samplerate to %" PRIu64 ".", vdev->samplerate);
|
||||
break;
|
||||
case SR_HWCAP_SESSIONFILE:
|
||||
vdev->sessionfile = g_strdup(value);
|
||||
sr_info("session driver: setting sessionfile to %s",
|
||||
vdev->sessionfile);
|
||||
sr_info("Setting sessionfile to '%s'.", vdev->sessionfile);
|
||||
break;
|
||||
case SR_HWCAP_CAPTUREFILE:
|
||||
vdev->capturefile = g_strdup(value);
|
||||
sr_info("session driver: setting capturefile to %s",
|
||||
vdev->capturefile);
|
||||
sr_info("Setting capturefile to '%s'.", vdev->capturefile);
|
||||
break;
|
||||
case SR_HWCAP_CAPTURE_UNITSIZE:
|
||||
tmp_u64 = value;
|
||||
|
@ -196,8 +200,7 @@ static int hw_dev_config_set(const struct sr_dev_inst *sdi, int hwcap,
|
|||
vdev->num_probes = *tmp_u64;
|
||||
break;
|
||||
default:
|
||||
sr_err("session driver: %s: unknown capability %d requested",
|
||||
__func__, hwcap);
|
||||
sr_err("Unknown capability: %d.", hwcap);
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
|
@ -216,23 +219,23 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
|
||||
vdev = sdi->priv;
|
||||
|
||||
sr_info("session_driver: opening archive %s file %s", vdev->sessionfile,
|
||||
sr_info("Opening archive %s file %s", vdev->sessionfile,
|
||||
vdev->capturefile);
|
||||
|
||||
if (!(vdev->archive = zip_open(vdev->sessionfile, 0, &ret))) {
|
||||
sr_err("session driver: Failed to open session file '%s': "
|
||||
sr_err("Failed to open session file '%s': "
|
||||
"zip error %d\n", vdev->sessionfile, ret);
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
if (zip_stat(vdev->archive, vdev->capturefile, 0, &zs) == -1) {
|
||||
sr_err("session driver: Failed to check capture file '%s' in "
|
||||
sr_err("Failed to check capture file '%s' in "
|
||||
"session file '%s'.", vdev->capturefile, vdev->sessionfile);
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
if (!(vdev->capfile = zip_fopen(vdev->archive, vdev->capturefile, 0))) {
|
||||
sr_err("session driver: Failed to open capture file '%s' in "
|
||||
sr_err("Failed to open capture file '%s' in "
|
||||
"session file '%s'.", vdev->capturefile, vdev->sessionfile);
|
||||
return SR_ERR;
|
||||
}
|
||||
|
@ -241,12 +244,12 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
sr_session_source_add(-1, 0, 0, receive_data, cb_data);
|
||||
|
||||
if (!(packet = g_try_malloc(sizeof(struct sr_datafeed_packet)))) {
|
||||
sr_err("session driver: %s: packet malloc failed", __func__);
|
||||
sr_err("%s: packet malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
if (!(header = g_try_malloc(sizeof(struct sr_datafeed_header)))) {
|
||||
sr_err("session driver: %s: header malloc failed", __func__);
|
||||
sr_err("%s: header malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -272,7 +275,7 @@ static int hw_dev_acquisition_start(const struct sr_dev_inst *sdi,
|
|||
|
||||
/** @private */
|
||||
SR_PRIV struct sr_dev_driver session_driver = {
|
||||
.name = "session",
|
||||
.name = "virtual-session",
|
||||
.longname = "Session-emulating driver",
|
||||
.api_version = 1,
|
||||
.init = hw_init,
|
||||
|
|
|
@ -27,6 +27,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "session-file: "
|
||||
#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
|
@ -66,42 +75,41 @@ SR_API int sr_session_load(const char *filename)
|
|||
char probename[SR_MAX_PROBENAME_LEN + 1];
|
||||
|
||||
if (!filename) {
|
||||
sr_err("session file: %s: filename was NULL", __func__);
|
||||
sr_err("%s: filename was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
if (!(archive = zip_open(filename, 0, &ret))) {
|
||||
sr_dbg("session file: Failed to open session file: zip "
|
||||
"error %d", ret);
|
||||
sr_dbg("Failed to open session file: zip error %d", ret);
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
/* check "version" */
|
||||
version = 0;
|
||||
if (!(zf = zip_fopen(archive, "version", 0))) {
|
||||
sr_dbg("session file: Not a sigrok session file.");
|
||||
sr_dbg("Not a sigrok session file.");
|
||||
return SR_ERR;
|
||||
}
|
||||
if ((ret = zip_fread(zf, s, 10)) == -1) {
|
||||
sr_dbg("session file: Not a valid sigrok session file.");
|
||||
sr_dbg("Not a valid sigrok session file.");
|
||||
return SR_ERR;
|
||||
}
|
||||
zip_fclose(zf);
|
||||
s[ret] = 0;
|
||||
version = strtoull(s, NULL, 10);
|
||||
if (version != 1) {
|
||||
sr_dbg("session file: Not a valid sigrok session file version.");
|
||||
sr_dbg("Not a valid sigrok session file version.");
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
/* read "metadata" */
|
||||
if (zip_stat(archive, "metadata", 0, &zs) == -1) {
|
||||
sr_dbg("session file: Not a valid sigrok session file.");
|
||||
sr_dbg("Not a valid sigrok session file.");
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
if (!(metafile = g_try_malloc(zs.size))) {
|
||||
sr_err("session file: %s: metafile malloc failed", __func__);
|
||||
sr_err("%s: metafile malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -111,7 +119,7 @@ SR_API int sr_session_load(const char *filename)
|
|||
|
||||
kf = g_key_file_new();
|
||||
if (!g_key_file_load_from_data(kf, metafile, zs.size, 0, NULL)) {
|
||||
sr_dbg("session file: Failed to parse metadata.");
|
||||
sr_dbg("Failed to parse metadata.");
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
|
@ -206,7 +214,7 @@ SR_API int sr_session_save(const char *filename,
|
|||
char version[1], rawname[16], metafile[32], *buf, *s;
|
||||
|
||||
if (!filename) {
|
||||
sr_err("session file: %s: filename was NULL", __func__);
|
||||
sr_err("%s: filename was NULL", __func__);
|
||||
return SR_ERR_ARG;
|
||||
}
|
||||
|
||||
|
@ -220,7 +228,7 @@ SR_API int sr_session_save(const char *filename,
|
|||
if (!(versrc = zip_source_buffer(zipfile, version, 1, 0)))
|
||||
return SR_ERR;
|
||||
if (zip_add(zipfile, "version", versrc) == -1) {
|
||||
sr_info("session file: error saving version into zipfile: %s",
|
||||
sr_info("error saving version into zipfile: %s",
|
||||
zip_strerror(zipfile));
|
||||
return SR_ERR;
|
||||
}
|
||||
|
@ -267,8 +275,7 @@ SR_API int sr_session_save(const char *filename,
|
|||
buf = g_try_malloc(ds->num_units * ds->ds_unitsize +
|
||||
DATASTORE_CHUNKSIZE);
|
||||
if (!buf) {
|
||||
sr_err("session file: %s: buf malloc failed",
|
||||
__func__);
|
||||
sr_err("%s: buf malloc failed", __func__);
|
||||
return SR_ERR_MALLOC;
|
||||
}
|
||||
|
||||
|
@ -292,8 +299,7 @@ SR_API int sr_session_save(const char *filename,
|
|||
return SR_ERR;
|
||||
|
||||
if ((ret = zip_close(zipfile)) == -1) {
|
||||
sr_info("session file: error saving zipfile: %s",
|
||||
zip_strerror(zipfile));
|
||||
sr_info("error saving zipfile: %s", zip_strerror(zipfile));
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
|
|
26
strutil.c
26
strutil.c
|
@ -24,6 +24,15 @@
|
|||
#include "libsigrok.h"
|
||||
#include "libsigrok-internal.h"
|
||||
|
||||
/* Message logging helpers with driver-specific prefix string. */
|
||||
#define DRIVER_LOG_DOMAIN "strutil: "
|
||||
#define sr_log(l, s, args...) sr_log(l, DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_spew(s, args...) sr_spew(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_dbg(s, args...) sr_dbg(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_info(s, args...) sr_info(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_warn(s, args...) sr_warn(DRIVER_LOG_DOMAIN s, ## args)
|
||||
#define sr_err(s, args...) sr_err(DRIVER_LOG_DOMAIN s, ## args)
|
||||
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
|
@ -55,7 +64,7 @@
|
|||
*/
|
||||
SR_API char *sr_si_string_u64(uint64_t x, const char *unit)
|
||||
{
|
||||
if(unit == NULL)
|
||||
if (unit == NULL)
|
||||
unit = "";
|
||||
|
||||
if ((x >= SR_GHZ(1)) && (x % SR_GHZ(1) == 0)) {
|
||||
|
@ -79,8 +88,7 @@ SR_API char *sr_si_string_u64(uint64_t x, const char *unit)
|
|||
return g_strdup_printf("%" PRIu64 " %s", x, unit);
|
||||
}
|
||||
|
||||
sr_err("strutil: %s: Error creating SI units string.",
|
||||
__func__);
|
||||
sr_err("%s: Error creating SI units string.", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -120,7 +128,7 @@ SR_API char *sr_period_string(uint64_t frequency)
|
|||
|
||||
/* Allocate enough for a uint64_t as string + " ms". */
|
||||
if (!(o = g_try_malloc0(30 + 1))) {
|
||||
sr_err("strutil: %s: o malloc failed", __func__);
|
||||
sr_err("%s: o malloc failed", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -161,7 +169,7 @@ SR_API char *sr_voltage_string(struct sr_rational *voltage)
|
|||
int r;
|
||||
|
||||
if (!(o = g_try_malloc0(30 + 1))) {
|
||||
sr_err("strutil: %s: o malloc failed", __func__);
|
||||
sr_err("%s: o malloc failed", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -218,13 +226,13 @@ SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
|
|||
error = FALSE;
|
||||
|
||||
if (!(triggerlist = g_try_malloc0(max_probes * sizeof(char *)))) {
|
||||
sr_err("strutil: %s: triggerlist malloc failed", __func__);
|
||||
sr_err("%s: triggerlist malloc failed", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (sdi->driver->info_get(SR_DI_TRIGGER_TYPES,
|
||||
(const void **)&trigger_types, sdi) != SR_OK) {
|
||||
sr_err("strutil: %s: Device doesn't support any triggers.", __func__);
|
||||
sr_err("%s: Device doesn't support any triggers.", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -242,7 +250,7 @@ SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
|
|||
}
|
||||
|
||||
if (probenum < 0 || probenum >= max_probes) {
|
||||
sr_err("strutil: Invalid probe.");
|
||||
sr_err("Invalid probe.");
|
||||
error = TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -250,7 +258,7 @@ SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi,
|
|||
if ((trigger = strchr(tokens[i], '='))) {
|
||||
for (tc = ++trigger; *tc; tc++) {
|
||||
if (strchr(trigger_types, *tc) == NULL) {
|
||||
sr_err("strutil: Unsupported trigger "
|
||||
sr_err("Unsupported trigger "
|
||||
"type '%c'.", *tc);
|
||||
error = TRUE;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue