Merge pull request #25 from JanX2/master

Fix Clang static analyser nit: zero out nmbs_bitfield structs.
This commit is contained in:
Valerio De Benedetto 2023-04-21 10:53:08 +02:00 committed by GitHub
commit 2d1ea540ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -57,7 +57,7 @@ void loop() {
nmbs_set_destination_rtu_address(&nmbs, RTU_SERVER_ADDRESS);
// Write 2 coils from address 64
nmbs_bitfield coils;
nmbs_bitfield coils = {0};
nmbs_bitfield_write(coils, 0, 1);
nmbs_bitfield_write(coils, 1, 1);
err = nmbs_write_multiple_coils(&nmbs, 64, 2, coils);

View File

@ -45,7 +45,7 @@ int main(int argc, char* argv[]) {
nmbs_set_read_timeout(&nmbs, 1000);
// Write 2 coils from address 64
nmbs_bitfield coils;
nmbs_bitfield coils = {0};
nmbs_bitfield_write(coils, 0, 1);
nmbs_bitfield_write(coils, 1, 1);
err = nmbs_write_multiple_coils(&nmbs, 64, 2, coils);

View File

@ -669,7 +669,7 @@ static nmbs_error handle_write_multiple_coils(nmbs_t* nmbs) {
if (err != NMBS_ERROR_NONE)
return err;
nmbs_bitfield coils;
nmbs_bitfield coils = {0};
for (int i = 0; i < coils_bytes; i++) {
coils[i] = get_1(nmbs);
NMBS_DEBUG_PRINT("%d ", coils[i]);

View File

@ -235,7 +235,7 @@ void test_fc1(nmbs_transport transport) {
expect(nmbs_read_coils(&CLIENT, 3, 1, NULL) == NMBS_EXCEPTION_ILLEGAL_DATA_VALUE);
should("read with no error");
nmbs_bitfield bf;
nmbs_bitfield bf = {0};
check(nmbs_read_coils(&CLIENT, 10, 3, bf));
expect(nmbs_bitfield_read(bf, 0) == 1);
expect(nmbs_bitfield_read(bf, 1) == 0);
@ -302,7 +302,7 @@ void test_fc2(nmbs_transport transport) {
expect(nmbs_read_discrete_inputs(&CLIENT, 3, 1, NULL) == NMBS_EXCEPTION_ILLEGAL_DATA_VALUE);
should("read with no error");
nmbs_bitfield bf;
nmbs_bitfield bf = {0};
check(nmbs_read_discrete_inputs(&CLIENT, 10, 3, bf));
expect(nmbs_bitfield_read(bf, 0) == 1);
expect(nmbs_bitfield_read(bf, 1) == 0);