From a91029a00e83e3933046cc9354357bccaa66c272 Mon Sep 17 00:00:00 2001 From: Francis Dupont Date: Mon, 11 Jan 2010 10:49:14 +0000 Subject: [PATCH] Prevent Linux spurious warnings about fwrite(). [RT #20812] --- CHANGES | 3 +++ bin/dnssec/dnssec-dsfromkey.c | 8 ++++---- bin/tests/cfg_test.c | 4 ++-- lib/dns/dst_api.c | 6 +++--- lib/dns/dst_parse.c | 6 +++--- lib/isc/include/isc/util.h | 12 +++++++++++- 6 files changed, 26 insertions(+), 13 deletions(-) diff --git a/CHANGES b/CHANGES index cb79cfef7a..9ebc7a9a24 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +2837. [port] Prevent Linux spurious warnings about fwrite(). + [RT #20812] + 2836. [bug] Keys that were scheduled to become active could be delayed. [RT #20874] diff --git a/bin/dnssec/dnssec-dsfromkey.c b/bin/dnssec/dnssec-dsfromkey.c index f2408a8d60..d699c78378 100644 --- a/bin/dnssec/dnssec-dsfromkey.c +++ b/bin/dnssec/dnssec-dsfromkey.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dnssec-dsfromkey.c,v 1.16 2009/10/12 20:48:10 each Exp $ */ +/* $Id: dnssec-dsfromkey.c,v 1.17 2010/01/11 10:49:14 fdupont Exp $ */ /*! \file */ @@ -265,12 +265,12 @@ emit(unsigned int dtype, isc_boolean_t showall, char *lookaside, fatal("can't print class"); isc_buffer_usedregion(&nameb, &r); - fwrite(r.base, 1, r.length, stdout); + isc_util_fwrite(r.base, 1, r.length, stdout); putchar(' '); isc_buffer_usedregion(&classb, &r); - fwrite(r.base, 1, r.length, stdout); + isc_util_fwrite(r.base, 1, r.length, stdout); if (lookaside == NULL) printf(" DS "); @@ -278,7 +278,7 @@ emit(unsigned int dtype, isc_boolean_t showall, char *lookaside, printf(" DLV "); isc_buffer_usedregion(&textb, &r); - fwrite(r.base, 1, r.length, stdout); + isc_util_fwrite(r.base, 1, r.length, stdout); putchar('\n'); } diff --git a/bin/tests/cfg_test.c b/bin/tests/cfg_test.c index 25a372cfec..0b959902b4 100644 --- a/bin/tests/cfg_test.c +++ b/bin/tests/cfg_test.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cfg_test.c,v 1.21 2009/03/02 23:47:43 tbox Exp $ */ +/* $Id: cfg_test.c,v 1.22 2010/01/11 10:49:14 fdupont Exp $ */ /*! \file */ @@ -49,7 +49,7 @@ check_result(isc_result_t result, const char *format, ...) { static void output(void *closure, const char *text, int textlen) { UNUSED(closure); - (void) fwrite(text, 1, textlen, stdout); + (void) isc_util_fwrite(text, 1, textlen, stdout); } static void diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index c0bc43d41b..bafe405345 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -31,7 +31,7 @@ /* * Principal Author: Brian Wellington - * $Id: dst_api.c,v 1.47 2009/11/07 03:36:58 each Exp $ + * $Id: dst_api.c,v 1.48 2010/01/11 10:49:14 fdupont Exp $ */ /*! \file */ @@ -1450,7 +1450,7 @@ write_public_key(const dst_key_t *key, int type, const char *directory) { fprintf(fp, " "); isc_buffer_usedregion(&classb, &r); - fwrite(r.base, 1, r.length, fp); + isc_util_fwrite(r.base, 1, r.length, fp); if ((type & DST_TYPE_KEY) != 0) fprintf(fp, " KEY "); @@ -1458,7 +1458,7 @@ write_public_key(const dst_key_t *key, int type, const char *directory) { fprintf(fp, " DNSKEY "); isc_buffer_usedregion(&textb, &r); - fwrite(r.base, 1, r.length, fp); + isc_util_fwrite(r.base, 1, r.length, fp); fputc('\n', fp); fflush(fp); diff --git a/lib/dns/dst_parse.c b/lib/dns/dst_parse.c index 0dfd5171a8..fd2f1d115c 100644 --- a/lib/dns/dst_parse.c +++ b/lib/dns/dst_parse.c @@ -31,7 +31,7 @@ /*% * Principal Author: Brian Wellington - * $Id: dst_parse.c,v 1.25 2010/01/08 23:51:44 tbox Exp $ + * $Id: dst_parse.c,v 1.26 2010/01/11 10:49:14 fdupont Exp $ */ #include @@ -626,7 +626,7 @@ dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv, isc_buffer_usedregion(&b, &r); fprintf(fp, "%s ", s); - fwrite(r.base, 1, r.length, fp); + isc_util_fwrite(r.base, 1, r.length, fp); fprintf(fp, "\n"); } @@ -651,7 +651,7 @@ dst__privstruct_writefile(const dst_key_t *key, const dst_private_t *priv, isc_buffer_usedregion(&b, &r); fprintf(fp, "%s ", timetags[i]); - fwrite(r.base, 1, r.length, fp); + isc_util_fwrite(r.base, 1, r.length, fp); fprintf(fp, "\n"); } } diff --git a/lib/isc/include/isc/util.h b/lib/isc/include/isc/util.h index 8a3b95d9da..97c9a89001 100644 --- a/lib/isc/include/isc/util.h +++ b/lib/isc/include/isc/util.h @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: util.h,v 1.30 2007/06/19 23:47:18 tbox Exp $ */ +/* $Id: util.h,v 1.31 2010/01/11 10:49:14 fdupont Exp $ */ #ifndef ISC_UTIL_H #define ISC_UTIL_H 1 @@ -230,4 +230,14 @@ */ #define TIME_NOW(tp) RUNTIME_CHECK(isc_time_now((tp)) == ISC_R_SUCCESS) +/*% + * Prevent Linux spurious warnings + */ +#if defined(__GNUC__) && (__GNUC__ > 3) +#define isc_util_fwrite(a, b, c, d) \ + __builtin_expect(fwrite((a), (b), (c), (d)), (c)) +#else +#define isc_util_fwrite(a, b, c, d) fwrite((a), (b), (c), (d)) +#endif + #endif /* ISC_UTIL_H */