Commit 1babbbb8 authored by Per Cederqvist's avatar Per Cederqvist

(rcsid): Added a missing const.

(next_free_num): Changed type from int to Conf_no.
(next_text_num): Changed type from int to Text_no.
(read_person): Flag unused parameters.
(read_conference): Likewise.
(read_text_stat): Likewise.
(cached_get_text_stat): Adjusted printf format according to
	the next_text_num change.
(init_cache): Likewise.
(free_match_table): Renamed a parameter name to avoid
	warnings from gcc.
(build_matching_info): Renamed a local variable name to avoid
	warnings from gcc.
(pre_sync): Use tno_iter and cno_iter instead of i to get all
	types correct.
(post_sync): Likewise.
(copy_file): Flag unused parameters.
parent b57794b6
/*
* $Id: simple-cache.c,v 0.65 1998/06/14 14:51:22 byers Exp $
* $Id: simple-cache.c,v 0.66 1998/07/08 17:07:33 ceder Exp $
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -34,7 +34,8 @@
* Attempt at newer algorithm by byers (FASTSAVE)
*/
static char *rcsid = "$Id: simple-cache.c,v 0.65 1998/06/14 14:51:22 byers Exp $";
static const char *
rcsid = "$Id: simple-cache.c,v 0.66 1998/07/08 17:07:33 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -84,6 +85,7 @@ USE(rcsid);
#include "param.h"
#include "config.h"
#include "admin.h"
#include "unused.h"
/*
* Possible improvements: +++
......@@ -101,10 +103,10 @@ USE(rcsid);
static Small_conf * small_conf_arr[ MAX_CONF ];
static Cache_node_mcb * pers_mcb;
static Cache_node_mcb * conf_mcb;
static int next_free_num = 1;
static Conf_no next_free_num = 1;
static Cache_node_mcb * text_mcb;
static int next_text_num = 1;
static Text_no next_text_num = 1;
/*
* The elements in the following lists with same index refers to the same
......@@ -151,6 +153,11 @@ static enum {
*/
#ifndef FASTSAVE
/* sync_next should be split in next_text_to_sync and
next_conf_to_sync to avoid warnings about the different sizes of
Conf_no and Text_no. Since that is indeed done if FASTSAVE is set,
don't bother doing it in the old code that will anyhow soon be
replaced. */
static long sync_next;
#endif
......@@ -223,7 +230,7 @@ static void log_access(Log_type t,
static Person *
read_person(FILE *fp,
long pos,
long size)
long UNUSED(size)) /* FIXME: should sanity-check the size */
{
Person *p;
long dummy;
......@@ -245,7 +252,7 @@ read_person(FILE *fp,
static Conference *
read_conference(FILE *fp,
long pos,
long size)
long UNUSED(size)) /* FIXME: should sanity-check the size */
{
Conference *c;
long dummy;
......@@ -266,7 +273,7 @@ read_conference(FILE *fp,
static Text_stat *
read_text_stat(FILE *fp,
long pos,
long size)
long UNUSED(size)) /* FIXME: should sanity-check the size */
{
Text_stat *t;
long dummy;
......@@ -897,7 +904,7 @@ cached_get_text_stat( Text_no text )
Cache_node *node;
TRACE2("cached_get_text_stat(%lu); next_text_num == ", text);
TRACE2("%d\n", next_text_num);
TRACE2("%lu\n", (unsigned long)next_text_num);
if ( text == 0 )
{
......@@ -1263,17 +1270,17 @@ cached_unlock_conf(Conf_no conf_no)
/* Free the _contents_ of a match_table. The table itself i _not_ freed. */
static void
free_match_table(Matching_info *match)
free_match_table(Matching_info *mtch)
{
if ( match == NULL )
if ( mtch == NULL )
return;
while ( ! s_empty( match->name ))
while ( ! s_empty( mtch->name ))
{
free_tokens( match->tokens );
/* match->name is not freed since it points into conf_arr[]. */
free_tokens( mtch->tokens );
/* mtch->name is not freed since it points into conf_arr[]. */
++match;
++mtch;
}
}
......@@ -1281,7 +1288,7 @@ extern Success
build_matching_info(void)
{
Conf_no i;
Matching_info *match;
Matching_info *mtch;
Conf_no *conf;
free_match_table(match_table);
......@@ -1291,7 +1298,7 @@ build_matching_info(void)
no_of_match_info = 0;
match = match_table;
mtch = match_table;
conf = conf_table;
for ( i = 1; i < next_free_num; i++ )
......@@ -1299,19 +1306,19 @@ build_matching_info(void)
if ( small_conf_arr[ i ] != NULL
&& ! s_empty ( small_conf_arr[ i ]->name ) )
{
match->name = small_conf_arr[ i ]->name;
match->tokens = tokenize(match->name, s_fcrea_str(WHITESPACE));
match->priority = 7;
mtch->name = small_conf_arr[ i ]->name;
mtch->tokens = tokenize(mtch->name, s_fcrea_str(WHITESPACE));
mtch->priority = 7;
*conf = i;
++match;
++mtch;
++conf;
++no_of_match_info;
}
}
match->name = EMPTY_STRING;
match->tokens = NULL;
match->priority = 0;
mtch->name = EMPTY_STRING;
mtch->tokens = NULL;
mtch->priority = 0;
*conf = 0;
return OK;
......@@ -1419,7 +1426,8 @@ get_version(const char *fn)
static void
pre_sync(void)
{
long i;
Text_no tno_iter;
Conf_no cno_iter;
Cache_node *node;
async_sync_db();
......@@ -1432,9 +1440,9 @@ pre_sync(void)
highest_conf_no = next_free_num;
#ifndef FASTSAVE
for ( i = 1; i < highest_conf_no; i++ )
for ( cno_iter = 1; cno_iter < highest_conf_no; cno_iter++ )
{
node = get_conf_node(i);
node = get_conf_node(cno_iter);
if ( node == NULL )
continue;
......@@ -1442,7 +1450,7 @@ pre_sync(void)
if (node->s.exists == 0)
{
unlink_conf_lru(node);
destruct_cache_node(conf_mcb, i);
destruct_cache_node(conf_mcb, cno_iter);
}
else
{
......@@ -1464,9 +1472,9 @@ pre_sync(void)
}
}
for ( i = 1; i < highest_conf_no; i++ )
for ( cno_iter = 1; cno_iter < highest_conf_no; cno_iter++ )
{
node = get_pers_node(i);
node = get_pers_node(cno_iter);
if ( node == NULL )
continue;
......@@ -1474,7 +1482,7 @@ pre_sync(void)
if (node->s.exists == 0)
{
unlink_pers_lru(node);
destruct_cache_node(pers_mcb, i);
destruct_cache_node(pers_mcb, cno_iter);
}
else
{
......@@ -1496,9 +1504,9 @@ pre_sync(void)
}
}
for ( i = 1; i < highest_text_no; i++ )
for ( tno_iter = 1; tno_iter < highest_text_no; tno_iter++ )
{
node = get_text_node(i);
node = get_text_node(tno_iter);
if ( node == NULL )
continue;
......@@ -1506,7 +1514,7 @@ pre_sync(void)
if (node->s.exists == 0)
{
unlink_text_lru(node);
destruct_cache_node(text_mcb, i);
destruct_cache_node(text_mcb, tno_iter);
}
else
{
......@@ -1590,7 +1598,7 @@ copy_file(FILE *from,
FILE *to,
long from_pos,
long len,
long no)
long UNUSED(no)) /* FIXME: should sanity-check no. */
{
char *buf;
long result;
......@@ -1761,7 +1769,8 @@ save_one_pers(void)
static void
post_sync(void)
{
int i;
Text_no tno_iter;
Conf_no cno_iter;
Cache_node *node;
async_sync_db();
......@@ -1779,9 +1788,9 @@ post_sync(void)
return;
}
for ( i = 1; i < highest_conf_no; i++ )
for ( cno_iter = 1; cno_iter < highest_conf_no; cno_iter++ )
{
node = get_conf_node(i);
node = get_conf_node(cno_iter);
if ( node != NULL )
{
node->pos = node->pos_b;
......@@ -1791,9 +1800,9 @@ post_sync(void)
}
}
for ( i = 1; i < highest_conf_no; i++ )
for ( cno_iter = 1; cno_iter < highest_conf_no; cno_iter++ )
{
node = get_pers_node(i);
node = get_pers_node(cno_iter);
if ( node != NULL )
{
node->pos = node->pos_b;
......@@ -1803,9 +1812,9 @@ post_sync(void)
}
}
for ( i = 1; i < highest_text_no; i++ )
for ( tno_iter = 1; tno_iter < highest_text_no; tno_iter++ )
{
node = get_text_node(i);
node = get_text_node(tno_iter);
if ( node != NULL )
{
node->pos = node->pos_b;
......@@ -2405,7 +2414,7 @@ init_cache(void)
build_matching_info();
log("Read %d confs/persons and %d texts\n",
log("Read %d confs/persons and %ld texts\n",
next_free_num, next_text_num);
return OK;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment