sr: s/err/ret/ for consistency.

We use ret, err, error, and others for return codes of functions.
Standardize on 'ret' for consistency reasons for now.
This commit is contained in:
Uwe Hermann 2012-03-20 17:51:18 +01:00
parent d6eb0c333c
commit ebc3473882
7 changed files with 108 additions and 108 deletions

View File

@ -99,31 +99,31 @@ static int hw_dev_open(int dev_index)
{
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;
}
@ -301,51 +301,51 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
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;
}
@ -360,10 +360,10 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
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;
}

View File

@ -32,25 +32,25 @@
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);
@ -66,12 +66,12 @@ SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
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;
}
@ -88,28 +88,28 @@ SR_PRIV int ezusb_upload_firmware(libusb_device *dev, int configuration,
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;
}

View File

@ -160,7 +160,7 @@ static int fx2lafw_open_dev(int dev_index)
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;
@ -173,8 +173,8 @@ static int fx2lafw_open_dev(int dev_index)
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;
}
@ -199,7 +199,7 @@ static int fx2lafw_open_dev(int dev_index)
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,
@ -212,7 +212,7 @@ static int fx2lafw_open_dev(int dev_index)
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 */
@ -266,7 +266,7 @@ static int hw_init(const char *deviceinfo)
const struct fx2lafw_profile *fx2lafw_prof;
struct context *ctx;
libusb_device **devlist;
int err;
int ret;
int devcnt = 0;
int i, j;
@ -282,9 +282,9 @@ static int hw_init(const char *deviceinfo)
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;
}
@ -342,7 +342,7 @@ static int hw_dev_open(int dev_index)
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;
@ -352,14 +352,14 @@ static int hw_dev_open(int dev_index)
* 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);
@ -367,18 +367,18 @@ static int hw_dev_open(int dev_index)
}
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;
}
@ -618,7 +618,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
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)))
@ -673,9 +673,9 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
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;

View File

@ -177,7 +177,7 @@ static int sl_open_dev(int dev_index)
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;
@ -190,8 +190,8 @@ static int sl_open_dev(int dev_index)
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;
}
@ -216,7 +216,7 @@ static int sl_open_dev(int dev_index)
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,
@ -229,7 +229,7 @@ static int sl_open_dev(int dev_index)
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 */
@ -332,7 +332,7 @@ static int hw_init(const char *devinfo)
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;
@ -347,10 +347,10 @@ static int hw_init(const char *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;
}
@ -404,7 +404,7 @@ static int hw_dev_open(int dev_index)
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;
@ -414,14 +414,14 @@ static int hw_dev_open(int dev_index)
* 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);
@ -429,18 +429,18 @@ static int hw_dev_open(int dev_index)
}
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;
}

View File

@ -176,7 +176,7 @@ static int opendev4(struct sr_dev_inst **sdi, libusb_device *dev,
{
struct context *ctx;
unsigned int i;
int err;
int ret;
/* Note: sdi is non-NULL, the caller already checked this. */
@ -185,8 +185,8 @@ static int opendev4(struct sr_dev_inst **sdi, libusb_device *dev,
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;
}
@ -214,13 +214,13 @@ static int opendev4(struct sr_dev_inst **sdi, libusb_device *dev,
}
/* 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;
}
}
@ -330,7 +330,7 @@ static int hw_init(const char *devinfo)
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. */
@ -362,9 +362,9 @@ static int hw_init(const char *devinfo)
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;
}
@ -402,7 +402,7 @@ static int hw_dev_open(int dev_index)
{
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");
@ -416,16 +416,16 @@ static int hw_dev_open(int dev_index)
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;
}

View File

@ -274,7 +274,7 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
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;
@ -282,9 +282,9 @@ static int hw_dev_acquisition_start(int dev_index, void *cb_data)
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;
}

View File

@ -48,7 +48,7 @@ SR_API int sr_session_load(const char *filename)
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];
@ -58,9 +58,9 @@ SR_API int sr_session_load(const char *filename)
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;
}
@ -176,7 +176,7 @@ int sr_session_save(const char *filename)
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;
@ -187,7 +187,7 @@ int sr_session_save(const char *filename)
/* 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" */