Vitezslav Samel vitezslav@samel.cz writes:
Make use of structures and helper functions to clean up this function.
Signed-off-by: Vitezslav Samel vitezslav@samel.cz
src/ifstats.c | 328 +++++++++++++++++--------------------------------------- src/ifstats.h | 80 ++++---------- src/log.c | 110 ++++++++++++-------- 3 files changed, 187 insertions(+), 331 deletions(-)
ts->total.total.packets,
ts->total.total.bytes);
This looks pretty bad. Total in total? The code will became hard to grep. I suggest to change the name of items in struct.
counter looks to me too generic. it's packet counter. better name could be *pkt_counter* and all the items should be prefixed with pc_ like
struct pkt_counter unsigned long long pc_packets;
+struct counter {
- unsigned long long packets;
uint64_t?
- unsigned long long bytes;
+};
prefix it with e.g. with *pr_*
+struct proto_counter {
- struct counter total;
- struct counter in;
- struct counter out;
+};
and e.g. *i_*
+struct ifcounts {
- struct proto_counter total;
- struct counter bcast;
- struct counter bad;
- struct proto_counter ipv4;
- struct proto_counter ipv6;
- struct proto_counter nonip;
- struct proto_counter tcp;
- struct proto_counter udp;
- struct proto_counter icmp;
- struct proto_counter other;
};