mirror of
git://git.code.sf.net/p/dhcpd-pools/code
synced 2025-12-17 00:06:59 +00:00
all: fix compiler warninings
Use compiler warnings from coreutils to check nothing complains, and fix everything that did. CFLAGS='-Wall -W -Wformat-y2k -Wformat-security -Winit-self -Wmissing-include-dirs -Wunused -Wunknown-pragmas -Wstrict-aliasing -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-align -Wwrite-strings -Wmissing-declarations -Wmissing-noreturn -Wpacked -Winvalid-pch -Wvolatile-register-var -Wdisabled-optimization -Woverlength-strings -Wbuiltin-macro-redefined -Wmudflap -Wpacked-bitfield-compat -Wsync-nand -Wattributes -Wcoverage-mismatch -Wabi -Wcpp -Wdeprecated -Wdeprecated-declarations -Wdiv-by-zero -Wendif-labels -Wextra -Wformat-contains-nul -Wformat-extra-args -Wformat-zero-length -Wformat=2 -Wmultichar -Wnormalized=nfc -Woverflow -Wpointer-to-int-cast -Wpragmas -Wsuggest-attribute=noreturn -Wtrampolines -Wno-sign-compare -Wno-unused-parameter -Wsuggest-attribute=noreturn -Wno-format-nonliteral -Wno-logical-op -fdiagnostics-show-option -funit-at-a-time' Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
37563d8d59
commit
b3e02ce0ba
6 changed files with 22 additions and 19 deletions
|
|
@ -42,7 +42,7 @@
|
||||||
#include "dhcpd-pools.h"
|
#include "dhcpd-pools.h"
|
||||||
|
|
||||||
/* Clean up data */
|
/* Clean up data */
|
||||||
int ip_sort(struct leases_t *a, struct leases_t *b)
|
static int ip_sort(struct leases_t *a, struct leases_t *b)
|
||||||
{
|
{
|
||||||
if (a->ip < b->ip)
|
if (a->ip < b->ip)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
int i, c, sorts = 0;
|
int i, c, sorts = 0;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
char *tmp;
|
char const *tmp;
|
||||||
struct range_t *tmp_ranges;
|
struct range_t *tmp_ranges;
|
||||||
enum {
|
enum {
|
||||||
OPT_WARN = CHAR_MAX + 1,
|
OPT_WARN = CHAR_MAX + 1,
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ void *safe_malloc(const size_t size)
|
||||||
;
|
;
|
||||||
void *safe_realloc(void *__restrict ptr, const size_t size);
|
void *safe_realloc(void *__restrict ptr, const size_t size);
|
||||||
char *safe_strdup(const char *__restrict str) __attribute__ ((nonnull(1)));
|
char *safe_strdup(const char *__restrict str) __attribute__ ((nonnull(1)));
|
||||||
int xstrstr(char *__restrict a, char *__restrict b, int len);
|
int xstrstr(char *__restrict a, const char *__restrict b, int len);
|
||||||
double strtod_or_err(const char *__restrict str, const char *__restrict errmesg);
|
double strtod_or_err(const char *__restrict str, const char *__restrict errmesg);
|
||||||
int close_stream(FILE * stream);
|
int close_stream(FILE * stream);
|
||||||
void close_stdout(void);
|
void close_stdout(void);
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,7 @@ int nth_field(int n, char *restrict dest, const char *restrict src)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* dhcpd.conf interesting words */
|
/* dhcpd.conf interesting words */
|
||||||
int is_interesting_config_clause(char *restrict s)
|
static int is_interesting_config_clause(char const *restrict s)
|
||||||
{
|
{
|
||||||
if (strstr(s, "range")) {
|
if (strstr(s, "range")) {
|
||||||
return 3;
|
return 3;
|
||||||
|
|
|
||||||
11
src/other.c
11
src/other.c
|
|
@ -104,7 +104,7 @@ int
|
||||||
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
|
||||||
__attribute__ ((hot))
|
__attribute__ ((hot))
|
||||||
#endif
|
#endif
|
||||||
xstrstr(char *restrict a, char *restrict b, int len)
|
xstrstr(char *restrict a, const char *restrict b, int len)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
/* two spaces are very common in lease file, after them
|
/* two spaces are very common in lease file, after them
|
||||||
|
|
@ -137,7 +137,7 @@ char *safe_strdup(const char *restrict str)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return percentage value */
|
/* Return percentage value */
|
||||||
double strtod_or_err(const char *str, const char *errmesg)
|
double strtod_or_err(const char *restrict str, const char *restrict errmesg)
|
||||||
{
|
{
|
||||||
double num;
|
double num;
|
||||||
char *end = NULL;
|
char *end = NULL;
|
||||||
|
|
@ -158,16 +158,17 @@ double strtod_or_err(const char *str, const char *errmesg)
|
||||||
errx(EXIT_FAILURE, "%s: '%s'", errmesg, str);
|
errx(EXIT_FAILURE, "%s: '%s'", errmesg, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
void flip_ranges(struct range_t *restrict ranges, struct range_t *restrict tmp_ranges)
|
void flip_ranges(struct range_t *restrict flip_me,
|
||||||
|
struct range_t *restrict tmp_ranges)
|
||||||
{
|
{
|
||||||
unsigned int i = num_ranges - 1, j;
|
unsigned int i = num_ranges - 1, j;
|
||||||
|
|
||||||
for (j = 0; j < num_ranges; j++) {
|
for (j = 0; j < num_ranges; j++) {
|
||||||
*(tmp_ranges + j) = *(ranges + i);
|
*(tmp_ranges + j) = *(flip_me + i);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(ranges, tmp_ranges, num_ranges * sizeof(struct range_t));
|
memcpy(flip_me, tmp_ranges, num_ranges * sizeof(struct range_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free memory, flush buffers etc */
|
/* Free memory, flush buffers etc */
|
||||||
|
|
|
||||||
22
src/output.c
22
src/output.c
|
|
@ -314,7 +314,7 @@ int output_xml(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void html_header(FILE *restrict f)
|
static void html_header(FILE *restrict f)
|
||||||
{
|
{
|
||||||
char outstr[200];
|
char outstr[200];
|
||||||
struct tm *tmp;
|
struct tm *tmp;
|
||||||
|
|
@ -388,7 +388,7 @@ void html_header(FILE *restrict f)
|
||||||
fprintf(f, "<a name=\"ranges\">The lease file mtime: %s</a>", outstr);
|
fprintf(f, "<a name=\"ranges\">The lease file mtime: %s</a>", outstr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void html_footer(FILE *restrict f)
|
static void html_footer(FILE *restrict f)
|
||||||
{
|
{
|
||||||
fprintf(f, "<p><br></p>\n");
|
fprintf(f, "<p><br></p>\n");
|
||||||
fprintf(f, "<hr>\n");
|
fprintf(f, "<hr>\n");
|
||||||
|
|
@ -404,44 +404,46 @@ void html_footer(FILE *restrict f)
|
||||||
fprintf(f, "</html>\n");
|
fprintf(f, "</html>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void newrow(FILE *restrict f)
|
static void newrow(FILE *restrict f)
|
||||||
{
|
{
|
||||||
fprintf(f, "<tr>\n");
|
fprintf(f, "<tr>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void endrow(FILE *restrict f)
|
static void endrow(FILE *restrict f)
|
||||||
{
|
{
|
||||||
fprintf(f, "</tr>\n\n");
|
fprintf(f, "</tr>\n\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void output_line(FILE *restrict f, char *restrict type, char *restrict class, char *restrict text)
|
static void output_line(FILE *restrict f, char const *restrict type,
|
||||||
|
char const *restrict class, char const *restrict text)
|
||||||
{
|
{
|
||||||
fprintf(f, " <%s class=%s>%s</%s>\n", type, class, text, type);
|
fprintf(f, " <%s class=%s>%s</%s>\n", type, class, text, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void output_long(FILE *restrict f, char *restrict type, unsigned long unlong)
|
static void output_long(FILE *restrict f, char const *restrict type,
|
||||||
|
unsigned long unlong)
|
||||||
{
|
{
|
||||||
fprintf(f, " <%s class=ralign>%lu</%s>\n", type, unlong, type);
|
fprintf(f, " <%s class=ralign>%lu</%s>\n", type, unlong, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void output_float(FILE * f, char *restrict type, float fl)
|
static void output_float(FILE * f, char const *restrict type, float fl)
|
||||||
{
|
{
|
||||||
fprintf(f, " <%s class=ralign>%.3f</%s>\n", type, fl, type);
|
fprintf(f, " <%s class=ralign>%.3f</%s>\n", type, fl, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void table_start(FILE *restrict f)
|
static void table_start(FILE *restrict f)
|
||||||
{
|
{
|
||||||
fprintf(f, "<table width=\"75%%\" ");
|
fprintf(f, "<table width=\"75%%\" ");
|
||||||
fprintf(f, "class=\"%s\" ", PACKAGE_NAME);
|
fprintf(f, "class=\"%s\" ", PACKAGE_NAME);
|
||||||
fprintf(f, "summary=\"ISC dhcpd pool usage report\">\n");
|
fprintf(f, "summary=\"ISC dhcpd pool usage report\">\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void table_end(FILE *restrict f)
|
static void table_end(FILE *restrict f)
|
||||||
{
|
{
|
||||||
fprintf(f, "</table>\n");
|
fprintf(f, "</table>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void newsection(FILE *restrict f, char *restrict title)
|
static void newsection(FILE *restrict f, char const *restrict title)
|
||||||
{
|
{
|
||||||
newrow(f);
|
newrow(f);
|
||||||
output_line(f, "td", "calign", " ");
|
output_line(f, "td", "calign", " ");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue