Commit Graph

4773 Commits

Author SHA1 Message Date
Frank Stettner a7e48f3c06 korad-kaxxxxp: Simplify korad_kaxxxxp_receive_data() event loop function. 2018-02-11 23:16:37 +01:00
Frank Stettner 8f39d5698d korad-kaxxxxp: Use locale independent sr_snprintf_ascii() function 2018-02-11 23:15:52 +01:00
Frank Stettner 3f9b48ae5f korad-kaxxxxp: Synchronize read and write operations. 2018-02-11 23:15:52 +01:00
Frank Stettner 23165d7bb2 korad-kaxxxxp: Add two channels "V" and "I", remove channel "CH1" 2018-02-11 23:15:52 +01:00
Frank Stettner 16e88c6b93 tests: Tests for the locale independent sr_vsnprintf_ascii() function. 2018-02-11 23:15:52 +01:00
Frank Stettner 79034d4f39 strutil: Locale independent snprintf() and vsnprintf() functions 2018-02-11 23:15:39 +01:00
Gerhard Sittig eac9fcd268 hameg-hmo: fix potential NULL dereference
Check for successful allocation before accessing struct members. Return
with an error from device initialization when allocation fails.

This was reported by clang's scan-build.
2018-02-10 15:34:20 +01:00
Gerhard Sittig addbb09bf8 hameg-hmo: fix potential memory leak
Make sure to release the allocated "pod enabled" memory, too, when SCPI
communication during channel setup fails. Defer the return with an error
(instead of duplicating the free() invocation).

This was reported by clang's scan-build.
2018-02-10 15:34:01 +01:00
Gerhard Sittig f396351704 output/srzip: fix potential "use after free"
The compiler marks a potential use after free, which the current
implementation won't trigger. The error only occurs when a sigrok
channel is neither logic nor analog.

Address the issue nevertheless, to silence the compiler warning, and to
protect against possible programming errors when a future implementation
should support more channel types.

This was reported by clang's scan-build.
2018-02-10 15:33:23 +01:00
Gerhard Sittig 499f5045dd session: fix another potential memory leak
This was reported by clang's scan-build.
2018-02-10 15:32:03 +01:00
Gerhard Sittig 972398f471 output/wav: fixup coding style nits, adjust data types
Fixup unbalanced braces for more complex if statements, to better
reflect the project's official coding style.

Adjust data types in the float_to_le() routine. A float value gets
copied to a buffer of bytes (uint8_t). Don't use 'char' on the other
side of assignments, to not assume a specific width for char, and to
avoid potential signedness issues. Copy from bytes to bytes instead.
2018-02-09 22:40:58 +01:00
Gerhard Sittig 23eeac46ed output/wav: change default for scale factor from 0.0 to 1.0
The WAV output module supports an optional 'scale' factor, in its
absence the samples will pass unmodified. The builtin help text is
unexpected, and reads:

  $ sigrok-cli -O wav --show
  ...
  Options:
    scale: Scale values by factor (default 0.0)

Setup a default scale factor of 1.0, which results in identical
behaviour and better reflects what is happening.
2018-02-09 22:40:58 +01:00
Gerhard Sittig aa0979482f output/vcd: assume packed input data image, unbreak 2nd+ channel
The previous implementation only emitted data for the first enabled
channels, and "saw no changes" after emission of the initial value for
channels on positions that followed a disabled channel.

Assume that the received data from the session bus communicates the bits
of enabled channels in a packed representation. Skip the mapping of
output bit indices to sigrok channel numbers.

This fixes the remaining part of bug #519.

Tested by inspecting in gtkwave the result of command:
  $ sigrok-cli -d demo -C D1,D3,D6 -c samplerate=2M --samples 2500 -O vcd -o trace.vcd

When we find that all input sources (device drivers, and input modules)
provide a dense bit field, all of the mapping logic can get removed
here. This commit just quickly disables the logic.
2018-02-09 22:40:58 +01:00
Gerhard Sittig a299a95413 output/vcd: assign adjacent names to enabled channels
Identifiers for channels in the VCD header section could be "sparse"
when sigrok channels were disabled. Make sure to not assign names to
disabled channels. This will e.g. assign !, ", and # to channels D1, D3,
and D6, when D0, D2, D4-D5, and D7 are disabled.

This addresses part of bug #519.
2018-02-09 22:40:58 +01:00
Gerhard Sittig 64aa214a22 several DMMs: set DC flag for diode mode
Few DMM drivers already did it. This commit adjusts the remaining DMM
drivers, to set the "DC" flag for measurements in diode mode.

This fixes bug #144.

Although I don't have the hardware to test, the nature of the change and
the arrangement of driver code suggests it's good. When a meter already
communicated the "DC" status, the change does nothing and won't harm.
The change ensures "DC" is flagged for those meters which previously
didn't, which is desirable.
2018-02-09 22:40:58 +01:00
Gerhard Sittig b8278e0943 strutil: accept trailing whitespace after number text
Some SCPI based drivers fail to convert response data, because strutil
conversion helpers sr_atol() and sr_atof() don't like trailing spaces
after the number's text that successfully got converted.

It's yet to get determined whether all call sites of the conversion
routines like their eating adjacent whitespace. But given that the
conversion routine explicitly checks for end of the string after the
number, no call site should expect or even depend on trailing text to
keep its whitespace.

See bug #788 for a discussion and example data.
2018-02-09 22:40:58 +01:00
Gerhard Sittig 751ba4c8ed strutil: support tera/peta/exa suffixes in symbolic size specs
Synchronize sr_parse_sizestring() with sr_si_string_u64() capabilities.
Add support for the T/P/E suffixes. Since this conversion helper deals
with integer values exclusively, there is no issue with case insensitive
matches. The value cannot be pico. Neither is there an ambiguity with
the 10e6 notation.

This addresses bug #763.

Fix a style nit while we are here. Put braces around both arms of a
complex conditional.
2018-02-09 22:40:50 +01:00
Gerhard Sittig 57a88297dd beaglelogic: silence compiler warning
Explicitly assign NULL to param to avoid the "may be used uninitialized"
warning reported in bug #1094. Behaviour remains unchanged. All references
to the variable were under "if (!conn)", and the assigning arm of the
branch checked for "if (!param)" after assignment. So the error could
not happen, but compilers may not have noticed depending on the width of
their scope during compilation.

Move the initialization of 'conn' closer to the conditional assignment,
such that all paths are seen in one spot during maintenance.

This fixes bug #1094.
2018-02-09 21:59:18 +01:00
Gerhard Sittig 6f63b1ee67 usb: re-use existing values, don't re-determine bus and device address
Avoid repeated libusb bus number and device address retrieval operations,
instead use variables where the information previously got stored to.
2018-02-09 21:59:18 +01:00
Gerhard Sittig 241c03029d log: flush log lines, to cope with non-terminal output (pipes)
Although log messages are terminated by a line feed, output still might
get buffered when the program does not talk to a terminal (that it is
aware of). Add an fflush(3) call to the printf(3) sequence such that log
output will immediately show up when writing to pipes or sockets, too.
2018-02-09 21:59:18 +01:00
Gerhard Sittig 928560e6f5 backend: fixup resource leak in sr_init() error code path
Early sr_init() steps can just 'return' fine. After allocation of the
'context' memory, make all error paths 'goto done' before returning,
to undo the memory allocation.
2018-02-09 21:59:18 +01:00
Gerhard Sittig 309bb27ee4 README.devices: the PRINT button must get pressed for Metrix MX56C 2018-02-09 21:59:18 +01:00
Gerhard Sittig 11e3a56380 srzip: don't access non-existing option
The srzip output module dropped support for the "filename" option in
commit 37875f7506 on 2015-07-30, but still used to assign to slot
options[0] which clobbers the array's sentinel. Remove those accesses
to the non-existing option.
2018-02-09 21:59:18 +01:00
Uwe Hermann 793e9963b8 hantek-4032l: Fix a compiler warning.
api.c: In function 'config_set':
  api.c:352:5: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'uint64_t' [-Wformat=]
       sr_err("invalid sample range 2k...64M: %ld",
       ^
2018-02-09 21:44:23 +01:00
Uwe Hermann 3347fe26a0 beaglelogic: Fix a compiler warning.
beaglelogic_tcp.c: In function 'beaglelogic_tcp_send_cmd':
 beaglelogic_tcp.c:114:3: warning: format '%lu' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' [-Wformat=]
     sr_dbg("Only sent %d/%lu bytes of command: '%s'.", out,
     ^
2018-02-09 21:44:23 +01:00
Gerhard Sittig 93b5cd6919 yokogawa-dlm: fix several compiler warnings (assignment, memory)
Check pointers' validity before dereferencing them. Release partially
allocated memory in an error path. Remove an assignment which never took
effect.

This was reported by clang's scan-build.
2018-02-09 21:37:40 +01:00
Gerhard Sittig 2da5c95f3d tondaj-sl-814: fix a potential memory leak
Release an allocated device instance in an error path.

This was reported by clang's scan-build.
2018-02-09 21:37:40 +01:00
Gerhard Sittig aedbf89d85 sysclk-lwla: silence potential NULL dereference compiler warning
Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.
2018-02-09 21:37:40 +01:00
Gerhard Sittig 08eba2d301 scpi-pps: silence potential NULL dereference compiler warning
Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.
2018-02-09 21:37:40 +01:00
Gerhard Sittig 6a821db6f2 saleae-logic-pro: silence "assigned, not used" compiler warning
Remove an assignment that never took effect.

This was reported by clang's scan-build.
2018-02-09 21:37:40 +01:00
Gerhard Sittig 0306ae30b6 rigol-ds: silence potential NULL dereference compiler warning
Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.
2018-02-09 21:37:39 +01:00
Gerhard Sittig b04cbd0ba3 ols, pipistrello-ols: silence "assigned, not used" compiler warning
Each code path either assigns to 'flags', or leaves the routine. There
is no potential path that leaves the variable at the initially assigned
value, so the assignment took no effect. Remove it.

Nit: Trim the source code line length while we are here.

This was reported by clang's scan-build.
2018-02-09 21:37:39 +01:00
Gerhard Sittig 8eadb70a37 norma-dmm: fix a potential memory leak
Release an allocated buffer in an error path.

This was reported by clang's scan-build.
2018-02-09 21:37:39 +01:00
Gerhard Sittig e4924d752b motech-lps-30x: fix several compiler warnings
Check pointers' validity before dereferencing them. Explicitly assign a
default value to variables, before conversion routines conditionally
assign the "real" value (and don't in case of conversion errors). This
avoids processing "garbage" data.

Strictly speaking I cannot see how the conversion routine returns OK and
has _not_ assigned a result. But the explicit assignment won't harm
either, and matches the fallback when the conversion fails (detectibly).
Which means that runtime behaviour won't change.

This was reported by clang's scan-build.
2018-02-09 21:37:39 +01:00
Gerhard Sittig fe535a89c9 maynuo-m97: fix potential NULL dereference
Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.
2018-02-09 21:37:39 +01:00
Gerhard Sittig 4072d5b42f manson-hcs-3xxx: fix potential NULL dereference
Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.
2018-02-09 21:37:39 +01:00
Gerhard Sittig f62c2ad65d lecroy-xstream: fix several compiler warnings (assignment, memory)
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.
2018-02-09 21:37:39 +01:00
Gerhard Sittig b65adcedb8 lascar-el-usb: fix potential NULL dereference and memory leak
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.
2018-02-09 21:37:39 +01:00
Gerhard Sittig fc69eecca0 korad-kaxxxxp: fix potential NULL dereference
Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.
2018-02-09 21:37:39 +01:00
Gerhard Sittig 1674225a2f hp-3457a: fix potential NULL dereference
Check the active channels' list for not being empty, before
dereferencing pointers.

This was reported by clang's scan-build.
2018-02-09 21:37:39 +01:00
Gerhard Sittig e93ca8a4d6 hantek-6xxx: fix potential NULL dereference
Check pointers' validity before dereferencing.

This was reported by clang's scan-build.
2018-02-09 21:37:39 +01:00
Gerhard Sittig b0e80e9aa9 hameg-hmo: fix several compiler warnings (assignments, memory)
Silence warnings about assigned values that never get used, potential
NULL deference, and potential memory leaks.

This was reported by clang's scan-build.
2018-02-09 21:37:39 +01:00
Gerhard Sittig 56e9672b11 gmc-mh-1x-2x: fix potential memory leak
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.
2018-02-09 21:37:39 +01:00
Gerhard Sittig 0d1c51f57f fx2lafw: silence "NULL dereference" compiler warning
Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.
2018-02-09 21:37:39 +01:00
Gerhard Sittig f6051b9eca ftdi-la: silence "assigned but never used" compiler warning
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.
2018-02-09 21:37:35 +01:00
Gerhard Sittig 051e4beb79 dreamsourcelab-dslogic: avoid division by zero
Do not align to block_size when its value is zero.

This was reported by clang's scan-build.
2018-02-09 21:34:17 +01:00
Gerhard Sittig 8e2fd23acb dreamsourcelab-dslogic: avoid NULL pointer dereference
Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.
2018-02-09 21:34:17 +01:00
Gerhard Sittig 755eb22156 chronovu-la: avoid NULL pointer dereference
Check pointers' validity before dereferencing them.

This was reported by clang's scan-build.
2018-02-09 21:34:17 +01:00
Gerhard Sittig 05b0cc416f beaglelogic: fixup use of uninitialized data in TCP routines
Make sure that failure to communicate via TCP results in access to
uninitialized data.

This was reported by clang's scan-build.
2018-02-09 21:34:17 +01:00
Gerhard Sittig 71f2000bfb beaglelogic: fixup memory leak in the TCP command send routine
Release allocated memory in an error code path.

This was reported by clang's scan-build.
2018-02-09 21:34:17 +01:00