]> git.pond.sub.org Git - empserver/commitdiff
Check argument of ef_cadef(), ef_nelem(), ef_flags(), ef_mtime()
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 1 Sep 2008 13:34:16 +0000 (09:34 -0400)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 4 Sep 2008 00:43:13 +0000 (20:43 -0400)
This removes any need for calling ef_check() outside of file.c.
Remove its only occurence, from symval(), and give it internal
linkage.

include/file.h
src/lib/common/file.c
src/lib/common/xundump.c

index 55aa672d94c53b69d45769f3287bd80780ab9cff..3d8587bd50b4a10afe84f311782f37a3b82f094c 100644 (file)
@@ -197,7 +197,6 @@ extern void *ef_ptr(int, int);
 extern char *ef_nameof(int);
 extern time_t ef_mtime(int);
 extern int ef_open(int, int, int);
-extern int ef_check(int);
 extern int ef_close(int);
 extern int ef_flush(int);
 extern void ef_blank(int, int, void *);
index c3b082d72718c732f0e95067dfc81095c5e797db..81b0b97d8e2987f06712b3b148bc259bbee2cf0b 100644 (file)
@@ -53,6 +53,7 @@ static int do_write(struct empfile *, void *, int, int);
 static unsigned get_seqno(struct empfile *, int);
 static void new_seqno(struct empfile *, void *);
 static void do_blank(struct empfile *, void *, int, int);
+static int ef_check(int);
 
 /*
  * Open the file-backed table TYPE (EF_SECTOR, ...).
@@ -691,24 +692,32 @@ ef_truncate(int type, int count)
 struct castr *
 ef_cadef(int type)
 {
+    if (ef_check(type) < 0)
+       return NULL;
     return empfile[type].cadef;
 }
 
 int
 ef_nelem(int type)
 {
+    if (ef_check(type) < 0)
+       return 0;
     return empfile[type].fids;
 }
 
 int
 ef_flags(int type)
 {
+    if (ef_check(type) < 0)
+       return 0;
     return empfile[type].flags;
 }
 
 time_t
 ef_mtime(int type)
 {
+    if (ef_check(type) < 0)
+       return 0;
     if (empfile[type].fd <= 0)
        return 0;
     return fdate(empfile[type].fd);
@@ -765,7 +774,7 @@ ef_nameof(int type)
     return empfile[type].name;
 }
 
-int
+static int
 ef_check(int type)
 {
     if (CANT_HAPPEN((unsigned)type >= EF_MAX))
index abef9c27e664d1a6b73198938a3d44de72e2c9e8..0a811974d843ee830b5606181fbb67d5c8059312 100644 (file)
@@ -671,8 +671,6 @@ symval(struct castr *ca, int i)
 {
     int type = ca->ca_table;
 
-    if (ef_check(type) < 0)
-       return -1;
     if (ef_cadef(type) == symbol_ca)
        /* symbol table, value is in the table */
        return ((struct symbol *)ef_ptr(type, i))->value;