diff --git a/src/ucore_logging.c b/src/ucore_logging.c index 87e25b2..bbf3231 100644 --- a/src/ucore_logging.c +++ b/src/ucore_logging.c @@ -186,7 +186,7 @@ static inline void uc_log_remove_dest_unlocked(struct uc_log_destination *dest) //check that it's not already removed SLIST_FOREACH(it, &destinations, entry) { - if(it == dest); + if(it == dest) break; } diff --git a/test/test_logging.c b/test/test_logging.c index fd59c12..6a676d6 100644 --- a/test/test_logging.c +++ b/test/test_logging.c @@ -195,14 +195,20 @@ START_TEST (test_logfile_remove_dest) .cnt = 1, }; struct stat st; - struct uc_log_destination *dest; + struct uc_log_destination *dest1, *dest2; int rc; uc_log_init(&mods); - dest = uc_log_new_file(file_name, UC_LL_DEBUG, 1); - fail_if(dest == NULL); - uc_log_add_destination(dest); + + dest1 = uc_log_new_file(file_name, UC_LL_DEBUG, 1); + fail_if(dest1 == NULL); + + dest2 = uc_log_new_stderr(UC_LL_WARNING, 1); + fail_if(dest2 == NULL); + + uc_log_add_destination(dest1); + uc_log_add_destination(dest2); UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); @@ -211,7 +217,7 @@ START_TEST (test_logfile_remove_dest) fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); fail_if(st.st_size != 80*2, "was %ld\n", (long)st.st_size);//should be 82 chars per log statement - uc_log_remove_destination(dest); + uc_log_remove_destination(dest1); UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1); //should not be logged now