From: pcarana Date: Tue, 2 Apr 2019 20:54:17 +0000 (-0600) Subject: Add compilation warnings, and rename VRP struct property X-Git-Tag: v0.0.2~52^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0a81d18c844a1b957ec80405f2e87f5bec97202;p=thirdparty%2FFORT-validator.git Add compilation warnings, and rename VRP struct property --- diff --git a/src/Makefile.am b/src/Makefile.am index ce5019eb..74a897ab 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,4 +24,75 @@ rtr_server_SOURCES += rtr/primitive_reader.c rtr/primitive_reader.h rtr_server_SOURCES += rtr/primitive_writer.c rtr/primitive_writer.h rtr_server_SOURCES += rtr/rtr.c rtr/rtr.h -rtr_server_LDADD = ${JANSSON_LIBS} \ No newline at end of file +rtr_server_LDADD = ${JANSSON_LIBS} + +# I'm tired of scrolling up, but feel free to comment this out. +GCC_WARNS = -fmax-errors=1 + +# Please ready some arguments if you want to permanently remove some of these +# flags. I gave a quick read to the documentation of all of these warnings, and +# generally liked each of them. +GCC_WARNS += -Wpedantic -pedantic-errors -Waddress -Walloc-zero -Walloca +GCC_WARNS += -Wno-aggressive-loop-optimizations -Warray-bounds=2 -Wbool-compare +GCC_WARNS += -Wbool-operation -Wno-builtin-declaration-mismatch -Wcast-align +GCC_WARNS += -Wcast-qual -Wchar-subscripts -Wchkp -Wclobbered -Wcomment +GCC_WARNS += -Wdangling-else -Wdate-time -Wdisabled-optimization +GCC_WARNS += -Wdouble-promotion -Wduplicated-branches -Wduplicated-cond +GCC_WARNS += -Wempty-body -Wenum-compare -Wexpansion-to-defined -Wfloat-equal +GCC_WARNS += -Wformat -Wformat-nonliteral -Wformat-overflow=2 -Wformat-security +GCC_WARNS += -Wformat-signedness -Wformat-truncation=2 -Wformat-y2k +GCC_WARNS += -Wframe-address -Wjump-misses-init -Wignored-qualifiers +GCC_WARNS += -Wignored-attributes -Wincompatible-pointer-types + +# This is a fun one. Write "/* fallthrough */" to prevent a warning whenever +# switch cases do not break. +GCC_WARNS += -Wimplicit-fallthrough + +GCC_WARNS += -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Winline +GCC_WARNS += -Wint-in-bool-context -Winvalid-memory-model -Winvalid-pch +GCC_WARNS += -Wlogical-op -Wlogical-not-parentheses -Wlong-long -Wmain +GCC_WARNS += -Wmaybe-uninitialized -Wmemset-elt-size -Wmemset-transposed-args +GCC_WARNS += -Wmisleading-indentation -Wmissing-braces -Wmissing-include-dirs +GCC_WARNS += -Wnonnull -Wnonnull-compare -Wnormalized -Wnull-dereference + +# This one seems to be undocumented. +GCC_WARNS += -Wodr + +# "Warn if the vectorizer cost model overrides the OpenMP or the Cilk Plus simd +# directive set by user." +# ... What? +GCC_WARNS += -Wopenmp-simd + +GCC_WARNS += -Woverride-init-side-effects -Woverlength-strings -Wpacked +GCC_WARNS += -Wpacked-bitfield-compat -Wparentheses -Wpointer-arith +GCC_WARNS += -Wpointer-compare -Wredundant-decls -Wrestrict -Wreturn-type +GCC_WARNS += -Wsequence-point -Wshadow -Wshift-overflow=2 -Wshift-count-negative +GCC_WARNS += -Wshift-count-overflow -Wshift-negative-value -Wfloat-conversion +GCC_WARNS += -Wsizeof-pointer-memaccess -Wsizeof-array-argument +GCC_WARNS += -Wstack-protector -Wstrict-aliasing -Wstrict-overflow=5 +GCC_WARNS += -Wstringop-overflow=4 -Wsuggest-final-types -Wsuggest-final-methods +GCC_WARNS += -Wmissing-format-attribute -Wswitch -Wswitch-bool -Wswitch-enum +GCC_WARNS += -Wswitch-unreachable -Wsync-nand -Wtautological-compare +GCC_WARNS += -Wtrampolines -Wtrigraphs -Wtype-limits -Wundef -Wuninitialized +GCC_WARNS += -Wunknown-pragmas -Wunsafe-loop-optimizations +GCC_WARNS += -Wunsuffixed-float-constants -Wunused -Wunused-function +GCC_WARNS += -Wunused-label -Wunused-local-typedefs -Wunused-macros +GCC_WARNS += -Wunused-value -Wunused-variable -Wunused-const-variable=2 +GCC_WARNS += -Wunused-but-set-parameter -Wunused-but-set-variable +GCC_WARNS += -Wvariadic-macros -Wvector-operation-performance -Wvla +GCC_WARNS += -Wvolatile-register-var -Wwrite-strings + +# "Issue a warning when HSAIL cannot be emitted for the compiled function or +# OpenMP construct." +# Uh-huh. +GCC_WARNS += -Whsa + +# I don't mind too much increasing these. +# Just make sure that you know what you're doing. +GCC_WARNS += -Wlarger-than=2048 -Walloc-size-larger-than=4096 +GCC_WARNS += -Wframe-larger-than=1024 -Wstack-usage=1024 + +# Can't use because of dependencies: -Waggregate-return +# Want to add, but needs work: -Wconversion, -Wsign-compare, -Wsign-conversion +# Seem to require other compiler features: -Wchkp, -Wstack-protector, +# -Wstrict-aliasing, -Wstrict-overflow diff --git a/src/rtr/pdu_sender.c b/src/rtr/pdu_sender.c index 421feddc..a7bf2e1a 100644 --- a/src/rtr/pdu_sender.c +++ b/src/rtr/pdu_sender.c @@ -215,9 +215,9 @@ send_payload_pdus(struct sender_common *common) goto end; for (ptr = vrps; (ptr - vrps) < len; ptr++) { - if (ptr->in_addr_len == INET_ADDRSTRLEN) + if (ptr->addr_fam == AF_INET) error = send_ipv4_prefix_pdu(common, ptr); - else if (ptr->in_addr_len == INET6_ADDRSTRLEN) + else if (ptr->addr_fam == AF_INET6) error = send_ipv6_prefix_pdu(common, ptr); else error = -EINVAL; diff --git a/src/vrps.c b/src/vrps.c index 6249ea57..ff3ae7cc 100644 --- a/src/vrps.c +++ b/src/vrps.c @@ -115,7 +115,7 @@ create_vrp4(u_int32_t asn, struct in_addr ipv4_prefix, u_int8_t prefix_length, init_vrp(&result, asn, prefix_length, max_prefix_length); result.ipv4_prefix = ipv4_prefix; - result.in_addr_len = INET_ADDRSTRLEN; + result.addr_fam = AF_INET; return result; } @@ -128,7 +128,7 @@ create_vrp6(u_int32_t asn, struct in6_addr ipv6_prefix, u_int8_t prefix_length, init_vrp(&result, asn, prefix_length, max_prefix_length); result.ipv6_prefix = ipv6_prefix; - result.in_addr_len = INET6_ADDRSTRLEN; + result.addr_fam = AF_INET6; return result; } @@ -137,12 +137,12 @@ static bool vrp_equal(struct vrp *left, struct vrp *right) { return left->asn == right->asn - && left->in_addr_len == right->in_addr_len + && left->addr_fam == right->addr_fam && left->prefix_length == right->prefix_length && left->max_prefix_length == right->max_prefix_length - && ((left->in_addr_len == INET_ADDRSTRLEN + && ((left->addr_fam == AF_INET && left->ipv4_prefix.s_addr == right->ipv4_prefix.s_addr) - || (left->in_addr_len == INET6_ADDRSTRLEN + || (left->addr_fam == AF_INET6 && IN6_ARE_ADDR_EQUAL(left->ipv6_prefix.s6_addr32, right->ipv6_prefix.s6_addr32))); } diff --git a/src/vrps.h b/src/vrps.h index d1be5ad3..f6d4c208 100644 --- a/src/vrps.h +++ b/src/vrps.h @@ -17,7 +17,7 @@ struct vrp { }; u_int8_t prefix_length; u_int8_t max_prefix_length; - u_int8_t in_addr_len; + u_int8_t addr_fam; u_int8_t flags; };