commit 0949519b8199db9b70e1c56111893096aa6df1d5
Author: Seth McDonald <[email protected]>
AuthorDate: Fri May 1 12:41:53 2026 +1000
Commit: Oswald Buddenhagen <[email protected]>
CommitDate: Fri May 1 11:39:11 2026 +0200
Suppress unavoidable memrchr() warning
For consistency with glibc, our memrchr() implementation returns a
non-const pointer derived from a const pointer passed as an argument.
This can trigger the -Wcast-qual compiler warning, which we have
enabled. So locally suppress it for the relevant cast.
While at it, we also delay the cast to the last possible moment, which
is the return statement. This is safer, and also consistent with glibc.
Also use our uchar typedef rather than the nonstandard u_char, fixing
the omission from commit 42cedc8f8.
src/util.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/util.c b/src/util.c
index c110188..22e639f 100644
--- a/src/util.c
+++ b/src/util.c
@@ -454,12 +454,18 @@ vasprintf( char **strp, const char *fmt, va_list ap )
void *
memrchr( const void *s, int c, size_t n )
{
- u_char *b = (u_char *)s, *e = b + n;
+ const uchar *b = s;
+ const uchar *e = b + n;
- while (--e >= b)
- if (*e == c)
+ while (--e >= b) {
+ if (*e == c) {
+DIAG_PUSH
+DIAG_DISABLE("-Wcast-qual")
return (void *)e;
- return 0;
+DIAG_POP
+ }
+ }
+ return NULL;
}
#endif
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel