On Wed, Apr 9, 2025 at 1:16 AM Lwazi Dube <lwa...@gmail.com> wrote:

> On Tue, 8 Apr 2025 at 05:23, Sebastien Lorquet <sebast...@lorquet.fr>
> wrote:
>
> > Hello,
> >
> > Nathan proposal to have a kconfig, with a default to the historical
> > algorithm, is a good solution.
> >
>
> Kconfig will work if you mean this:
>
> int16_t crc16(FAR const uint8_t *src, size_t len)
> {
> #if defined(CONFIG_CRC16_IBM)
>   return crc16ibmpart(src, len, 0);
> #elif defined(CONFIG_CRC16_XMODEM)
>   return crc16xmodempart(src, len, 0);
> #endif
> }
>

It's a very bad idea to use Kconfig to change the function's behaviour like
this.
For example, y/zmodem calls crc16 which expects the result same as
crc16xmodempart.
With this change, y/zmodem works fine when you select CONFIG_CRC16_XMODEM,
but stops working when you select CONFIG_CRC16_IBM.
To make y/zmodem working with any choice, you have to change crc16 to
crc16xmodempart.
All code which calls crc16 before, must change to either crc16ibmpart or
crc16xmodempart, which means crc16 can't be used in any portable code.
Do you really want this behaviour?

Reply via email to