From b3b6604f55b819748b4a37cad48e72e92a3b8a5c Mon Sep 17 00:00:00 2001 From: lordrasmus Date: Fri, 2 Jun 2023 15:48:30 +0200 Subject: [PATCH] code cleanup --- src/data_types.h | 10 +++++----- src/fping.c | 4 ++-- src/top_view.c | 8 ++++---- src/top_view.h | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/data_types.h b/src/data_types.h index 687275a..bef4c62 100644 --- a/src/data_types.h +++ b/src/data_types.h @@ -28,11 +28,11 @@ typedef struct host_entry { int64_t total_time_i; /* sum of response times */ int64_t *resp_times; /* individual response times */ - int top_view_print_pos; - int64_t top_view_last_timeouts; - int64_t top_view_last_timeouts_count; - int64_t top_view_last_timeouts_seq; - char last_timeout_time[100]; + int top_view_print_pos; /* line where the host is printed */ + int64_t top_view_last_timeouts; /* timeout Counter */ + int64_t top_view_last_timeouts_count; /* how many timeout occurred */ + int64_t top_view_last_timeouts_seq; /* how many packets where lost till the next answer arrived */ + char top_view_last_timeout_time[100]; /* buffer to print how long the last timeout was ( packets * period ) */ /* to avoid allocating two struct events each time that we send a ping, we * preallocate here two struct events for each ping that we might send for diff --git a/src/fping.c b/src/fping.c index 59f9d0d..ff46ac7 100644 --- a/src/fping.c +++ b/src/fping.c @@ -1322,7 +1322,7 @@ void main_loop() } printf("\n"); }else{ - print_top_view( h, 1 ); + top_view_print( h, 1 ); } } @@ -2455,7 +2455,7 @@ int wait_for_reply(int64_t wait_time) printf("\n"); }else{ - print_top_view( h, 0 ); + top_view_print( h, 0 ); } } diff --git a/src/top_view.c b/src/top_view.c index b5ad652..586eb17 100644 --- a/src/top_view.c +++ b/src/top_view.c @@ -96,13 +96,13 @@ static void print_top_view_init( void ){ -void print_top_view( HOST_ENTRY *h, int timeout ) { +void top_view_print( HOST_ENTRY *h, int timeout ) { print_top_view_init(); if ( h->top_view_print_pos == 0 ){ h->top_view_print_pos = next_view_pos++; - sprintf(h->last_timeout_time, "0 ms" ); + sprintf(h->top_view_last_timeout_time, "0 ms" ); } @@ -113,7 +113,7 @@ void print_top_view( HOST_ENTRY *h, int timeout ) { h->top_view_last_timeouts++; h->top_view_last_timeouts_seq = h->top_view_last_timeouts; - sprintf(h->last_timeout_time, "%"PRIi64" ms ", h->top_view_last_timeouts * ( perhost_interval / 1000 / 1000 ) ); + sprintf(h->top_view_last_timeout_time, "%"PRIi64" ms ", h->top_view_last_timeouts * ( perhost_interval / 1000 / 1000 ) ); }else{ @@ -134,7 +134,7 @@ void print_top_view( HOST_ENTRY *h, int timeout ) { pos_printf( 5 + h->top_view_print_pos, TIMEOUT_TOTAL_POS , "%"PRIi64, h->top_view_last_timeouts_count); pos_printf( 5 + h->top_view_print_pos, TIMEOUT_SEQ_POS , "%"PRIi64, h->top_view_last_timeouts_seq); - pos_printf( 5 + h->top_view_print_pos, TIMEOUT_TIME_POS , "%s", h->last_timeout_time); + pos_printf( 5 + h->top_view_print_pos, TIMEOUT_TIME_POS , "%s", h->top_view_last_timeout_time); diff --git a/src/top_view.h b/src/top_view.h index bb79da4..e112648 100644 --- a/src/top_view.h +++ b/src/top_view.h @@ -2,7 +2,7 @@ #include "data_types.h" -void print_top_view( HOST_ENTRY *h, int timeout ); +void top_view_print( HOST_ENTRY *h, int timeout ); void top_view_end( void );