Use C99 style initializers everywhere
This big patch was compiled by vimgrepping for memset calls and changing
to C99 initializer if applicable. One notable exception is the
initialization of union bpf_attr in tc/tc_bpf.c: changing it would break
for older gcc versions (at least <=3.4.6).
Calls to memset for struct rtattr pointer fields for parse_rtattr*()
were just dropped since they are not needed.
The changes here allowed the compiler to discover some unused variables,
so get rid of them, too.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: David Ahern <dsa@cumulusnetworks.com>
diff --git a/tc/q_hfsc.c b/tc/q_hfsc.c
index 9ebe323..cf784f1 100644
--- a/tc/q_hfsc.c
+++ b/tc/q_hfsc.c
@@ -73,9 +73,7 @@
static int
hfsc_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
{
- struct tc_hfsc_qopt qopt;
-
- memset(&qopt, 0, sizeof(qopt));
+ struct tc_hfsc_qopt qopt = {};
while (argc > 0) {
if (matches(*argv, "default") == 0) {
@@ -146,15 +144,10 @@
hfsc_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,
struct nlmsghdr *n)
{
- struct tc_service_curve rsc, fsc, usc;
- int rsc_ok, fsc_ok, usc_ok;
+ struct tc_service_curve rsc = {}, fsc = {}, usc = {};
+ int rsc_ok = 0, fsc_ok = 0, usc_ok = 0;
struct rtattr *tail;
- memset(&rsc, 0, sizeof(rsc));
- memset(&fsc, 0, sizeof(fsc));
- memset(&usc, 0, sizeof(usc));
- rsc_ok = fsc_ok = usc_ok = 0;
-
while (argc > 0) {
if (matches(*argv, "rt") == 0) {
NEXT_ARG();