yokogawa-dlm: Replace g_try_malloc() calls and fix coding style
This commit is contained in:
parent
0028d5a1ee
commit
ac10a927b5
|
@ -69,8 +69,7 @@ static struct sr_dev_inst *probe_usbtmc_device(struct sr_scpi_dev_inst *scpi)
|
|||
sr_scpi_hw_info_free(hw_info);
|
||||
hw_info = NULL;
|
||||
|
||||
if (!(devc = g_try_malloc0(sizeof(struct dev_context))))
|
||||
goto fail;
|
||||
devc = g_malloc0(sizeof(struct dev_context));
|
||||
|
||||
sdi->driver = di;
|
||||
sdi->priv = devc;
|
||||
|
@ -570,7 +569,7 @@ static int dlm_setup_channels(const struct sr_dev_inst *sdi)
|
|||
model = devc->model_config;
|
||||
setup_changed = FALSE;
|
||||
|
||||
pod_enabled = g_try_malloc0(sizeof(gboolean) * model->pods);
|
||||
pod_enabled = g_malloc0(sizeof(gboolean) * model->pods);
|
||||
|
||||
for (l = sdi->channels; l; l = l->next) {
|
||||
ch = l->data;
|
||||
|
@ -635,7 +634,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
|||
|
||||
(void)cb_data;
|
||||
|
||||
if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED;
|
||||
if (sdi->status != SR_ST_ACTIVE)
|
||||
return SR_ERR_DEV_CLOSED;
|
||||
|
||||
scpi = sdi->conn;
|
||||
devc = sdi->priv;
|
||||
|
@ -708,7 +708,7 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data)
|
|||
|
||||
SR_PRIV struct sr_dev_driver yokogawa_dlm_driver_info = {
|
||||
.name = "yokogawa-dlm",
|
||||
.longname = "Yokogawa DL/DLM driver",
|
||||
.longname = "Yokogawa DL/DLM",
|
||||
.api_version = 1,
|
||||
.init = init,
|
||||
.cleanup = cleanup,
|
||||
|
|
|
@ -328,6 +328,7 @@ static int array_float_get(gchar *value, const uint64_t array[][2],
|
|||
int i;
|
||||
uint64_t f;
|
||||
float s;
|
||||
unsigned int s_int;
|
||||
gchar ss[10], es[10];
|
||||
|
||||
memset(ss, 0, sizeof(ss));
|
||||
|
@ -350,10 +351,10 @@ static int array_float_get(gchar *value, const uint64_t array[][2],
|
|||
while ((int)fmod(log10(f), 3) > 0) { s *= 10; f *= 10; }
|
||||
|
||||
/* Truncate s to circumvent rounding errors. */
|
||||
s = (int)s;
|
||||
s_int = (unsigned int)s;
|
||||
|
||||
for (i = 0; i < array_len; i++) {
|
||||
if ( (s == array[i][0]) && (f == array[i][1]) ) {
|
||||
if ( (s_int == array[i][0]) && (f == array[i][1]) ) {
|
||||
*result = i;
|
||||
return SR_OK;
|
||||
}
|
||||
|
@ -583,14 +584,13 @@ SR_PRIV int dlm_scope_state_query(struct sr_dev_inst *sdi)
|
|||
*
|
||||
* @param config The device configuration to use.
|
||||
*
|
||||
* @return The newly allocated scope_state struct or NULL on error.
|
||||
* @return The newly allocated scope_state struct.
|
||||
*/
|
||||
static struct scope_state *dlm_scope_state_new(struct scope_config *config)
|
||||
{
|
||||
struct scope_state *state;
|
||||
|
||||
if (!(state = g_try_malloc0(sizeof(struct scope_state))))
|
||||
return NULL;
|
||||
state = g_malloc0(sizeof(struct scope_state));
|
||||
|
||||
state->analog_states = g_malloc0(config->analog_channels *
|
||||
sizeof(struct analog_channel_state));
|
||||
|
|
|
@ -79,8 +79,6 @@ struct scope_config {
|
|||
|
||||
const uint8_t num_xdivs;
|
||||
const uint8_t num_ydivs;
|
||||
|
||||
const char *(*scpi_dialect)[];
|
||||
};
|
||||
|
||||
struct analog_channel_state {
|
||||
|
|
Loading…
Reference in New Issue