From: Bert Vermeulen Date: Tue, 28 Feb 2012 16:47:02 +0000 (+0100) Subject: sr: code cleanup X-Git-Tag: libsigrok-0.1.0~79 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=2285cf9bc519edb88eccbe3bf2ddd6888e54cdf2;p=libsigrok.git sr: code cleanup --- diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index 27ce1dd9..e33de713 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -233,7 +233,7 @@ static struct sr_dev_inst *zp_open_dev(int dev_index) struct sr_dev_inst *sdi; libusb_device **devlist; struct libusb_device_descriptor des; - int err, i; + int i; if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) return NULL; @@ -244,7 +244,7 @@ static struct sr_dev_inst *zp_open_dev(int dev_index) libusb_get_device_list(usb_context, &devlist); for (i = 0; devlist[i]; i++) { /* TODO: Error handling. */ - err = opendev4(&sdi, devlist[i], &des); + opendev4(&sdi, devlist[i], &des); } } else { /* Status must be SR_ST_ACTIVE, i.e. already in use... */ diff --git a/input/chronovu_la8.c b/input/chronovu_la8.c index 1ecb6fb7..af6a80c7 100644 --- a/input/chronovu_la8.c +++ b/input/chronovu_la8.c @@ -154,7 +154,7 @@ static int loadfile(struct sr_input *in, const char *filename) for (i = 0; i < NUM_PACKETS; i++) { /* TODO: Handle errors, handle incomplete reads. */ size = read(fd, buf, PACKET_SIZE); - logic.length = PACKET_SIZE; + logic.length = size; sr_session_bus(in->vdev, &packet); } close(fd); /* FIXME */ diff --git a/output/chronovu_la8.c b/output/chronovu_la8.c index 91ad56e6..75881195 100644 --- a/output/chronovu_la8.c +++ b/output/chronovu_la8.c @@ -86,7 +86,6 @@ static int init(struct sr_output *o) struct context *ctx; struct sr_probe *probe; GSList *l; - int num_probes; uint64_t samplerate; if (!o) { @@ -111,7 +110,7 @@ static int init(struct sr_output *o) o->internal = ctx; - /* Get the number of probes, their names, and the unitsize. */ + /* Get the probe names and the unitsize. */ /* TODO: Error handling. */ for (l = o->dev->probes; l; l = l->next) { probe = l->data; @@ -122,8 +121,6 @@ static int init(struct sr_output *o) ctx->probelist[ctx->num_enabled_probes] = 0; ctx->unitsize = (ctx->num_enabled_probes + 7) / 8; - num_probes = g_slist_length(o->dev->probes); - if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) { samplerate = *((uint64_t *) o->dev->plugin->dev_info_get( o->dev->plugin_index, SR_DI_CUR_SAMPLERATE)); diff --git a/output/gnuplot.c b/output/gnuplot.c index ecbc027b..c150a2fb 100644 --- a/output/gnuplot.c +++ b/output/gnuplot.c @@ -148,8 +148,6 @@ static int init(struct sr_output *o) static int event(struct sr_output *o, int event_type, char **data_out, uint64_t *length_out) { - struct context *ctx; - if (!o) { sr_err("gnuplot out: %s: o was NULL", __func__); return SR_ERR_ARG; @@ -165,8 +163,6 @@ static int event(struct sr_output *o, int event_type, char **data_out, return SR_ERR_ARG; } - ctx = o->internal; - switch (event_type) { case SR_DF_TRIGGER: /* TODO: Can a trigger mark be in a gnuplot data file? */ diff --git a/output/vcd.c b/output/vcd.c index 7ceb0bae..119a3774 100644 --- a/output/vcd.c +++ b/output/vcd.c @@ -138,10 +138,8 @@ static int init(struct sr_output *o) static int event(struct sr_output *o, int event_type, char **data_out, uint64_t *length_out) { - struct context *ctx; char *outbuf; - ctx = o->internal; switch (event_type) { case SR_DF_END: outbuf = g_strdup("$dumpoff\n$end\n"); diff --git a/session_file.c b/session_file.c index 259472e5..d11ccebd 100644 --- a/session_file.c +++ b/session_file.c @@ -46,7 +46,6 @@ SR_API int sr_session_load(const char *filename) struct zip *archive; struct zip_file *zf; struct zip_stat zs; - struct sr_session *session; struct sr_dev *dev; struct sr_probe *probe; int ret, err, probenum, devcnt, i, j; @@ -98,7 +97,7 @@ SR_API int sr_session_load(const char *filename) return SR_ERR; } - session = sr_session_new(); + sr_session_new(); devcnt = 0; capturefiles = g_ptr_array_new_with_free_func(g_free);