Skip to content
Snippets Groups Projects
Commit 5de558bb authored by Lucas Russo's avatar Lucas Russo
Browse files

hal/sm_io/*/acq/sm_io_acq_exp.c: fix maximum channel error check

First, we need to check if the received argument is within the
valid range. Only later, we must proceed...

This fixes #33 github issue
parent 72b732f9
No related branches found
No related tags found
No related merge requests found
......@@ -64,13 +64,6 @@ static int _acq_data_acquire (void *owner, void *args, void *ret)
uint32_t num_samples = *(uint32_t *) EXP_MSG_ZMQ_FIRST_ARG(args);
uint32_t chan = *(uint32_t *) EXP_MSG_ZMQ_NEXT_ARG(args);
/* number of samples required is out of the maximum limit */
if (num_samples > SMIO_ACQ_HANDLER(self)->acq_buf[chan].max_samples-1) {
DBE_DEBUG (DBG_SM_IO | DBG_LVL_WARN, "[sm_io:acq] data_acquire: "
"Number of samples required is out of the maximum limit\n");
return -ACQ_NUM_SAMPLES_OOR;
}
/* channel required is out of the limit */
if (chan > SMIO_ACQ_NUM_CHANNELS-1) {
DBE_DEBUG (DBG_SM_IO | DBG_LVL_WARN, "[sm_io:acq] data_acquire: "
......@@ -79,6 +72,13 @@ static int _acq_data_acquire (void *owner, void *args, void *ret)
return -ACQ_NUM_SAMPLES_OOR;
}
/* number of samples required is out of the maximum limit */
if (num_samples > SMIO_ACQ_HANDLER(self)->acq_buf[chan].max_samples-1) {
DBE_DEBUG (DBG_SM_IO | DBG_LVL_WARN, "[sm_io:acq] data_acquire: "
"Number of samples required is out of the maximum limit\n");
return -ACQ_NUM_SAMPLES_OOR;
}
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:acq] data_acquire: "
"Current acq params: number of samples = %u, channel = %u\n",
num_samples, chan);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment