X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_complain.h;h=09c43750b3979f2bdd7e67a50bd60a298895ca2f;hb=0a73779531039d715e8ca405658c65ba03fad408;hp=e93d823e2ae8a52cb30cb15ff4be67c57308a184;hpb=7c8fb05fcb919fb2d9fc68757c198916396600ce;p=collectd.git diff --git a/src/utils_complain.h b/src/utils_complain.h index e93d823e..09c43750 100644 --- a/src/utils_complain.h +++ b/src/utils_complain.h @@ -39,7 +39,8 @@ typedef struct int interval; } c_complain_t; -#define C_COMPLAIN_INIT { 0, 0 } +#define C_COMPLAIN_INIT_STATIC { 0, 0 } +#define C_COMPLAIN_INIT(c) do { (c)->last = 0; (c)->interval = 0; } while (0) /* * NAME @@ -75,6 +76,15 @@ void c_complain_once (int level, c_complain_t *c, const char *format, ...); /* * NAME + * c_would_release + * + * DESCRIPTION + * Returns true if the specified complaint would be released, false else. + */ +#define c_would_release(c) ((c)->interval != 0) + +/* + * NAME * c_release * * DESCRIPTION @@ -86,7 +96,7 @@ void c_complain_once (int level, c_complain_t *c, const char *format, ...); void c_do_release (int level, c_complain_t *c, const char *format, ...); #define c_release(level, c, ...) \ do { \ - if ((c)->interval != 0) \ + if (c_would_release (c)) \ c_do_release(level, c, __VA_ARGS__); \ } while (0)