Added another bunch of compiler warnings and fix code.

This commit is contained in:
Juan RP 2011-01-15 11:59:44 +01:00
parent d9001adbad
commit 6051eb29ab
8 changed files with 33 additions and 13 deletions

View File

@ -42,7 +42,7 @@ struct list_pkgver_cb {
size_t pkgver_len; size_t pkgver_len;
}; };
static void static void __attribute__((noreturn))
usage(void) usage(void)
{ {
fprintf(stderr, fprintf(stderr,
@ -137,7 +137,7 @@ show_orphans(void)
return 0; return 0;
} }
static void static void __attribute__((noreturn))
cleanup(int signum) cleanup(int signum)
{ {
xbps_end(); xbps_end();

View File

@ -83,7 +83,7 @@ struct defprops {
{ .sect = "node-sub", .prop = "opt-fillcolor", .val = "grey" } { .sect = "node-sub", .prop = "opt-fillcolor", .val = "grey" }
}; };
static void static void __attribute__((noreturn))
die(const char *fmt, ...) die(const char *fmt, ...)
{ {
va_list ap; va_list ap;
@ -97,7 +97,7 @@ die(const char *fmt, ...)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
static void static void __attribute__((noreturn))
usage(void) usage(void)
{ {
fprintf(stderr, fprintf(stderr,

View File

@ -35,7 +35,7 @@
#include <xbps_api.h> #include <xbps_api.h>
#include "defs.h" #include "defs.h"
static void static void __attribute__((noreturn))
usage(void) usage(void)
{ {
fprintf(stderr, fprintf(stderr,

View File

@ -68,7 +68,8 @@ void
show_pkg_info(prop_dictionary_t dict) show_pkg_info(prop_dictionary_t dict)
{ {
prop_object_t obj; prop_object_t obj;
char size[64], *sep; const char *sep;
char size[64];
int rv = 0; int rv = 0;
assert(dict != NULL); assert(dict != NULL);
@ -132,7 +133,7 @@ show_pkg_info(prop_dictionary_t dict)
printf("Configuration files:\n"); printf("Configuration files:\n");
sep = " "; sep = " ";
(void)xbps_callback_array_iter_in_dict(dict, "conf_files", (void)xbps_callback_array_iter_in_dict(dict, "conf_files",
list_strings_sep_in_array, sep); list_strings_sep_in_array, __UNCONST(sep));
printf("\n"); printf("\n");
} }

View File

@ -55,7 +55,7 @@ write_plist_file(prop_dictionary_t dict, const char *file)
} }
} }
static void static void __attribute__((noreturn))
usage(void) usage(void)
{ {
fprintf(stderr, fprintf(stderr,

7
configure vendored
View File

@ -235,9 +235,12 @@ EOF
# Check for some compiler warning flags. # Check for some compiler warning flags.
# #
for f in all extra error shadow "format=2" missing-prototypes \ for f in all extra error shadow "format=2" missing-prototypes \
missing-declarations nested-externs \ missing-declarations nested-externs vla no-overlength-strings \
unsafe-loop-optimizations undef sign-compare format-security \
missing-include-dirs format-nonliteral old-style-definition \
init-self redundant-decls float-equal missing-noreturn \
cast-align cast-qual pointer-arith comment unused-macros \ cast-align cast-qual pointer-arith comment unused-macros \
declaration-after-statement stack-protector; do declaration-after-statement write-strings stack-protector; do
check_compiler_flag ${f} W check_compiler_flag ${f} W
done done

View File

@ -14,7 +14,7 @@ LIBPROP_OBJS += portableproplib/prop_stack.o portableproplib/prop_string.o
LIBPROP_OBJS += portableproplib/prop_array_util.o portableproplib/prop_number.o LIBPROP_OBJS += portableproplib/prop_array_util.o portableproplib/prop_number.o
LIBPROP_OBJS += portableproplib/prop_dictionary_util.o LIBPROP_OBJS += portableproplib/prop_dictionary_util.o
LIBPROP_OBJS += portableproplib/prop_data.o LIBPROP_OBJS += portableproplib/prop_data.o
LIBPROP_CFLAGS = -Wno-cast-qual -Wno-unused-parameter LIBPROP_CFLAGS = -Wno-old-style-definition -Wno-cast-qual -Wno-unused-parameter
ifdef USE_EXTERNAL_PROPLIB ifdef USE_EXTERNAL_PROPLIB
LIBPROP_OBJS = LIBPROP_OBJS =

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2009-2010 Juan Romero Pardines * Copyright (c) 2009-2011 Juan Romero Pardines
* Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav * Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav
* All rights reserved. * All rights reserved.
* *
@ -83,6 +83,22 @@ stat_eta(struct xferstat *xsp)
return str; return str;
} }
/** High precision double comparison
* \param[in] a The first double to compare
* \param[in] b The second double to compare
* \return true on equal within precison, false if not equal within defined precision.
*/
static inline bool
compare_double(const double a, const double b)
{
const double precision = 0.00001;
if ((a - precision) < b && (a + precision) > b)
return true;
else
return false;
}
/* /*
* Compute and display transfer rate * Compute and display transfer rate
*/ */
@ -95,7 +111,7 @@ stat_bps(struct xferstat *xsp)
delta = (xsp->last.tv_sec + (xsp->last.tv_usec / 1.e6)) delta = (xsp->last.tv_sec + (xsp->last.tv_usec / 1.e6))
- (xsp->start.tv_sec + (xsp->start.tv_usec / 1.e6)); - (xsp->start.tv_sec + (xsp->start.tv_usec / 1.e6));
if (delta == 0.0) { if (compare_double(delta, 0.0001)) {
snprintf(str, sizeof str, "-- stalled --"); snprintf(str, sizeof str, "-- stalled --");
} else { } else {
bps = ((double)(xsp->rcvd - xsp->offset) / delta); bps = ((double)(xsp->rcvd - xsp->offset) / delta);