From fa325e9b42b0bdfb48857d1958d9fb7ceac55151 Mon Sep 17 00:00:00 2001 From: Dan Cross Date: Fri, 10 Jan 2020 14:44:21 +0000 Subject: Trivial changes: whitespace and modes. Remote whitespace at the ends of lines. Remove blank lines from the ends of files. Change modes on source files so that they are not executable. Signed-off-by: Dan Cross --- src/libventi/cache.c | 15 +++++++-------- src/libventi/client.c | 2 +- src/libventi/cvt.h | 1 - src/libventi/debug.c | 1 - src/libventi/debugpacket.c | 9 ++++----- src/libventi/dtype.c | 1 - src/libventi/entry.c | 9 ++++----- src/libventi/file.c | 18 ++++++++--------- src/libventi/hangup.c | 1 - src/libventi/log.c | 15 +++++++-------- src/libventi/mem.c | 7 +++---- src/libventi/packet.c | 48 +++++++++++++++++++++++----------------------- src/libventi/queue.c | 2 +- src/libventi/rpc.c | 7 +++---- src/libventi/send.c | 9 ++++----- src/libventi/server.c | 3 +-- src/libventi/strdup.c | 1 - src/libventi/string.c | 1 - src/libventi/time.c | 9 ++++----- src/libventi/zero.c | 2 +- src/libventi/zeroscore.c | 1 - 21 files changed, 73 insertions(+), 89 deletions(-) (limited to 'src/libventi') diff --git a/src/libventi/cache.c b/src/libventi/cache.c index da0d103e..aed19c55 100644 --- a/src/libventi/cache.c +++ b/src/libventi/cache.c @@ -176,7 +176,7 @@ upheap(int i, VtBlock *b) u32int now; int p; VtCache *c; - + c = b->c; now = c->now; for(; i != 0; i = p){ @@ -200,7 +200,7 @@ downheap(int i, VtBlock *b) u32int now; int k; VtCache *c; - + c = b->c; now = c->now; for(; ; i = k){ @@ -291,7 +291,7 @@ vtcachebumpblock(VtCache *c) b->prev = nil; } - + if(0)fprint(2, "droping %x:%V\n", b->addr, b->score); /* set vtBlock to a reasonable state */ b->ref = 1; @@ -306,7 +306,7 @@ static VtBlock* vtcacheevict(VtCache *c, ulong size) { VtBlock *b; - + /* * If we were out of memory and put some blocks * to the side but now we have memory, grab one. @@ -317,7 +317,7 @@ vtcacheevict(VtCache *c, ulong size) b->next = nil; goto alloc; } - + /* * Otherwise, evict until we have memory. */ @@ -474,7 +474,7 @@ vtcacheglobal(VtCache *c, uchar score[VtScoreSize], int type, ulong size) /* * Lock b before unlocking c, so that others wait while we read. - * + * * You might think there is a race between this qlock(b) before qunlock(c) * and the qlock(c) while holding a qlock(b) in vtblockwrite. However, * the block here can never be the block in a vtblockwrite, so we're safe. @@ -542,7 +542,7 @@ if(0)fprint(2, "vtblockput: %d: %x %d %d\n", getpid(), b->addr, c->nheap, b->ios * b->nlock should probably stay at zero while * the vtBlock is unlocked, but diskThread and vtSleep * conspire to assume that they can just qlock(&b->lk); vtblockput(b), - * so we have to keep b->nlock set to 1 even + * so we have to keep b->nlock set to 1 even * when the vtBlock is unlocked. */ assert(b->nlock == 0); @@ -642,4 +642,3 @@ vtglobaltolocal(uchar score[VtScoreSize]) return NilBlock; return (score[16]<<24)|(score[17]<<16)|(score[18]<<8)|score[19]; } - diff --git a/src/libventi/client.c b/src/libventi/client.c index f76fd343..14f4543f 100644 --- a/src/libventi/client.c +++ b/src/libventi/client.c @@ -182,7 +182,7 @@ int vtgoodbye(VtConn *z) { VtFcall tx, rx; - + tx.msgtype = VtTgoodbye; vtfcallrpc(z, &tx, &rx); /* always fails: no VtRgoodbye */ return 0; diff --git a/src/libventi/cvt.h b/src/libventi/cvt.h index ef4c2f51..4d61dbed 100644 --- a/src/libventi/cvt.h +++ b/src/libventi/cvt.h @@ -12,4 +12,3 @@ #define U32PUT(p,v) (p)[0]=(v)>>24;(p)[1]=(v)>>16;(p)[2]=(v)>>8;(p)[3]=(v) #define U48PUT(p,v,t32) t32=(v)>>32;U16PUT(p,t32);t32=(v);U32PUT((p)+2,t32) #define U64PUT(p,v,t32) t32=(v)>>32;U32PUT(p,t32);t32=(v);U32PUT((p)+4,t32) - diff --git a/src/libventi/debug.c b/src/libventi/debug.c index e0452e48..9549d89b 100644 --- a/src/libventi/debug.c +++ b/src/libventi/debug.c @@ -14,4 +14,3 @@ vtdebug(VtConn *z, char *fmt, ...) vfprint(2, fmt, arg); va_end(arg); } - diff --git a/src/libventi/debugpacket.c b/src/libventi/debugpacket.c index 4c13bc87..1fbfea6a 100644 --- a/src/libventi/debugpacket.c +++ b/src/libventi/debugpacket.c @@ -19,7 +19,7 @@ Packet* packetalloc(void) { Packet *p; - + p = vtmallocz(sizeof *p); p->free = vtfree; p->arg = nil; @@ -52,7 +52,7 @@ int packetcmp(Packet *p, Packet *q) { int i, len; - + NOTFREE(p); NOTFREE(q); len = p->len; @@ -129,7 +129,7 @@ Packet* packetforeign(uchar *buf, int n, void (*free)(void*), void *a) { Packet *p; - + if(n < 0) abort(); p = packetalloc(); @@ -224,7 +224,7 @@ Packet* packetsplit(Packet *p, int n) { Packet *q; - + NOTFREE(p); q = packetalloc(); q->data = vtmalloc(n); @@ -262,4 +262,3 @@ packettrim(Packet *p, int offset, int n) p->len -= n; return 0; } - diff --git a/src/libventi/dtype.c b/src/libventi/dtype.c index 7886518e..7b0867ba 100644 --- a/src/libventi/dtype.c +++ b/src/libventi/dtype.c @@ -75,4 +75,3 @@ vtfromdisktype(uint n) return VtCorruptType; return fromdisk[n]; } - diff --git a/src/libventi/entry.c b/src/libventi/entry.c index 5e9a7c1f..12fb9589 100644 --- a/src/libventi/entry.c +++ b/src/libventi/entry.c @@ -21,7 +21,7 @@ vttobig(ulong n) { int shift; ulong n0; - + n0 = n; shift = 0; while(n >= (1<<(16 - 5))) { @@ -30,7 +30,7 @@ vttobig(ulong n) shift++; n >>= 1; } - + n = (n<<5) | shift; if(((n>>5)<<(n&31)) != n0) sysfatal("vttobig %#lux => %#lux failed", n0, n); @@ -111,11 +111,11 @@ vtentryunpack(VtEntry *e, uchar *p, int index) p += VtScoreSize; assert(p-op == VtEntrySize); - + if(!(e->flags & VtEntryActive)) return 0; - /* + /* * Some old vac files use psize==0 and dsize==0 when the * file itself has size 0 or is zeros. Just to make programs not * have to figure out what block sizes of 0 means, rewrite them. @@ -130,4 +130,3 @@ vtentryunpack(VtEntry *e, uchar *p, int index) return 0; } - diff --git a/src/libventi/file.c b/src/libventi/file.c index e97df39c..8a051248 100644 --- a/src/libventi/file.c +++ b/src/libventi/file.c @@ -4,7 +4,7 @@ * The single point of truth for the info about the VtFiles themselves * is the block data. Because of this, there is no explicit locking of * VtFile structures, and indeed there may be more than one VtFile - * structure for a given Venti file. They synchronize through the + * structure for a given Venti file. They synchronize through the * block cache. * * This is a bit simpler than fossil because there are no epochs @@ -182,7 +182,7 @@ _vtfilecreate(VtFile *r, int o, int psize, int dsize, int type) int epb; VtFile *rr; u32int offset; - + assert(ISLOCKED(r)); assert(type == VtDirType || type == VtDataType); @@ -574,7 +574,7 @@ growdepth(VtFile *r, VtBlock *p, VtEntry *e, int depth) if(bb == nil) break; memmove(bb->data, b->score, VtScoreSize); - memmove(e->score, bb->score, VtScoreSize); + memmove(e->score, bb->score, VtScoreSize); e->type++; e->flags |= VtEntryLocal; vtblockput(b); @@ -671,7 +671,7 @@ mkindices(VtEntry *e, u32int bn, int *index) } return i; } - + VtBlock * vtfileblock(VtFile *r, u32int bn, int mode) { @@ -985,7 +985,7 @@ sizetodepth(uvlong s, int psize, int dsize) { int np; int d; - + /* determine pointer depth */ np = psize/VtScoreSize; s = (s + dsize - 1)/dsize; @@ -1125,7 +1125,7 @@ flushblock(VtCache *c, VtBlock *bb, uchar score[VtScoreSize], int ppb, int epb, vtentrypack(&e, b->data, i); } break; - + default: /* VtPointerTypeX */ for(i=0; idata+VtScoreSize*i, ppb, epb, type-1) < 0) @@ -1233,13 +1233,13 @@ vtfileflushbefore(VtFile *r, u64int offset) }else{ /* * interior node: pointer blocks. - * specifically, b = bi[i] is a block whose index[i-1]'th entry - * points at bi[i-1]. + * specifically, b = bi[i] is a block whose index[i-1]'th entry + * points at bi[i-1]. */ b = bi[i]; /* - * the index entries up to but not including index[i-1] point at + * the index entries up to but not including index[i-1] point at * finished blocks, so flush them for sure. */ for(j=0; jreadq); qunlock(&z->lk); } - diff --git a/src/libventi/log.c b/src/libventi/log.c index 0d67a98b..a6738c7a 100644 --- a/src/libventi/log.c +++ b/src/libventi/log.c @@ -36,7 +36,7 @@ vtlognames(int *pn) int i, nname, size; VtLog *l; char **s, *a, *e; - + qlock(&vl.lk); size = 0; nname = 0; @@ -45,7 +45,7 @@ vtlognames(int *pn) nname++; size += strlen(l->name)+1; } - + s = vtmalloc(nname*sizeof(char*)+size); a = (char*)(s+nname); e = (char*)s+nname*sizeof(char*)+size; @@ -111,12 +111,12 @@ vtlogopen(char *name, uint size) } strcpy(p, name); l->name = p; - + /* insert */ l->next = vl.hash[h]; vl.hash[h] = l; l->ref++; - + l->ref++; qunlock(&vl.lk); return l; @@ -192,10 +192,10 @@ void vtlogprint(VtLog *l, char *fmt, ...) { va_list arg; - + if(l == nil) return; - + va_start(arg, fmt); vtlogvprint(l, fmt, arg); va_end(arg); @@ -224,7 +224,7 @@ vtlogdump(int fd, VtLog *l) if(l == nil) return; - + c = l->w; for(i=0; inchunk; i++){ if(++c == l->chunk+l->nchunk) @@ -232,4 +232,3 @@ vtlogdump(int fd, VtLog *l) write(fd, c->p, c->wp-c->p); } } - diff --git a/src/libventi/mem.c b/src/libventi/mem.c index dea99a9d..2f03de4e 100644 --- a/src/libventi/mem.c +++ b/src/libventi/mem.c @@ -62,7 +62,7 @@ vtbrk(int n) align = IdealAlignment; else if(n > 8) align = 8; - else + else align = 4; lock(&lk); @@ -74,8 +74,8 @@ vtbrk(int n) nchunk++; } - assert(n + pad <= nbuf); - + assert(n + pad <= nbuf); + p = buf + pad; buf += pad + n; nbuf -= pad + n; @@ -83,4 +83,3 @@ vtbrk(int n) return p; } - diff --git a/src/libventi/packet.c b/src/libventi/packet.c index d19d8537..8d162818 100644 --- a/src/libventi/packet.c +++ b/src/libventi/packet.c @@ -35,7 +35,7 @@ enum { FragLocalAlloc, FragGlobal }; - + struct Frag { int state; @@ -55,10 +55,10 @@ struct Packet ulong pc; Packet *next; - + Frag *first; Frag *last; - + Frag local[NLocalFrag]; }; @@ -80,7 +80,7 @@ static void checkpacket(Packet*); #endif /* - * the free list is primarily for speed, but it is + * the free list is primarily for speed, but it is * also necessary for packetsplit that packets * are never freed -- a packet can contain a different * packet's local fragments, thanks to packetsplit! @@ -157,7 +157,7 @@ packetfree(Packet *p) Packet * packetdup(Packet *p, int offset, int n) -{ +{ Frag *f, *ff; Packet *pp; @@ -179,7 +179,7 @@ packetdup(Packet *p, int offset, int n) /* skip offset */ for(f=p->first; offset >= FRAGSIZE(f); f=f->next) offset -= FRAGSIZE(f); - + /* first frag */ ff = fragdup(pp, f); ff->rp += offset; @@ -195,7 +195,7 @@ packetdup(Packet *p, int offset, int n) n -= FRAGSIZE(ff); pp->asize += FRAGASIZE(ff); } - + /* fix up last frag: note n <= 0 */ ff->wp += n; ff->next = nil; @@ -295,7 +295,7 @@ packettrim(Packet *p, int offset, int n) NOTFREE(p); return 0; } - + /* free before offset */ for(f=p->first; offset >= FRAGSIZE(f); f=ff) { p->asize -= FRAGASIZE(f); @@ -341,7 +341,7 @@ packetheader(Packet *p, int n) } p->size += n; - + /* try and fix in current frag */ f = p->first; if(f != nil) { @@ -377,7 +377,7 @@ packettrailer(Packet *p, int n) } p->size += n; - + /* try and fix in current frag */ if(p->first != nil) { f = p->last; @@ -433,7 +433,7 @@ packetprefix(Packet *p, uchar *buf, int n) nn = n; if(nn > MaxFragSize) nn = MaxFragSize; - f = fragalloc(p, nn, PEnd, p->first); + f = fragalloc(p, nn, PEnd, p->first); p->asize += FRAGASIZE(f); if(p->first == nil) p->last = f; @@ -470,7 +470,7 @@ packetappend(Packet *p, uchar *buf, int n) n -= nn; } } - + while(n > 0) { nn = n; if(nn > MaxFragSize) @@ -537,7 +537,7 @@ packetpeek(Packet *p, uchar *buf, int offset, int n) werrstr(EPacketSize); return nil; } - + /* skip up to offset */ for(f=p->first; offset >= FRAGSIZE(f); f=f->next) offset -= FRAGSIZE(f); @@ -586,7 +586,7 @@ packetfragments(Packet *p, IOchunk *io, int nio, int offset) NOTFREE(p); if(p->size == 0 || nio <= 0) return 0; - + if(offset < 0 || offset > p->size) { werrstr(EPacketOffset); return -1; @@ -599,7 +599,7 @@ packetfragments(Packet *p, IOchunk *io, int nio, int offset) eio = io + nio; for(; f != nil && io < eio; f=f->next) { io->addr = f->rp + offset; - io->len = f->wp - (f->rp + offset); + io->len = f->wp - (f->rp + offset); offset = 0; size += io->len; io++; @@ -633,7 +633,7 @@ packetstats(void) nbm = 0; for(m=freelist.bigmem; m; m=m->next) nbm++; - + fprint(2, "packet: %d/%d frag: %d/%d small mem: %d/%d big mem: %d/%d\n", np, freelist.npacket, nf, freelist.nfrag, @@ -651,7 +651,7 @@ packetsize(Packet *p) if(1) { Frag *f; int size = 0; - + for(f=p->first; f; f=f->next) size += FRAGSIZE(f); if(size != p->size) @@ -668,7 +668,7 @@ packetasize(Packet *p) if(0) { Frag *f; int asize = 0; - + for(f=p->first; f; f=f->next) asize += FRAGASIZE(f); if(asize != p->asize) @@ -764,7 +764,7 @@ fragalloc(Packet *p, int n, int pos, Frag *next) goto Found; } } - lock(&freelist.lk); + lock(&freelist.lk); f = freelist.frag; if(f != nil) freelist.frag = f->next; @@ -825,7 +825,7 @@ fragdup(Packet *p, Frag *f) Frag *ff; Mem *m; - m = f->mem; + m = f->mem; /* * m->rp && m->wp can be out of date when ref == 1 @@ -853,7 +853,7 @@ fragdup(Packet *p, Frag *f) unlock(&m->lk); } - + return ff; } @@ -877,7 +877,7 @@ fragfree(Frag *f) lock(&freelist.lk); f->next = freelist.frag; freelist.frag = f; - unlock(&freelist.lk); + unlock(&freelist.lk); } static Mem * @@ -915,7 +915,7 @@ memalloc(int n, int pos) m->bp = vtbrk(nn); m->ep = m->bp + nn; } - assert(m->ref == 0); + assert(m->ref == 0); m->ref = 1; switch(pos) { @@ -930,7 +930,7 @@ memalloc(int n, int pos) break; case PEnd: m->rp = m->ep - n; - break; + break; } /* check we did not blow it */ if(m->rp < m->bp) diff --git a/src/libventi/queue.c b/src/libventi/queue.c index bba63032..b898ea74 100644 --- a/src/libventi/queue.c +++ b/src/libventi/queue.c @@ -44,7 +44,7 @@ void _vtqdecref(Queue *q) { Qel *e; - + qlock(&q->lk); if(--q->ref > 0){ qunlock(&q->lk); diff --git a/src/libventi/rpc.c b/src/libventi/rpc.c index 8f268633..2abe3e42 100644 --- a/src/libventi/rpc.c +++ b/src/libventi/rpc.c @@ -1,9 +1,9 @@ /* - * Multiplexed Venti client. It would be nice if we + * Multiplexed Venti client. It would be nice if we * could turn this into a generic library routine rather * than keep it Venti specific. A user-level 9P client * could use something like this too. - * + * * (Actually it does - this should be replaced with libmux, * which should be renamed librpcmux.) * @@ -125,7 +125,7 @@ vtrpc(VtConn *z, Packet *p) return _vtrpc(z, p, nil); } -static int +static int gettag(VtConn *z, Rwait *r) { int i; @@ -176,4 +176,3 @@ abort(); r->done = 1; rwakeup(&r->r); } - diff --git a/src/libventi/send.c b/src/libventi/send.c index 4dbe115f..96dfe9e6 100644 --- a/src/libventi/send.c +++ b/src/libventi/send.c @@ -126,14 +126,14 @@ _vtrecv(VtConn *z) p = packetsplit(p, len); vtlog(VtServerLog, "%T %s: read packet %p len %d
\n", z->addr, p, len); return p; -Err: +Err: vtlog(VtServerLog, "%T %s: error reading packet: %r
\n", z->addr); - return nil; + return nil; } /* * If you fork off two procs running vtrecvproc and vtsendproc, - * then vtrecv/vtsend (and thus vtrpc) will never block except on + * then vtrecv/vtsend (and thus vtrpc) will never block except on * rendevouses, which is nice when it's running in one thread of many. */ void @@ -258,9 +258,8 @@ vtsend(VtConn *z, Packet *p) if(_vtsend(z, p) < 0){ qunlock(&z->outlk); vthangup(z); - return -1; + return -1; } qunlock(&z->outlk); return 0; } - diff --git a/src/libventi/server.c b/src/libventi/server.c index 91752200..58ce1d8d 100644 --- a/src/libventi/server.c +++ b/src/libventi/server.c @@ -180,7 +180,7 @@ VtReq* vtgetreq(VtSrv *srv) { VtReq *r; - + r = _vtqrecv(srv->q); if (r != nil) vtlog(VtServerLog, "%T %s: vtgetreq %F
\n", ((VtSconn*)r->sc)->c->addr, &r->tx); @@ -215,4 +215,3 @@ vtrespond(VtReq *r) vtfcallclear(&r->rx); vtfree(r); } - diff --git a/src/libventi/strdup.c b/src/libventi/strdup.c index e191c390..36fa6fc7 100644 --- a/src/libventi/strdup.c +++ b/src/libventi/strdup.c @@ -15,4 +15,3 @@ vtstrdup(char *s) memmove(ss, s, n); return ss; } - diff --git a/src/libventi/string.c b/src/libventi/string.c index 9763149a..b273b182 100644 --- a/src/libventi/string.c +++ b/src/libventi/string.c @@ -47,4 +47,3 @@ vtgetstring(Packet *p, char **ps) *ps = s; return 0; } - diff --git a/src/libventi/time.c b/src/libventi/time.c index eb686b32..e105c624 100644 --- a/src/libventi/time.c +++ b/src/libventi/time.c @@ -15,14 +15,13 @@ vttimefmt(Fmt *fmt) ns = nsec(); tm = *localtime(ns/1000000000); if(fmt->flags&FmtLong){ - return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d.%03d", - tm.year+1900, tm.mon+1, tm.mday, + return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d.%03d", + tm.year+1900, tm.mon+1, tm.mday, tm.hour, tm.min, tm.sec, (int)(ns%1000000000)/1000000); }else{ - return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d", - tm.year+1900, tm.mon+1, tm.mday, + return fmtprint(fmt, "%04d/%02d%02d %02d:%02d:%02d", + tm.year+1900, tm.mon+1, tm.mday, tm.hour, tm.min, tm.sec); } } - diff --git a/src/libventi/zero.c b/src/libventi/zero.c index c40aea96..33353c78 100644 --- a/src/libventi/zero.c +++ b/src/libventi/zero.c @@ -23,7 +23,7 @@ vtzeroextend(int type, uchar *buf, uint n, uint nn) } } -uint +uint vtzerotruncate(int type, uchar *buf, uint n) { uchar *p; diff --git a/src/libventi/zeroscore.c b/src/libventi/zeroscore.c index 6f22d72d..b58b13c2 100644 --- a/src/libventi/zeroscore.c +++ b/src/libventi/zeroscore.c @@ -7,4 +7,3 @@ uchar vtzeroscore[VtScoreSize] = { 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09 }; - -- cgit v1.2.3