From: Uwe Hermann Date: Wed, 21 Mar 2012 18:28:43 +0000 (+0100) Subject: sr/srd: Small fixes, constifications, doc updates. X-Git-Tag: libsigrok-0.1.0~36 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8ec95d22822ed5ebf4b6aeaff654608ad0225073;p=libsigrok.git sr/srd: Small fixes, constifications, doc updates. --- diff --git a/datastore.c b/datastore.c index 96d830b4..36bde281 100644 --- a/datastore.c +++ b/datastore.c @@ -128,16 +128,12 @@ SR_API int sr_datastore_destroy(struct sr_datastore *ds) * is returned, the value/state of 'ds' is undefined. */ SR_API int sr_datastore_put(struct sr_datastore *ds, void *data, - unsigned int length, int in_unitsize, int *probelist) + unsigned int length, int in_unitsize, const int *probelist) { unsigned int stored; int capacity, size, num_chunks, chunk_bytes_free, chunk_offset; gpointer chunk; - /* Avoid compiler warnings. */ - (void)in_unitsize; - (void)probelist; - if (!ds) { sr_err("ds: %s: ds was NULL", __func__); return SR_ERR_ARG; diff --git a/device.c b/device.c index ba29adb5..99e9c378 100644 --- a/device.c +++ b/device.c @@ -357,10 +357,10 @@ SR_API int sr_dev_trigger_set(struct sr_dev *dev, int probenum, /** * Determine whether the specified device has the specified capability. * - * TODO: Should return int? - * * @param dev Pointer to the device to be checked. Must not be NULL. - * The device's 'driver' field must not be NULL either. + * If the device's 'driver' field is NULL (virtual device), this + * function will always return FALSE (virtual devices don't have + * a hardware capabilities list). * @param hwcap The capability that should be checked (whether it's supported * by the specified device). * @@ -376,7 +376,7 @@ SR_API gboolean sr_dev_has_hwcap(const struct sr_dev *dev, int hwcap) if (!dev) { sr_err("dev: %s: dev was NULL", __func__); - return FALSE; /* TODO: SR_ERR_ARG. */ + return FALSE; } /* @@ -386,14 +386,14 @@ SR_API gboolean sr_dev_has_hwcap(const struct sr_dev *dev, int hwcap) if (!dev->driver) { sr_dbg("dev: %s: dev->driver was NULL, this seems to be " "a virtual device without capabilities", __func__); - return FALSE; /* TODO: SR_ERR_ARG. */ + return FALSE; } /* TODO: Sanity check on 'hwcap'. */ if (!(hwcaps = dev->driver->hwcap_get_all())) { sr_err("dev: %s: dev has no capabilities", __func__); - return FALSE; /* TODO: SR_ERR*. */ + return FALSE; } for (i = 0; hwcaps[i]; i++) { diff --git a/output/analog.c b/output/analog.c index 762fdfc5..20f680f0 100644 --- a/output/analog.c +++ b/output/analog.c @@ -41,7 +41,7 @@ struct context { unsigned int unitsize; int line_offset; int linebuf_len; - char *probelist[65]; + char *probelist[SR_MAX_NUM_PROBES + 1]; char *linebuf; int spl_cnt; uint8_t *linevalues; diff --git a/output/text/text.h b/output/text/text.h index 4ec26985..8dcb45d2 100644 --- a/output/text/text.h +++ b/output/text/text.h @@ -36,7 +36,7 @@ struct context { unsigned int unitsize; int line_offset; int linebuf_len; - char *probelist[65]; + char *probelist[SR_MAX_NUM_PROBES + 1]; char *linebuf; int spl_cnt; uint8_t *linevalues; diff --git a/output/vcd.c b/output/vcd.c index 91f72c13..0840c589 100644 --- a/output/vcd.c +++ b/output/vcd.c @@ -29,7 +29,7 @@ struct context { int num_enabled_probes; int unitsize; - char *probelist[65]; + char *probelist[SR_MAX_NUM_PROBES + 1]; int *prevbits; GString *header; uint64_t prevsample; diff --git a/session.c b/session.c index ffa7e072..8048fdfd 100644 --- a/session.c +++ b/session.c @@ -145,7 +145,7 @@ SR_API int sr_session_dev_add(struct sr_dev *dev) if (!dev->driver->dev_open) { sr_err("session: %s: dev->driver->dev_open was NULL", __func__); - return SR_ERR_ARG; + return SR_ERR_BUG; } if ((ret = dev->driver->dev_open(dev->driver_index)) != SR_OK) { diff --git a/sigrok-proto.h b/sigrok-proto.h index c357e389..0913f898 100644 --- a/sigrok-proto.h +++ b/sigrok-proto.h @@ -43,7 +43,7 @@ SR_API int sr_datastore_new(int unitsize, struct sr_datastore **ds); SR_API int sr_datastore_destroy(struct sr_datastore *ds); SR_API int sr_datastore_put(struct sr_datastore *ds, void *data, unsigned int length, int in_unitsize, - int *probelist); + const int *probelist); /*--- device.c --------------------------------------------------------------*/