Commit acd36e624971d58571074491d0023d95e16abc54

Authored by Stéphane Raimbault
1 parent 09b581a5

Remove useless internal variable called status

Showing 2 changed files with 5 additions and 15 deletions
src/modbus.c
... ... @@ -1046,26 +1046,16 @@ static int write_single(modbus_t *ctx, int function, int addr, int value)
1046 1046 }
1047 1047  
1048 1048 /* Turns ON or OFF a single bit of the remote device */
1049   -int modbus_write_bit(modbus_t *ctx, int addr, int state)
  1049 +int modbus_write_bit(modbus_t *ctx, int addr, int status)
1050 1050 {
1051   - int status;
1052   -
1053   - if (state)
1054   - state = 0xFF00;
1055   -
1056   - status = write_single(ctx, _FC_WRITE_SINGLE_COIL, addr, state);
1057   -
1058   - return status;
  1051 + return write_single(ctx, _FC_WRITE_SINGLE_COIL, addr,
  1052 + status ? 0xFF00 : 0);
1059 1053 }
1060 1054  
1061 1055 /* Writes a value in one register of the remote device */
1062 1056 int modbus_write_register(modbus_t *ctx, int addr, int value)
1063 1057 {
1064   - int status;
1065   -
1066   - status = write_single(ctx, _FC_WRITE_SINGLE_REGISTER, addr, value);
1067   -
1068   - return status;
  1058 + return write_single(ctx, _FC_WRITE_SINGLE_REGISTER, addr, value);
1069 1059 }
1070 1060  
1071 1061 /* Write the bits of the array in the remote device */
... ...
src/modbus.h
... ... @@ -160,7 +160,7 @@ int modbus_read_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest);
160 160 int modbus_read_input_bits(modbus_t *ctx, int addr, int nb, uint8_t *dest);
161 161 int modbus_read_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest);
162 162 int modbus_read_input_registers(modbus_t *ctx, int addr, int nb, uint16_t *dest);
163   -int modbus_write_bit(modbus_t *ctx, int coil_addr, int state);
  163 +int modbus_write_bit(modbus_t *ctx, int coil_addr, int status);
164 164 int modbus_write_register(modbus_t *ctx, int reg_addr, int value);
165 165 int modbus_write_bits(modbus_t *ctx, int addr, int nb, const uint8_t *data);
166 166 int modbus_write_registers(modbus_t *ctx, int addr, int nb, const uint16_t *data);
... ...