We use ret, err, error, and others for return codes of functions.
Standardize on 'ret' for consistency reasons for now.
{
struct sr_dev_inst *sdi;
struct context *ctx;
- int err;
+ int ret;
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
ctx = sdi->priv;
- err = snd_pcm_open(&ctx->capture_handle, AUDIO_DEV,
+ ret = snd_pcm_open(&ctx->capture_handle, AUDIO_DEV,
SND_PCM_STREAM_CAPTURE, 0);
- if (err < 0) {
+ if (ret < 0) {
sr_err("alsa: can't open audio device %s (%s)", AUDIO_DEV,
- snd_strerror(err));
+ snd_strerror(ret));
return SR_ERR;
}
- err = snd_pcm_hw_params_malloc(&ctx->hw_params);
- if (err < 0) {
+ ret = snd_pcm_hw_params_malloc(&ctx->hw_params);
+ if (ret < 0) {
sr_err("alsa: can't allocate hardware parameter structure (%s)",
- snd_strerror(err));
+ snd_strerror(ret));
return SR_ERR;
}
- err = snd_pcm_hw_params_any(ctx->capture_handle, ctx->hw_params);
- if (err < 0) {
+ ret = snd_pcm_hw_params_any(ctx->capture_handle, ctx->hw_params);
+ if (ret < 0) {
sr_err("alsa: can't initialize hardware parameter structure "
- "(%s)", snd_strerror(err));
+ "(%s)", snd_strerror(ret));
return SR_ERR;
}
struct sr_datafeed_header header;
struct pollfd *ufds;
int count;
- int err;
+ int ret;
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
ctx = sdi->priv;
- err = snd_pcm_hw_params_set_access(ctx->capture_handle,
+ ret = snd_pcm_hw_params_set_access(ctx->capture_handle,
ctx->hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
- if (err < 0) {
- sr_err("alsa: can't set access type (%s)", snd_strerror(err));
+ if (ret < 0) {
+ sr_err("alsa: can't set access type (%s)", snd_strerror(ret));
return SR_ERR;
}
/* FIXME: Hardcoded for 16bits */
- err = snd_pcm_hw_params_set_format(ctx->capture_handle,
+ ret = snd_pcm_hw_params_set_format(ctx->capture_handle,
ctx->hw_params, SND_PCM_FORMAT_S16_LE);
- if (err < 0) {
- sr_err("alsa: can't set sample format (%s)", snd_strerror(err));
+ if (ret < 0) {
+ sr_err("alsa: can't set sample format (%s)", snd_strerror(ret));
return SR_ERR;
}
- err = snd_pcm_hw_params_set_rate_near(ctx->capture_handle,
+ ret = snd_pcm_hw_params_set_rate_near(ctx->capture_handle,
ctx->hw_params, (unsigned int *)&ctx->cur_rate, 0);
- if (err < 0) {
- sr_err("alsa: can't set sample rate (%s)", snd_strerror(err));
+ if (ret < 0) {
+ sr_err("alsa: can't set sample rate (%s)", snd_strerror(ret));
return SR_ERR;
}
- err = snd_pcm_hw_params_set_channels(ctx->capture_handle,
+ ret = snd_pcm_hw_params_set_channels(ctx->capture_handle,
ctx->hw_params, NUM_PROBES);
- if (err < 0) {
- sr_err("alsa: can't set channel count (%s)", snd_strerror(err));
+ if (ret < 0) {
+ sr_err("alsa: can't set channel count (%s)", snd_strerror(ret));
return SR_ERR;
}
- err = snd_pcm_hw_params(ctx->capture_handle, ctx->hw_params);
- if (err < 0) {
- sr_err("alsa: can't set parameters (%s)", snd_strerror(err));
+ ret = snd_pcm_hw_params(ctx->capture_handle, ctx->hw_params);
+ if (ret < 0) {
+ sr_err("alsa: can't set parameters (%s)", snd_strerror(ret));
return SR_ERR;
}
- err = snd_pcm_prepare(ctx->capture_handle);
- if (err < 0) {
+ ret = snd_pcm_prepare(ctx->capture_handle);
+ if (ret < 0) {
sr_err("alsa: can't prepare audio interface for use (%s)",
- snd_strerror(err));
+ snd_strerror(ret));
return SR_ERR;
}
return SR_ERR_MALLOC;
}
- err = snd_pcm_poll_descriptors(ctx->capture_handle, ufds, count);
- if (err < 0) {
+ ret = snd_pcm_poll_descriptors(ctx->capture_handle, ufds, count);
+ if (ret < 0) {
sr_err("alsa: Unable to obtain poll descriptors (%s)",
- snd_strerror(err));
+ snd_strerror(ret));
g_free(ufds);
return SR_ERR;
}
SR_PRIV int ezusb_reset(struct libusb_device_handle *hdl, int set_clear)
{
- int err;
+ int ret;
unsigned char buf[1];
sr_info("ezusb: setting CPU reset mode %s...",
set_clear ? "on" : "off");
buf[0] = set_clear ? 1 : 0;
- err = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR, 0xa0,
+ ret = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR, 0xa0,
0xe600, 0x0000, buf, 1, 100);
- if (err < 0)
- sr_err("ezusb: Unable to send control request: %d", err);
+ if (ret < 0)
+ sr_err("ezusb: Unable to send control request: %d", ret);
- return err;
+ return ret;
}
SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
const char *filename)
{
FILE *fw;
- int offset, chunksize, err, result;
+ int offset, chunksize, ret, result;
unsigned char buf[4096];
sr_info("ezusb: Uploading firmware at %s", filename);
chunksize = fread(buf, 1, 4096, fw);
if (chunksize == 0)
break;
- err = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR |
+ ret = libusb_control_transfer(hdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, 0xa0, offset,
0x0000, buf, chunksize, 100);
- if (err < 0) {
+ if (ret < 0) {
sr_err("ezusb: Unable to send firmware to device: %d",
- err);
+ ret);
result = SR_ERR;
break;
}
const char *filename)
{
struct libusb_device_handle *hdl;
- int err;
+ int ret;
sr_info("ezusb: uploading firmware to device on %d.%d",
libusb_get_bus_number(dev), libusb_get_device_address(dev));
- if ((err = libusb_open(dev, &hdl)) < 0) {
- sr_err("ezusb: failed to open device: %d", err);
+ if ((ret = libusb_open(dev, &hdl)) < 0) {
+ sr_err("ezusb: failed to open device: %d", ret);
return SR_ERR;
}
/* Neither Windows/MinGW nor Darwin/Mac support these libusb-1.0 calls. */
#if !defined(_WIN32) && !defined(__APPLE__)
if (libusb_kernel_driver_active(hdl, 0)) {
- if ((err = libusb_detach_kernel_driver(hdl, 0)) < 0) {
- sr_err("ezusb: failed to detach kernel driver: %d", err);
+ if ((ret = libusb_detach_kernel_driver(hdl, 0)) < 0) {
+ sr_err("ezusb: failed to detach kernel driver: %d", ret);
return SR_ERR;
}
}
#endif
- if ((err = libusb_set_configuration(hdl, configuration)) < 0) {
- sr_err("ezusb: Unable to set configuration: %d", err);
+ if ((ret = libusb_set_configuration(hdl, configuration)) < 0) {
+ sr_err("ezusb: Unable to set configuration: %d", ret);
return SR_ERR;
}
struct libusb_device_descriptor des;
struct sr_dev_inst *sdi;
struct context *ctx;
- int err, skip, i;
+ int ret, skip, i;
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
skip = 0;
libusb_get_device_list(usb_context, &devlist);
for (i = 0; devlist[i]; i++) {
- if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("fx2lafw: failed to get device descriptor: %d", err);
+ if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
+ sr_err("fx2lafw: failed to get device descriptor: %d", ret);
continue;
}
continue;
}
- if (!(err = libusb_open(devlist[i], &ctx->usb->devhdl))) {
+ if (!(ret = libusb_open(devlist[i], &ctx->usb->devhdl))) {
if (ctx->usb->address == 0xff)
/*
* first time we touch this device after firmware upload,
sdi->index, ctx->usb->bus,
ctx->usb->address, USB_INTERFACE);
} else {
- sr_err("fx2lafw: failed to open device: %d", err);
+ sr_err("fx2lafw: failed to open device: %d", ret);
}
/* if we made it here, we handled the device one way or another */
const struct fx2lafw_profile *fx2lafw_prof;
struct context *ctx;
libusb_device **devlist;
- int err;
+ int ret;
int devcnt = 0;
int i, j;
libusb_get_device_list(usb_context, &devlist);
for (i = 0; devlist[i]; i++) {
- if ((err = libusb_get_device_descriptor(
+ if ((ret = libusb_get_device_descriptor(
devlist[i], &des)) != 0) {
- sr_warn("failed to get device descriptor: %d", err);
+ sr_warn("failed to get device descriptor: %d", ret);
continue;
}
GTimeVal cur_time;
struct sr_dev_inst *sdi;
struct context *ctx;
- int timediff, err;
+ int timediff, ret;
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
* if the firmware was recently uploaded, wait up to MAX_RENUM_DELAY ms
* for the FX2 to renumerate
*/
- err = 0;
+ ret = 0;
if (GTV_TO_MSEC(ctx->fw_updated) > 0) {
sr_info("fx2lafw: waiting for device to reset");
/* takes at least 300ms for the FX2 to be gone from the USB bus */
g_usleep(300 * 1000);
timediff = 0;
while (timediff < MAX_RENUM_DELAY) {
- if ((err = fx2lafw_open_dev(dev_index)) == SR_OK)
+ if ((ret = fx2lafw_open_dev(dev_index)) == SR_OK)
break;
g_usleep(100 * 1000);
g_get_current_time(&cur_time);
}
sr_info("fx2lafw: device came back after %d ms", timediff);
} else {
- err = fx2lafw_open_dev(dev_index);
+ ret = fx2lafw_open_dev(dev_index);
}
- if (err != SR_OK) {
+ if (ret != SR_OK) {
sr_err("fx2lafw: unable to open device");
return SR_ERR;
}
ctx = sdi->priv;
- err = libusb_claim_interface(ctx->usb->devhdl, USB_INTERFACE);
- if (err != 0) {
- sr_err("fx2lafw: Unable to claim interface: %d", err);
+ ret = libusb_claim_interface(ctx->usb->devhdl, USB_INTERFACE);
+ if (ret != 0) {
+ sr_err("fx2lafw: Unable to claim interface: %d", ret);
return SR_ERR;
}
struct context *ctx;
struct libusb_transfer *transfer;
const struct libusb_pollfd **lupfd;
- int err, size, i;
+ int ret, size, i;
unsigned char *buf;
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
g_free(header);
g_free(packet);
- if ((err = command_start_acquisition (ctx->usb->devhdl,
+ if ((ret = command_start_acquisition (ctx->usb->devhdl,
ctx->cur_samplerate)) != SR_OK) {
- return err;
+ return ret;
}
return SR_OK;
struct libusb_device_descriptor des;
struct sr_dev_inst *sdi;
struct context *ctx;
- int err, skip, i;
+ int ret, skip, i;
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
skip = 0;
libusb_get_device_list(usb_context, &devlist);
for (i = 0; devlist[i]; i++) {
- if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("logic: failed to get device descriptor: %d", err);
+ if ((ret = libusb_get_device_descriptor(devlist[i], &des))) {
+ sr_err("logic: failed to get device descriptor: %d", ret);
continue;
}
continue;
}
- if (!(err = libusb_open(devlist[i], &ctx->usb->devhdl))) {
+ if (!(ret = libusb_open(devlist[i], &ctx->usb->devhdl))) {
if (ctx->usb->address == 0xff)
/*
* first time we touch this device after firmware upload,
sdi->index, ctx->usb->bus,
ctx->usb->address, USB_INTERFACE);
} else {
- sr_err("logic: failed to open device: %d", err);
+ sr_err("logic: failed to open device: %d", ret);
}
/* if we made it here, we handled the device one way or another */
struct fx2_profile *fx2_prof;
struct context *ctx;
libusb_device **devlist;
- int err, devcnt, i, j;
+ int ret, devcnt, i, j;
/* Avoid compiler warnings. */
(void)devinfo;
libusb_get_device_list(usb_context, &devlist);
for (i = 0; devlist[i]; i++) {
fx2_prof = NULL;
- err = libusb_get_device_descriptor(devlist[i], &des);
- if (err != 0) {
+ ret = libusb_get_device_descriptor(devlist[i], &des);
+ if (ret != 0) {
sr_err("logic: failed to get device descriptor: %d",
- err);
+ ret);
continue;
}
GTimeVal cur_time;
struct sr_dev_inst *sdi;
struct context *ctx;
- int timediff, err;
+ int timediff, ret;
if (!(sdi = sr_dev_inst_get(dev_insts, dev_index)))
return SR_ERR;
* if the firmware was recently uploaded, wait up to MAX_RENUM_DELAY ms
* for the FX2 to renumerate
*/
- err = 0;
+ ret = 0;
if (GTV_TO_MSEC(ctx->fw_updated) > 0) {
sr_info("logic: waiting for device to reset");
/* takes at least 300ms for the FX2 to be gone from the USB bus */
g_usleep(300 * 1000);
timediff = 0;
while (timediff < MAX_RENUM_DELAY) {
- if ((err = sl_open_dev(dev_index)) == SR_OK)
+ if ((ret = sl_open_dev(dev_index)) == SR_OK)
break;
g_usleep(100 * 1000);
g_get_current_time(&cur_time);
}
sr_info("logic: device came back after %d ms", timediff);
} else {
- err = sl_open_dev(dev_index);
+ ret = sl_open_dev(dev_index);
}
- if (err != SR_OK) {
+ if (ret != SR_OK) {
sr_err("logic: unable to open device");
return SR_ERR;
}
ctx = sdi->priv;
- err = libusb_claim_interface(ctx->usb->devhdl, USB_INTERFACE);
- if (err != 0) {
- sr_err("logic: Unable to claim interface: %d", err);
+ ret = libusb_claim_interface(ctx->usb->devhdl, USB_INTERFACE);
+ if (ret != 0) {
+ sr_err("logic: Unable to claim interface: %d", ret);
return SR_ERR;
}
{
struct context *ctx;
unsigned int i;
- int err;
+ int ret;
/* Note: sdi is non-NULL, the caller already checked this. */
return -1;
}
- if ((err = libusb_get_device_descriptor(dev, des))) {
- sr_err("zp: failed to get device descriptor: %d", err);
+ if ((ret = libusb_get_device_descriptor(dev, des))) {
+ sr_err("zp: failed to get device descriptor: %d", ret);
return -1;
}
}
/* Found it. */
- if (!(err = libusb_open(dev, &(ctx->usb->devhdl)))) {
+ if (!(ret = libusb_open(dev, &(ctx->usb->devhdl)))) {
(*sdi)->status = SR_ST_ACTIVE;
sr_info("zp: opened device %d on %d.%d interface %d",
(*sdi)->index, ctx->usb->bus,
ctx->usb->address, USB_INTERFACE);
} else {
- sr_err("zp: failed to open device: %d", err);
+ sr_err("zp: failed to open device: %d", ret);
*sdi = NULL;
}
}
struct sr_dev_inst *sdi;
struct libusb_device_descriptor des;
libusb_device **devlist;
- int err, devcnt, i;
+ int ret, devcnt, i;
struct context *ctx;
/* Avoid compiler warnings. */
libusb_get_device_list(usb_context, &devlist); /* TODO: Errors. */
for (i = 0; devlist[i]; i++) {
- err = libusb_get_device_descriptor(devlist[i], &des);
- if (err != 0) {
- sr_err("zp: failed to get device descriptor: %d", err);
+ ret = libusb_get_device_descriptor(devlist[i], &des);
+ if (ret != 0) {
+ sr_err("zp: failed to get device descriptor: %d", ret);
continue;
}
{
struct sr_dev_inst *sdi;
struct context *ctx;
- int err;
+ int ret;
if (!(sdi = zp_open_dev(dev_index))) {
sr_err("zp: unable to open device");
return SR_ERR_ARG;
}
- err = libusb_set_configuration(ctx->usb->devhdl, USB_CONFIGURATION);
- if (err < 0) {
+ ret = libusb_set_configuration(ctx->usb->devhdl, USB_CONFIGURATION);
+ if (ret < 0) {
sr_err("zp: Unable to set USB configuration %d: %d",
- USB_CONFIGURATION, err);
+ USB_CONFIGURATION, ret);
return SR_ERR;
}
- err = libusb_claim_interface(ctx->usb->devhdl, USB_INTERFACE);
- if (err != 0) {
- sr_err("zp: Unable to claim interface: %d", err);
+ ret = libusb_claim_interface(ctx->usb->devhdl, USB_INTERFACE);
+ if (ret != 0) {
+ sr_err("zp: Unable to claim interface: %d", ret);
return SR_ERR;
}
struct session_vdev *vdev;
struct sr_datafeed_header *header;
struct sr_datafeed_packet *packet;
- int err;
+ int ret;
if (!(vdev = get_vdev_by_index(dev_index)))
return SR_ERR;
sr_info("session_driver: opening archive %s file %s", sessionfile,
vdev->capturefile);
- if (!(vdev->archive = zip_open(sessionfile, 0, &err))) {
+ if (!(vdev->archive = zip_open(sessionfile, 0, &ret))) {
sr_err("session driver: Failed to open session file '%s': "
- "zip error %d\n", sessionfile, err);
+ "zip error %d\n", sessionfile, ret);
return SR_ERR;
}
struct zip_stat zs;
struct sr_dev *dev;
struct sr_probe *probe;
- int ret, err, probenum, devcnt, i, j;
+ int ret, probenum, devcnt, i, j;
uint64_t tmp_u64, total_probes, enabled_probes, p;
char **sections, **keys, *metafile, *val, c;
char probename[SR_MAX_PROBENAME_LEN + 1];
return SR_ERR_ARG;
}
- if (!(archive = zip_open(filename, 0, &err))) {
+ if (!(archive = zip_open(filename, 0, &ret))) {
sr_dbg("session file: Failed to open session file: zip "
- "error %d", err);
+ "error %d", ret);
return SR_ERR;
}
struct sr_datastore *ds;
struct zip *zipfile;
struct zip_source *versrc, *metasrc, *logicsrc;
- int bufcnt, devcnt, tmpfile, ret, error, probecnt;
+ int bufcnt, devcnt, tmpfile, ret, probecnt;
uint64_t samplerate;
char version[1], rawname[16], metafile[32], *buf, *s;
/* Quietly delete it first, libzip wants replace ops otherwise. */
unlink(filename);
- if (!(zipfile = zip_open(filename, ZIP_CREATE, &error)))
+ if (!(zipfile = zip_open(filename, ZIP_CREATE, &ret)))
return SR_ERR;
/* "version" */