Check argument of ef_cadef(), ef_nelem(), ef_flags(), ef_mtime()
This removes any need for calling ef_check() outside of file.c. Remove its only occurence, from symval(), and give it internal linkage.
This commit is contained in:
parent
1492845c12
commit
50cfdcb5a7
3 changed files with 10 additions and 4 deletions
|
@ -197,7 +197,6 @@ extern void *ef_ptr(int, int);
|
||||||
extern char *ef_nameof(int);
|
extern char *ef_nameof(int);
|
||||||
extern time_t ef_mtime(int);
|
extern time_t ef_mtime(int);
|
||||||
extern int ef_open(int, int, int);
|
extern int ef_open(int, int, int);
|
||||||
extern int ef_check(int);
|
|
||||||
extern int ef_close(int);
|
extern int ef_close(int);
|
||||||
extern int ef_flush(int);
|
extern int ef_flush(int);
|
||||||
extern void ef_blank(int, int, void *);
|
extern void ef_blank(int, int, void *);
|
||||||
|
|
|
@ -53,6 +53,7 @@ static int do_write(struct empfile *, void *, int, int);
|
||||||
static unsigned get_seqno(struct empfile *, int);
|
static unsigned get_seqno(struct empfile *, int);
|
||||||
static void new_seqno(struct empfile *, void *);
|
static void new_seqno(struct empfile *, void *);
|
||||||
static void do_blank(struct empfile *, void *, int, int);
|
static void do_blank(struct empfile *, void *, int, int);
|
||||||
|
static int ef_check(int);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Open the file-backed table TYPE (EF_SECTOR, ...).
|
* Open the file-backed table TYPE (EF_SECTOR, ...).
|
||||||
|
@ -691,24 +692,32 @@ ef_truncate(int type, int count)
|
||||||
struct castr *
|
struct castr *
|
||||||
ef_cadef(int type)
|
ef_cadef(int type)
|
||||||
{
|
{
|
||||||
|
if (ef_check(type) < 0)
|
||||||
|
return NULL;
|
||||||
return empfile[type].cadef;
|
return empfile[type].cadef;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ef_nelem(int type)
|
ef_nelem(int type)
|
||||||
{
|
{
|
||||||
|
if (ef_check(type) < 0)
|
||||||
|
return 0;
|
||||||
return empfile[type].fids;
|
return empfile[type].fids;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ef_flags(int type)
|
ef_flags(int type)
|
||||||
{
|
{
|
||||||
|
if (ef_check(type) < 0)
|
||||||
|
return 0;
|
||||||
return empfile[type].flags;
|
return empfile[type].flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
time_t
|
time_t
|
||||||
ef_mtime(int type)
|
ef_mtime(int type)
|
||||||
{
|
{
|
||||||
|
if (ef_check(type) < 0)
|
||||||
|
return 0;
|
||||||
if (empfile[type].fd <= 0)
|
if (empfile[type].fd <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
return fdate(empfile[type].fd);
|
return fdate(empfile[type].fd);
|
||||||
|
@ -765,7 +774,7 @@ ef_nameof(int type)
|
||||||
return empfile[type].name;
|
return empfile[type].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
ef_check(int type)
|
ef_check(int type)
|
||||||
{
|
{
|
||||||
if (CANT_HAPPEN((unsigned)type >= EF_MAX))
|
if (CANT_HAPPEN((unsigned)type >= EF_MAX))
|
||||||
|
|
|
@ -671,8 +671,6 @@ symval(struct castr *ca, int i)
|
||||||
{
|
{
|
||||||
int type = ca->ca_table;
|
int type = ca->ca_table;
|
||||||
|
|
||||||
if (ef_check(type) < 0)
|
|
||||||
return -1;
|
|
||||||
if (ef_cadef(type) == symbol_ca)
|
if (ef_cadef(type) == symbol_ca)
|
||||||
/* symbol table, value is in the table */
|
/* symbol table, value is in the table */
|
||||||
return ((struct symbol *)ef_ptr(type, i))->value;
|
return ((struct symbol *)ef_ptr(type, i))->value;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue