]> git.pond.sub.org Git - empserver/commitdiff
Simplify how ef_write() handles write beyond end of file
authorMarkus Armbruster <armbru@pond.sub.org>
Fri, 29 Apr 2011 05:23:07 +0000 (07:23 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Sat, 25 Jun 2011 14:50:06 +0000 (16:50 +0200)
src/lib/common/file.c

index 31ecc260b888729b0437afbd123839e50cb28fa7..a200fca27bbc2e464e3920f5e2f59342b62c7f30 100644 (file)
@@ -520,11 +520,12 @@ ef_write(int type, int id, void *from)
     ep = &empfile[type];
     if (CANT_HAPPEN((ep->flags & (EFF_MEM | EFF_PRIVATE)) == EFF_PRIVATE))
        return 0;
-    if (CANT_HAPPEN((ep->flags & EFF_MEM) ? id >= ep->fids : id > ep->fids))
-       return 0;               /* not implemented */
     new_seqno(ep, from);
     if (id >= ep->fids) {
-       /* write beyond end of file extends it, take note */
+       /* beyond end of file */
+       if (CANT_HAPPEN((ep->flags & EFF_MEM) || id > ep->fids))
+           return 0;           /* not implemented */
+       /* write at end of file extends it */
        ep->fids = id + 1;
        if (ep->onresize)
            ep->onresize(type);