在 2018/12/17 23:15, Zebediah Figura 写道:
> This provides memcmp() for kernel-mode drivers, which for some reason
> is not exported from ntoskrnl like other crt functions.
> 
> The implementation was copied from wmemcmp.c in libmingwex.
> 
> Signed-off-by: Zebediah Figura <[email protected]>
> ---

> +    for ( ; 0 < _N; ++_S1, ++_S2, --_N)
> +     if (*_S1 != *_S2)
> +         return (*_S1 < *_S2 ? -1 : +1);
> +
> +    return 0;
> +}
> +

You must compare `*_S1` and `*_S2` as `unsigned char` as described below:
```
ISO/IEC WG14 N2176
7.24.4 Comparison functions
1 The sign of a nonzero value returned by the comparison functions
memcmp, strcmp, and strncmp is determined by the sign of the difference
between the values of the first pair of characters (both interpreted as
unsigned char) that differ in the objects being compared.
```


-- 
Best regards,
LH_Mouse

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to