[Nagios-devel] [PATCH 5/6] utils: Make internal prototypes easier

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] [PATCH 5/6] utils: Make internal prototypes easier

Post by Guest »

There was a mention about the old prototype (for an internal method)
making the code easier to test - in fact, it didn't, it just made things
more awkward.

Signed-off-by: Robin Sonefors
---
base/utils.c | 14 +++++++-------
t-tap/test_timeperiods.c | 36 ++++++++++++++++++------------------
2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/base/utils.c b/base/utils.c
index 739087c..99946fb 100644
--- a/base/utils.c
+++ b/base/utils.c
@@ -970,9 +970,9 @@ int check_time_against_period(time_t test_time, timeperiod *tperiod) {

/*#define TEST_TIMEPERIODS_B 1*/

-void _get_next_valid_time(time_t pref_time, time_t current_time, time_t *valid_time, timeperiod *tperiod);
+void _get_next_valid_time(time_t pref_time, time_t *valid_time, timeperiod *tperiod);

-static void _get_next_invalid_time(time_t pref_time, time_t current_time, time_t *invalid_time, timeperiod *tperiod) {
+static void _get_next_invalid_time(time_t pref_time, time_t *invalid_time, timeperiod *tperiod) {
timeperiodexclusion *temp_timeperiodexclusion = NULL;
int depth = 0;
int max_depth = 300; // commonly roughly equal to "days in the future"
@@ -1029,7 +1029,7 @@ static void _get_next_invalid_time(time_t pref_time, time_t current_time, time_t
}

for(temp_timeperiodexclusion = tperiod->exclusions; temp_timeperiodexclusion != NULL; temp_timeperiodexclusion = temp_timeperiodexclusion->next) {
- _get_next_valid_time(last_earliest_time, current_time, &potential_time, temp_timeperiodexclusion->timeperiod_ptr);
+ _get_next_valid_time(last_earliest_time, &potential_time, temp_timeperiodexclusion->timeperiod_ptr);
if (potential_time + 60 exclusions; temp_timeperiodexclusion != NULL; temp_timeperiodexclusion = temp_timeperiodexclusion->next) {
- _get_next_invalid_time(earliest_time, current_time, &earliest_time, temp_timeperiodexclusion->timeperiod_ptr);
+ _get_next_invalid_time(earliest_time, &earliest_time, temp_timeperiodexclusion->timeperiod_ptr);
#ifdef TEST_TIMEPERIODS_B
printf(" FINAL EARLIEST TIME: %lu = %s", (unsigned long)earliest_time, ctime(&earliest_time));
#endif
@@ -1145,7 +1145,7 @@ void get_next_valid_time(time_t pref_time, time_t *valid_time, timeperiod *tperi

pref_time = (pref_time < current_time) ? current_time : pref_time;

- _get_next_valid_time(pref_time, current_time, valid_time, tperiod);
+ _get_next_valid_time(pref_time, valid_time, tperiod);
}


diff --git a/t-tap/test_timeperiods.c b/t-tap/test_timeperiods.c
index e660855..6aa292f 100644
--- a/t-tap/test_timeperiods.c
+++ b/t-tap/test_timeperiods.c
@@ -147,7 +147,7 @@ int main(int argc, char **argv) {
is_valid_time = check_time_against_period(test_time, temp_timeperiod);
ok(is_valid_time == OK, "Always OK for 24x7 with TZ=UTC, time_t=%lu", test_time);
chosen_valid_time = 0L;
- _get_next_valid_time(test_time, test_time, &chosen_valid_time, temp_timeperiod);
+ _get_next_valid_time(test_time, &chosen_valid_time, temp_timeperiod);
ok(test_time == chosen_valid_time, "get_next_valid_time always returns same time");
test_time += 1800;
c++;
@@ -160,7 +160,7 @@ int main(int argc, char **argv) {
while(c < iterations) {
is_valid_time = check_time_against_period(test_time,

...[email truncated]...


This post was automatically imported from historical nagios-devel mailing list archives
Original poster: robin.sonefors@op5.com
Locked