mb_mapping types unnecessarily signed

16 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Memet B

ungelesen,
19.01.2023, 09:28:3319.01.23
an libmodbus
This is a very minor problem, but while going through some compiler warnings, I noticed that the definition for _modbus_mapping_t struct uses `int`s.

```
typedef struct _modbus_mapping_t {
    int nb_bits; // <--
    int start_bits;
    int nb_input_bits; // <--
    int start_input_bits;
    int nb_input_registers; // <--
    int start_input_registers;
    int nb_registers; // <--
    int start_registers;
    uint8_t *tab_bits;
    uint8_t *tab_input_bits;
    uint16_t *tab_input_registers;
    uint16_t *tab_registers;
    void (*coils_written)(int start, int count, void* ctx);
    void (*registers_written)(int start, int count, void* ctx);
    void *context;
} modbus_mapping_t;
```

Could these not be changed to `std::size_t`, or at the very least `uint`, since they should *never* be negative. Also, the start_*_registers members could (possibly?) be unsigned as well, but that isn't as clear as people may be using it in strange ways.


Thoughts?
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten