Various NULL-check consistency fixes.

This commit is contained in:
Uwe Hermann 2015-03-23 20:09:08 +01:00
parent a95f142e88
commit 98fec29ecb
16 changed files with 21 additions and 21 deletions

View File

@ -57,7 +57,7 @@ SR_PRIV int ezusb_install_firmware(libusb_device_handle *hdl,
unsigned char buf[4096];
sr_info("Uploading firmware at %s", filename);
if ((fw = g_fopen(filename, "rb")) == NULL) {
if (!(fw = g_fopen(filename, "rb"))) {
sr_err("Unable to open firmware file %s for reading: %s",
filename, strerror(errno));
return SR_ERR;

View File

@ -115,7 +115,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
* Let's assume there's no ACME device present if no probe
* has been registered.
*/
if (sdi->channel_groups == NULL)
if (!sdi->channel_groups)
goto err_out;
devices = g_slist_append(devices, sdi);

View File

@ -365,7 +365,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi,
if (devc->limit_samples > 0)
pre_trigger_samples = devc->capture_ratio * devc->limit_samples/100;
devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples);
if (devc->stl == NULL)
if (!devc->stl)
return SR_ERR_MALLOC;
devc->trigger_fired = FALSE;
} else

View File

@ -426,7 +426,7 @@ static int dev_close(struct sr_dev_inst *sdi)
struct sr_usb_dev_inst *usb;
usb = sdi->conn;
if (usb->devhdl == NULL)
if (!usb->devhdl)
return SR_ERR;
sr_info("fx2lafw: Closing device on %d.%d (logical) / %s (physical) interface %d.",
@ -629,7 +629,7 @@ static int start_transfers(const struct sr_dev_inst *sdi)
if (devc->limit_samples > 0)
pre_trigger_samples = devc->capture_ratio * devc->limit_samples/100;
devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples);
if (devc->stl == NULL)
if (!devc->stl)
return SR_ERR_MALLOC;
devc->trigger_fired = FALSE;
} else

View File

@ -57,7 +57,7 @@ int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
}
buf = g_malloc(FW_BUFSIZE);
if ((fw = g_fopen(filename, "rb")) == NULL) {
if (!(fw = g_fopen(filename, "rb"))) {
sr_err("Unable to open %s for reading: %s.", filename, strerror(errno));
return SR_ERR;
}

View File

@ -185,7 +185,7 @@ SR_PRIV void dso_close(struct sr_dev_inst *sdi)
usb = sdi->conn;
if (usb->devhdl == NULL)
if (!usb->devhdl)
return;
sr_info("Closing device on %d.%d (logical) / %s (physical) interface %d.",

View File

@ -77,7 +77,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
usb_devices = sr_usb_find(drvc->sr_ctx->libusb_ctx, USB_VID_PID);
if (usb_devices == NULL)
if (!usb_devices)
return NULL;
for (l = usb_devices; l; l = l->next) {

View File

@ -116,7 +116,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
}
if (!conn)
conn = SERIALCONN;
if (serialcomm == NULL)
if (!serialcomm)
serialcomm = SERIALCOMM;
udev = udev_new();

View File

@ -336,7 +336,7 @@ SR_PRIV int mso_check_trigger(struct sr_serial_dev_inst *serial, uint8_t *info)
sr_dbg("Requesting trigger state.");
ret = mso_send_control_message(serial, ARRAY_AND_SIZE(ops));
if (info == NULL || ret != SR_OK)
if (!info || ret != SR_OK)
return ret;
uint8_t buf = 0;

View File

@ -123,7 +123,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
if (!conn)
return NULL;
if (serialcomm == NULL)
if (!serialcomm)
serialcomm = SERIALCOMM;
serial = sr_serial_dev_inst_new(conn, serialcomm);

View File

@ -398,7 +398,7 @@ static int dev_close(struct sr_dev_inst *sdi)
struct sr_usb_dev_inst *usb;
usb = sdi->conn;
if (usb->devhdl == NULL)
if (!usb->devhdl)
return SR_ERR;
sr_info("Closing device on %d.%d (logical) / %s (physical) interface %d.",
@ -738,7 +738,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
if (devc->limit_samples > 0)
pre_trigger_samples = devc->capture_ratio * devc->limit_samples/100;
devc->stl = soft_trigger_logic_new(sdi, trigger, pre_trigger_samples);
if (devc->stl == NULL)
if (!devc->stl)
return SR_ERR_MALLOC;
devc->trigger_fired = FALSE;
} else

View File

@ -107,7 +107,7 @@ static int do_ep1_command(const struct sr_dev_inst *sdi,
usb = sdi->conn;
if (cmd_len < 1 || cmd_len > 64 || reply_len > 64 ||
command == NULL || (reply_len > 0 && reply == NULL))
!command || (reply_len > 0 && !reply))
return SR_ERR_ARG;
encrypt(buf, command, cmd_len);
@ -165,7 +165,7 @@ static int upload_led_table(const struct sr_dev_inst *sdi,
uint8_t chunk, command[64];
int ret;
if (cnt < 1 || cnt + offset > 64 || table == NULL)
if (cnt < 1 || cnt + offset > 64 || !table)
return SR_ERR_ARG;
while (cnt > 0) {
@ -351,7 +351,7 @@ static int upload_fpga_bitstream(const struct sr_dev_inst *sdi,
}
sr_info("Uploading FPGA bitstream at %s.", filename);
if ((fw = g_fopen(filename, "rb")) == NULL) {
if (!(fw = g_fopen(filename, "rb"))) {
sr_err("Unable to open bitstream file %s for reading: %s.",
filename, strerror(errno));
return SR_ERR;

View File

@ -54,8 +54,8 @@ static GSList *scpi_serial_scan(struct drv_context *drvc)
(void)drvc;
for (i = 0; i < ARRAY_SIZE(scpi_serial_usb_ids); i++) {
if ((l = sr_serial_find_usb(scpi_serial_usb_ids[i].vendor_id,
scpi_serial_usb_ids[i].product_id)) == NULL)
if (!(l = sr_serial_find_usb(scpi_serial_usb_ids[i].vendor_id,
scpi_serial_usb_ids[i].product_id)))
continue;
for (r = l; r; r = r->next) {
if (scpi_serial_usb_ids[i].serialcomm)

View File

@ -66,7 +66,7 @@ static int scpi_vxi_open(void *priv)
Create_LinkResp *link_resp;
vxi->client = clnt_create(vxi->address, DEVICE_CORE, DEVICE_CORE_VERSION, "tcp");
if (vxi->client == NULL) {
if (!vxi->client) {
sr_err("Client creation failed for %s", vxi->address);
return SR_ERR;
}

View File

@ -40,7 +40,7 @@ SR_PRIV struct soft_trigger_logic *soft_trigger_logic_new(
stl->pre_trigger_buffer = g_malloc(stl->pre_trigger_size);
stl->pre_trigger_head = stl->pre_trigger_buffer;
if (stl->pre_trigger_size > 0 && stl->pre_trigger_buffer == NULL) {
if (stl->pre_trigger_size > 0 && !stl->pre_trigger_buffer) {
soft_trigger_logic_free(stl);
return NULL;
}

View File

@ -246,7 +246,7 @@ SR_API char *sr_si_string_u64(uint64_t x, const char *unit)
const char *p, prefix[] = "\0kMGTPE";
char fmt[16], fract[20] = "", *f;
if (unit == NULL)
if (!unit)
unit = "";
for (i = 0; (quot = x / divisor[i]) >= 1000; i++);