Remove an assignment that won't take effect. Check pointers' validity
before dereferencing. Fix a memory leak.
This was reported by clang's scan-build.
Check for successful allocation of multiple memory ranges, and release
partial allocations in the error path when one of them failed. This
fixes a potential memory leak, as well as avoids NULL dereferences.
This was reported by clang's scan-build.
Silence warnings about assigned values that never get used, potential
NULL deference, and potential memory leaks.
This was reported by clang's scan-build.
The scan_2x_bd232() routine used to always prepare one spare context,
and filled it in when a device was found, just to allocate another one
and continue scanning.
Free the last allocated context unconditionally, as it was allocated
unconditionally, and never used.
This was reported by clang's scan-build.
Stick with the prepared but unfinished "limit msec" code path, but
silence the warning about an unused variable value.
This was reported by clang's scan-build.
Avoid a division by zero, by not using a zero unitsize in a modulo
operation. As a byproduct, avoid processing and counting input that
neither has analog nor logic data. This should never have happened,
but the change now catches the error if invalid input is seen.
This was reported by clang's scan-build.
The sr_packet_copy() routine could have written to an arbitrary memory
location. Make sure to allocate the space before writing to it, and
check for successful allocation before accessing the memory.
It's assumed that this error never took effect, as the routine appears
to be unused.
This was reported by clang's scan-build.
The 'opc' variable was only conditionally assigned to (depends on
successful SCPI communication). Ensure there always is a known value.
This was reported by clang's scan-build.
After the first capture ->num_frames never got to be _equal_
to ->limit_frames; fixed by resetting to zero in dev_acquisition_stop(),
and protected against similar problems in the future by switching to
greater-or-equal instead.
[Note: This patch is basically a squashed version of the initial driver
commits by Andreas Zschunke <andreas.zschunke@gmx.net>, two fixes by
Andrej Valek <andy@skyrain.eu>, and various coding style / cosmetic
fixes by Uwe Hermann <uwe@hermann-uwe.de> to make the driver a lot more
consistent with the rest of the libsigrok code-base.]
When refactoring the code, some places where sr_scpi_send was replaced
by rigol_ds_config_set the first argument was not changed from sdi->conn
to sdi. Fix the remaining ones.
Fix: https://sigrok.org/bug/1073
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
This regression was introduced in f1ba6b4b2c.
Due to how the sysclk-lwla driver does up to 3 open/close operations in
one dev_open() API callback we cannot rely on the sr_dev_open() and
sr_dev_close() wrappers setting the sdi->status variable in this case.
Tested on LWLA1034.
When processing of large VCD input files was spread across multiple
parse_contents() invocations, the resulting sigrok stream of sample data
had gaps in them and total timing was off. For instance 74ms of input
data were interpreted as spanning some 600ms or 300ms, depending on the
number of channels in the input stream.
Move the "previous timestamp" variable to the input module context. This
eliminates the inappropriate gaps and fixes the translation of VCD file
timestamps to sigrok sample numbers.
This fixes bug #1075.