]> git.ipfire.org Git - thirdparty/FORT-validator.git/commitdiff
Add compilation warnings, and rename VRP struct property
authorpcarana <pc.moreno2099@gmail.com>
Tue, 2 Apr 2019 20:54:17 +0000 (14:54 -0600)
committerpcarana <pc.moreno2099@gmail.com>
Tue, 2 Apr 2019 20:54:17 +0000 (14:54 -0600)
src/Makefile.am
src/rtr/pdu_sender.c
src/vrps.c
src/vrps.h

index ce5019eb53216edefc50327394aecf51e7ed196f..74a897ab2e0d514b7f00306a4596d8f46056bd96 100644 (file)
@@ -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
index 421feddc9e59a98decb5eed6fd4c0e0dbe8e1abe..a7bf2e1a8c6b9d54d2ce1178ff6eff0c5c1ea932 100644 (file)
@@ -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;
index 6249ea57a59a4d20d5eda44b4fba339db05e7fa2..ff3ae7ccfb6e68a7c04818be7ccffd5ff4e90399 100644 (file)
@@ -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)));
 }
index d1be5ad36605f1d212dacfedb646f3d26cf05b0c..f6d4c208f5ef152c77b9a039dd85a069dd6fc02a 100644 (file)
@@ -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;
 };