]> git.pond.sub.org Git - empserver/commitdiff
Change struct empfile callback onresize() to return void
authorMarkus Armbruster <armbru@pond.sub.org>
Thu, 28 Apr 2011 18:38:39 +0000 (20:38 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 25 Jun 2011 14:50:05 +0000 (16:50 +0200)
ef_open() handles onresize() failing incorrectly.  Instead of fixing
that, drop the failure mode.  It's not really used: unit_onresize()
fails only when used incorrectly.  It isn't.  If it ever is, ignoring
the failure is safe.

include/file.h
include/unit.h
src/lib/common/cargo.c
src/lib/common/file.c
src/lib/subs/fileinit.c

index c5887efcc39392272a223adf4ee50a7d7d32c9ac..47964a7111ef91ea621f612a99af2ceb26cceca8 100644 (file)
@@ -79,9 +79,8 @@ struct empfile {
     void (*prewrite)(int id, void *old, void *elt);
     /*
      * Called after table size changed, with file type as argument.
-     * Return -1 and set errno to make the operation fail.
      */
-    int (*onresize)(int type);
+    void (*onresize)(int type);
 };
 
 struct emptypedstr {
index e7e37b29893665a2eb95629abcd1180cde3b5563..06d082f02bca1dcbb5e764006987a4be15576935 100644 (file)
@@ -52,7 +52,7 @@ extern int unit_cargo_first(int, int, int);
 extern int unit_cargo_next(int, int);
 extern int unit_cargo_count(int, int, int);
 extern int unit_nplane(int, int, int *, int *, int *);
-extern int unit_onresize(int);
+extern void unit_onresize(int);
 
 extern void unit_list(struct emp_qelem *);
 extern void unit_put(struct emp_qelem *list, natid actor);
index 0152affc2eec3a5beea17cbd5ae9715c745c6899..36df0b2d79056dc6842076e4580df3fce88fa3e3 100644 (file)
@@ -276,14 +276,14 @@ unit_cargo_init(void)
  * Return 0 on success, -1 on error.
  * This is the struct empfile onresize callback for units.
  */
-int
+void
 unit_onresize(int type)
 {
     int n, i;
     struct clink *cl;
 
     if (CANT_HAPPEN(type < EF_SHIP || type > EF_NUKE))
-       return -1;
+       return;
 
     n = ef_nelem(type);
     cl = realloc(clink[type], n * sizeof(*clink[type]));
@@ -295,7 +295,6 @@ unit_onresize(int type)
     nclink[type] = n;
     if (ef_flags(type) & EFF_MEM)
        clink_check(type);
-    return 0;
 }
 
 /*
index 388f8c6a5e11a7aac925999c0cb7ee9240bbadd6..c02afb373adc22d89afbb09469544905f17372cc 100644 (file)
@@ -150,8 +150,8 @@ ef_open(int type, int how, int nelt)
        }
     }
 
-    if (ep->onresize && ep->onresize(type) < 0)
-       return 0;
+    if (ep->onresize)
+       ep->onresize(type);
     return 1;
 }
 
@@ -275,8 +275,8 @@ ef_close(int type)
     }
     ep->flags &= EFF_IMMUTABLE;
     ep->baseid = ep->cids = ep->fids = 0;
-    if (ep->onresize && ep->onresize(type) < 0)
-       retval = 0;
+    if (ep->onresize)
+       ep->onresize(type);
     return retval;
 }
 
@@ -523,8 +523,8 @@ ef_write(int type, int id, void *from)
     if (id >= ep->fids) {
        /* write beyond end of file extends it, take note */
        ep->fids = id + 1;
-       if (ep->onresize && ep->onresize(type) < 0)
-           return 0;
+       if (ep->onresize)
+           ep->onresize(type);
     }
     if (id >= ep->baseid && id < ep->baseid + ep->cids) {
        cachep = ep->cache + (id - ep->baseid) * ep->size;
@@ -708,8 +708,8 @@ ef_extend(int type, int count)
        }
     }
     ep->fids = id + count;
-    if (ep->onresize && ep->onresize(type) < 0)
-       return 0;
+    if (ep->onresize)
+       ep->onresize(type);
     return 1;
 }
 
@@ -801,8 +801,8 @@ ef_truncate(int type, int count)
            ep->cids = count - ep->baseid;
     }
 
-    if (ep->onresize && ep->onresize(type) < 0)
-       return 0;
+    if (ep->onresize)
+       ep->onresize(type);
     return 1;
 }
 
index 7d3183d64af76b88a028e2c4bbd5975fe230f309..b670de43574c373a105c0ecd264ff2edd18e3196 100644 (file)
@@ -44,7 +44,7 @@ struct fileinit {
     void (*oninit)(void *);
     void (*postread)(int, void *);
     void (*prewrite)(int, void *, void *);
-    int (*onresize)(int);
+    void (*onresize)(int);
 };
 
 static struct fileinit fileinit[] = {