dovecot-2.2: lib-otp: cast to the correct type of function pointer

dovecot at dovecot.org dovecot at dovecot.org
Tue May 27 18:19:15 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/7cda826410f5
changeset: 17406:7cda826410f5
user:      Phil Carmody <phil at dovecot.fi>
date:      Tue May 27 21:17:34 2014 +0300
description:
lib-otp: cast to the correct type of function pointer
sparse complains about the result of the F() cast being the wrong type
for the initialisation, which is true. So just cast to the right type
in the first place.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib-otp/otp-hash.c |  16 +++++++++++-----
 1 files changed, 11 insertions(+), 5 deletions(-)

diffs (30 lines):

diff -r 9f1e53489674 -r 7cda826410f5 src/lib-otp/otp-hash.c
--- a/src/lib-otp/otp-hash.c	Tue May 27 21:17:34 2014 +0300
+++ b/src/lib-otp/otp-hash.c	Tue May 27 21:17:34 2014 +0300
@@ -79,15 +79,21 @@
 }
 
 
-#define F(name) ((void (*)()) (name))
+#define F_INIT(name) ((void (*)(void *)) (name))
+#define F_UPDATE(name) ((void (*)(void *, const void *, size_t)) (name))
+#define F_FINAL(name) ((void (*)(void *, void *)) (name))
+#define F_FOLD(name) ((void (*)(void *, void *)) (name))
 
 static const struct digest digests[] = {
-	{ "md4", F(md4_init), F(md4_update), F(md4_final), F(md4_fold) },
-	{ "md5", F(md5_init), F(md5_update), F(md5_final), F(md5_fold) },
-	{ "sha1", F(sha1_init), F(sha1_loop),  F(sha1_result), F(sha1_fold) },
+	{ "md4",  F_INIT(md4_init),  F_UPDATE(md4_update), F_FINAL(md4_final),   F_FOLD(md4_fold) },
+	{ "md5",  F_INIT(md5_init),  F_UPDATE(md5_update), F_FINAL(md5_final),   F_FOLD(md5_fold) },
+	{ "sha1", F_INIT(sha1_init), F_UPDATE(sha1_loop),  F_FINAL(sha1_result), F_FOLD(sha1_fold) },
 };
 
-#undef F
+#undef F_INIT
+#undef F_UPDATE
+#undef F_FINAL
+#undef F_FOLD
 
 const char *digest_name(unsigned int algo)
 {


More information about the dovecot-cvs mailing list