mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-16 07:47:00 +00:00
clean up: fix couple compiler warnings
src/sort.c:255:5: warning: no previous prototype for 'merge' src/sort.c:290:2: warning: ISO C90 forbids mixed declarations and code src/mustach-dhcpd-pools.c:67:5: warning: no previous prototype for 'must_put_err' src/output.c:109:26: warning: comparing floating point with == or != is unsafe (x5) Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
88a3f1eb53
commit
8fba5c5e6b
5 changed files with 27 additions and 24 deletions
|
|
@ -74,6 +74,12 @@ AC_CHECK_FUNCS([\
|
||||||
])
|
])
|
||||||
AC_CHECK_DECL([strndupa])
|
AC_CHECK_DECL([strndupa])
|
||||||
|
|
||||||
|
AC_CHECK_FUNCS([fpclassify], [],
|
||||||
|
[AC_CHECK_LIB([m], [fpclassify], [MATH_LIBS="-lm"])]
|
||||||
|
[AC_CHECK_LIB([m], [__fpclassify], [MATH_LIBS="-lm"])]
|
||||||
|
)
|
||||||
|
AC_SUBST([MATH_LIBS])
|
||||||
|
|
||||||
AS_IF([test "x$ac_cv_func_open_memstream" = "xyes" && test "x$ac_cv_have_decl_strndupa" == "xyes"], [
|
AS_IF([test "x$ac_cv_func_open_memstream" = "xyes" && test "x$ac_cv_have_decl_strndupa" == "xyes"], [
|
||||||
build_mustach=yes
|
build_mustach=yes
|
||||||
AC_DEFINE([BUILD_MUSTACH], [1], [build mustach support])
|
AC_DEFINE([BUILD_MUSTACH], [1], [build mustach support])
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ bin_PROGRAMS = dhcpd-pools
|
||||||
AC_PROG_RANLIB = resolv
|
AC_PROG_RANLIB = resolv
|
||||||
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/lib -I$(top_builddir)/lib
|
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/lib -I$(top_builddir)/lib
|
||||||
|
|
||||||
dhcpd_pools_LDADD = $(top_builddir)/lib/libdhcpd_pools.la
|
dhcpd_pools_LDADD = $(top_builddir)/lib/libdhcpd_pools.la $(MATH_LIBS)
|
||||||
|
|
||||||
dhcpd_pools_SOURCES = \
|
dhcpd_pools_SOURCES = \
|
||||||
src/analyze.c \
|
src/analyze.c \
|
||||||
|
|
|
||||||
|
|
@ -64,10 +64,9 @@ static int must_enter(void *closure, const char *name);
|
||||||
static int must_leave(void *closure);
|
static int must_leave(void *closure);
|
||||||
|
|
||||||
/* This can be called when template is invalid end put happens before enter. */
|
/* This can be called when template is invalid end put happens before enter. */
|
||||||
int must_put_err(void *closure __attribute__ ((unused)),
|
static int must_put_err(void *closure __attribute__ ((unused)),
|
||||||
const char *name __attribute__ ((unused)),
|
const char *name __attribute__ ((unused)),
|
||||||
int escape __attribute__ ((unused)),
|
int escape __attribute__ ((unused)), FILE *file __attribute__ ((unused)))
|
||||||
FILE *file __attribute__ ((unused)))
|
|
||||||
{
|
{
|
||||||
return MUSTACH_ERROR_SYSTEM;
|
return MUSTACH_ERROR_SYSTEM;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
29
src/output.c
29
src/output.c
|
|
@ -106,22 +106,21 @@ int shnet_output_helper(struct conf_t *state, struct output_helper_t *oh,
|
||||||
{
|
{
|
||||||
/* counts and calculations */
|
/* counts and calculations */
|
||||||
oh->tc = shared_p->touched + shared_p->used;
|
oh->tc = shared_p->touched + shared_p->used;
|
||||||
if (shared_p->available == 0) {
|
if (fpclassify(shared_p->available) == FP_ZERO) {
|
||||||
oh->percent = NAN;
|
oh->percent = NAN;
|
||||||
oh->tcp = NAN;
|
oh->tcp = NAN;
|
||||||
oh->bup = NAN;
|
oh->bup = NAN;
|
||||||
} else {
|
|
||||||
oh->percent = (double)(100 * shared_p->used) / shared_p->available;
|
|
||||||
oh->tcp =
|
|
||||||
(double)((100 * (shared_p->touched + shared_p->used)) / shared_p->available);
|
|
||||||
if (state->backups_found == 1) {
|
|
||||||
oh->bup = (double)(100 * shared_p->backups) / shared_p->available;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* set status */
|
|
||||||
if (oh->percent == NAN)
|
|
||||||
oh->status = STATUS_SUPPRESSED;
|
oh->status = STATUS_SUPPRESSED;
|
||||||
else if (shared_p->available <= state->minsize)
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
oh->percent = (double)(100 * shared_p->used) / shared_p->available;
|
||||||
|
oh->tcp = (double)((100 * (shared_p->touched + shared_p->used)) / shared_p->available);
|
||||||
|
if (state->backups_found == 1)
|
||||||
|
oh->bup = (double)(100 * shared_p->backups) / shared_p->available;
|
||||||
|
|
||||||
|
/* set status */
|
||||||
|
if (shared_p->available <= state->minsize)
|
||||||
oh->status = STATUS_IGNORED;
|
oh->status = STATUS_IGNORED;
|
||||||
else if (state->critical < oh->percent && shared_p->used < state->crit_count)
|
else if (state->critical < oh->percent && shared_p->used < state->crit_count)
|
||||||
oh->status = STATUS_CRIT;
|
oh->status = STATUS_CRIT;
|
||||||
|
|
@ -503,18 +502,18 @@ static int output_json(struct conf_t *state, const int print_mac_addreses)
|
||||||
fprintf(outfile, "\"used\":%g, ", shared_p->used);
|
fprintf(outfile, "\"used\":%g, ", shared_p->used);
|
||||||
fprintf(outfile, "\"touched\":%g, ", shared_p->touched);
|
fprintf(outfile, "\"touched\":%g, ", shared_p->touched);
|
||||||
fprintf(outfile, "\"free\":%g, ", shared_p->available - shared_p->used);
|
fprintf(outfile, "\"free\":%g, ", shared_p->available - shared_p->used);
|
||||||
if (shared_p->available == 0)
|
if (fpclassify(shared_p->available) == FP_ZERO)
|
||||||
fprintf(outfile, "\"percent\":\"%g\", ", oh.percent);
|
fprintf(outfile, "\"percent\":\"%g\", ", oh.percent);
|
||||||
else
|
else
|
||||||
fprintf(outfile, "\"percent\":%g, ", oh.percent);
|
fprintf(outfile, "\"percent\":%g, ", oh.percent);
|
||||||
fprintf(outfile, "\"touch_count\":%g, ", oh.tc);
|
fprintf(outfile, "\"touch_count\":%g, ", oh.tc);
|
||||||
if (shared_p->available == 0)
|
if (fpclassify(shared_p->available) == FP_ZERO)
|
||||||
fprintf(outfile, "\"touch_percent\":\"%g\", ", oh.tcp);
|
fprintf(outfile, "\"touch_percent\":\"%g\", ", oh.tcp);
|
||||||
else
|
else
|
||||||
fprintf(outfile, "\"touch_percent\":%g, ", oh.tcp);
|
fprintf(outfile, "\"touch_percent\":%g, ", oh.tcp);
|
||||||
if (state->backups_found == 1) {
|
if (state->backups_found == 1) {
|
||||||
fprintf(outfile, "\"backup_count\":%g, ", shared_p->backups);
|
fprintf(outfile, "\"backup_count\":%g, ", shared_p->backups);
|
||||||
if (shared_p->available == 0)
|
if (fpclassify(shared_p->available) == FP_ZERO)
|
||||||
fprintf(outfile, "\"backup_percent\":\"%g\", ", oh.bup);
|
fprintf(outfile, "\"backup_percent\":\"%g\", ", oh.bup);
|
||||||
else
|
else
|
||||||
fprintf(outfile, "\"backup_percent\":%g, ", oh.bup);
|
fprintf(outfile, "\"backup_percent\":%g, ", oh.bup);
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ comparer_t field_selector(char c)
|
||||||
* \param right The right side of the merge sort.
|
* \param right The right side of the merge sort.
|
||||||
* \return Relevant for merge sort decision.
|
* \return Relevant for merge sort decision.
|
||||||
*/
|
*/
|
||||||
int merge(struct conf_t *state, struct range_t *restrict left, struct range_t *restrict right)
|
static int merge(struct conf_t *state, struct range_t *restrict left, struct range_t *restrict right)
|
||||||
{
|
{
|
||||||
struct output_sort *p;
|
struct output_sort *p;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
@ -282,13 +282,12 @@ void mergesort_ranges(struct conf_t *state, struct range_t *restrict orig, unsig
|
||||||
unsigned int left, i, u_right;
|
unsigned int left, i, u_right;
|
||||||
int s_right;
|
int s_right;
|
||||||
struct range_t hold;
|
struct range_t hold;
|
||||||
|
/* Merge sort split size */
|
||||||
|
static const unsigned int MIN_MERGE_SIZE = 8;
|
||||||
|
|
||||||
if (temp == NULL)
|
if (temp == NULL)
|
||||||
temp = xmalloc(sizeof(struct range_t) * size);
|
temp = xmalloc(sizeof(struct range_t) * size);
|
||||||
|
|
||||||
/* Merge sort split size */
|
|
||||||
static const unsigned int MIN_MERGE_SIZE = 8;
|
|
||||||
|
|
||||||
if (size < MIN_MERGE_SIZE) {
|
if (size < MIN_MERGE_SIZE) {
|
||||||
for (left = 0; left < size; left++) {
|
for (left = 0; left < size; left++) {
|
||||||
hold = *(orig + left);
|
hold = *(orig + left);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue