From 5fda9462bd7263fe52d892b34b254114a7b6c3f5 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 24 Feb 2008 20:33:57 +0100 Subject: [PATCH] Fix tests for unused news slots delete_old_news() and init_nreport() tested for non-zero nws_when, which is breaks for news at the epoch. Not likely to happen, but still wrong. ncache() tested nws_uid, which breaks for the first entry in the news file. This made ncache() overlook that entry in the cache, and create a new news item instead of incrementing nws_ntm. Was always broken that way. Fix by testing nws_vrb instead. --- src/lib/subs/nreport.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/subs/nreport.c b/src/lib/subs/nreport.c index aa47fc48..37e37edc 100644 --- a/src/lib/subs/nreport.c +++ b/src/lib/subs/nreport.c @@ -97,7 +97,7 @@ delete_old_news(void) /* skip over expired news */ expiry_time = time(NULL) - days(news_keep_days); for (i = 0; getnews(i, &news); i++) { - if (news.nws_when == 0 || news.nws_when >= expiry_time) + if (news.nws_vrb == 0 || news.nws_when >= expiry_time) break; } /* news id 0..I-1 have expired */ @@ -108,7 +108,7 @@ delete_old_news(void) /* move unexpired news I.. to 0.., overwriting expired news */ for (j = 0; getnews(i + j, &news); j++) { - if (news.nws_when == 0) + if (news.nws_vrb == 0) break; news.nws_uid = j; putnews(j, &news); @@ -137,7 +137,7 @@ init_nreport(void) struct nwsstr news; for (newest_item = 0; getnews(newest_item, &news); newest_item++) { - if (news.nws_when == 0) + if (news.nws_vrb == 0) break; } news_tail = newest_item; @@ -165,7 +165,7 @@ ncache(int actor, int event, int victim, int times) oldslot = i; oldtime = np->nws_when; } - if (np->nws_uid == 0) + if (np->nws_vrb == 0) continue; if (now - np->nws_when > minutes(5)) continue;