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:
Sami Kerola 2012-07-17 17:50:35 +02:00
parent 37563d8d59
commit b3e02ce0ba
6 changed files with 22 additions and 19 deletions

View file

@ -42,7 +42,7 @@
#include "dhcpd-pools.h"
/* 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)
return -1;

View file

@ -61,7 +61,7 @@ int main(int argc, char **argv)
{
int i, c, sorts = 0;
int option_index = 0;
char *tmp;
char const *tmp;
struct range_t *tmp_ranges;
enum {
OPT_WARN = CHAR_MAX + 1,

View file

@ -178,7 +178,7 @@ void *safe_malloc(const size_t size)
;
void *safe_realloc(void *__restrict ptr, const size_t size);
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);
int close_stream(FILE * stream);
void close_stdout(void);

View file

@ -200,7 +200,7 @@ int nth_field(int n, char *restrict dest, const char *restrict src)
}
/* 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")) {
return 3;

View file

@ -104,7 +104,7 @@ int
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
__attribute__ ((hot))
#endif
xstrstr(char *restrict a, char *restrict b, int len)
xstrstr(char *restrict a, const char *restrict b, int len)
{
int i;
/* two spaces are very common in lease file, after them
@ -137,7 +137,7 @@ char *safe_strdup(const char *restrict str)
}
/* 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;
char *end = NULL;
@ -158,16 +158,17 @@ double strtod_or_err(const char *str, const char *errmesg)
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;
for (j = 0; j < num_ranges; j++) {
*(tmp_ranges + j) = *(ranges + i);
*(tmp_ranges + j) = *(flip_me + 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 */

View file

@ -314,7 +314,7 @@ int output_xml(void)
return 0;
}
void html_header(FILE *restrict f)
static void html_header(FILE *restrict f)
{
char outstr[200];
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);
}
void html_footer(FILE *restrict f)
static void html_footer(FILE *restrict f)
{
fprintf(f, "<p><br></p>\n");
fprintf(f, "<hr>\n");
@ -404,44 +404,46 @@ void html_footer(FILE *restrict f)
fprintf(f, "</html>\n");
}
void newrow(FILE *restrict f)
static void newrow(FILE *restrict f)
{
fprintf(f, "<tr>\n");
}
void endrow(FILE *restrict f)
static void endrow(FILE *restrict f)
{
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);
}
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);
}
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);
}
void table_start(FILE *restrict f)
static void table_start(FILE *restrict f)
{
fprintf(f, "<table width=\"75%%\" ");
fprintf(f, "class=\"%s\" ", PACKAGE_NAME);
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");
}
void newsection(FILE *restrict f, char *restrict title)
static void newsection(FILE *restrict f, char const *restrict title)
{
newrow(f);
output_line(f, "td", "calign", "&nbsp;");