From 2b0b53992f094c65ca2bbffa38bb21d4ac21e590 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 29 Apr 2011 07:23:07 +0200 Subject: [PATCH] Simplify how ef_write() handles write beyond end of file --- src/lib/common/file.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/lib/common/file.c b/src/lib/common/file.c index 31ecc260b..a200fca27 100644 --- a/src/lib/common/file.c +++ b/src/lib/common/file.c @@ -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); -- 2.43.0