sr: code cleanup

This commit is contained in:
Bert Vermeulen 2012-02-28 17:47:02 +01:00
parent d261dbbfcc
commit 2285cf9bc5
6 changed files with 5 additions and 15 deletions

View File

@ -233,7 +233,7 @@ static struct sr_dev_inst *zp_open_dev(int dev_index)
struct sr_dev_inst *sdi; struct sr_dev_inst *sdi;
libusb_device **devlist; libusb_device **devlist;
struct libusb_device_descriptor des; struct libusb_device_descriptor des;
int err, i; int i;
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index))) if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return NULL; return NULL;
@ -244,7 +244,7 @@ static struct sr_dev_inst *zp_open_dev(int dev_index)
libusb_get_device_list(usb_context, &devlist); libusb_get_device_list(usb_context, &devlist);
for (i = 0; devlist[i]; i++) { for (i = 0; devlist[i]; i++) {
/* TODO: Error handling. */ /* TODO: Error handling. */
err = opendev4(&sdi, devlist[i], &des); opendev4(&sdi, devlist[i], &des);
} }
} else { } else {
/* Status must be SR_ST_ACTIVE, i.e. already in use... */ /* Status must be SR_ST_ACTIVE, i.e. already in use... */

View File

@ -154,7 +154,7 @@ static int loadfile(struct sr_input *in, const char *filename)
for (i = 0; i < NUM_PACKETS; i++) { for (i = 0; i < NUM_PACKETS; i++) {
/* TODO: Handle errors, handle incomplete reads. */ /* TODO: Handle errors, handle incomplete reads. */
size = read(fd, buf, PACKET_SIZE); size = read(fd, buf, PACKET_SIZE);
logic.length = PACKET_SIZE; logic.length = size;
sr_session_bus(in->vdev, &packet); sr_session_bus(in->vdev, &packet);
} }
close(fd); /* FIXME */ close(fd); /* FIXME */

View File

@ -86,7 +86,6 @@ static int init(struct sr_output *o)
struct context *ctx; struct context *ctx;
struct sr_probe *probe; struct sr_probe *probe;
GSList *l; GSList *l;
int num_probes;
uint64_t samplerate; uint64_t samplerate;
if (!o) { if (!o) {
@ -111,7 +110,7 @@ static int init(struct sr_output *o)
o->internal = ctx; o->internal = ctx;
/* Get the number of probes, their names, and the unitsize. */ /* Get the probe names and the unitsize. */
/* TODO: Error handling. */ /* TODO: Error handling. */
for (l = o->dev->probes; l; l = l->next) { for (l = o->dev->probes; l; l = l->next) {
probe = l->data; probe = l->data;
@ -122,8 +121,6 @@ static int init(struct sr_output *o)
ctx->probelist[ctx->num_enabled_probes] = 0; ctx->probelist[ctx->num_enabled_probes] = 0;
ctx->unitsize = (ctx->num_enabled_probes + 7) / 8; 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)) { if (sr_dev_has_hwcap(o->dev, SR_HWCAP_SAMPLERATE)) {
samplerate = *((uint64_t *) o->dev->plugin->dev_info_get( samplerate = *((uint64_t *) o->dev->plugin->dev_info_get(
o->dev->plugin_index, SR_DI_CUR_SAMPLERATE)); o->dev->plugin_index, SR_DI_CUR_SAMPLERATE));

View File

@ -148,8 +148,6 @@ static int init(struct sr_output *o)
static int event(struct sr_output *o, int event_type, char **data_out, static int event(struct sr_output *o, int event_type, char **data_out,
uint64_t *length_out) uint64_t *length_out)
{ {
struct context *ctx;
if (!o) { if (!o) {
sr_err("gnuplot out: %s: o was NULL", __func__); sr_err("gnuplot out: %s: o was NULL", __func__);
return SR_ERR_ARG; 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; return SR_ERR_ARG;
} }
ctx = o->internal;
switch (event_type) { switch (event_type) {
case SR_DF_TRIGGER: case SR_DF_TRIGGER:
/* TODO: Can a trigger mark be in a gnuplot data file? */ /* TODO: Can a trigger mark be in a gnuplot data file? */

View File

@ -138,10 +138,8 @@ static int init(struct sr_output *o)
static int event(struct sr_output *o, int event_type, char **data_out, static int event(struct sr_output *o, int event_type, char **data_out,
uint64_t *length_out) uint64_t *length_out)
{ {
struct context *ctx;
char *outbuf; char *outbuf;
ctx = o->internal;
switch (event_type) { switch (event_type) {
case SR_DF_END: case SR_DF_END:
outbuf = g_strdup("$dumpoff\n$end\n"); outbuf = g_strdup("$dumpoff\n$end\n");

View File

@ -46,7 +46,6 @@ SR_API int sr_session_load(const char *filename)
struct zip *archive; struct zip *archive;
struct zip_file *zf; struct zip_file *zf;
struct zip_stat zs; struct zip_stat zs;
struct sr_session *session;
struct sr_dev *dev; struct sr_dev *dev;
struct sr_probe *probe; struct sr_probe *probe;
int ret, err, probenum, devcnt, i, j; int ret, err, probenum, devcnt, i, j;
@ -98,7 +97,7 @@ SR_API int sr_session_load(const char *filename)
return SR_ERR; return SR_ERR;
} }
session = sr_session_new(); sr_session_new();
devcnt = 0; devcnt = 0;
capturefiles = g_ptr_array_new_with_free_func(g_free); capturefiles = g_ptr_array_new_with_free_func(g_free);