shithub: riscv

Download patch

ref: bada52183c0c61226e82784c307c564533d4fa26
parent: 464817ecf1a2d1486d7c265415e404a3c9298ee5
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Nov 1 07:27:51 EDT 2022

hjfs: check and fix print format errors

--- a/sys/src/cmd/hjfs/cons.c
+++ b/sys/src/cmd/hjfs/cons.c
@@ -142,7 +142,7 @@
 			dprint("bad block %ulld of %ulld in %s %s with directory entry index %d in block %ulld: %r\n", i, blocks, ftype, d->name, l->deind, l->blk);
 		putbuf(c);
 		if(chref(fsmain, r, 0) == 0)
-			dprint("block %ulld of %ulld in %s %s with directory entry index %d in block %ulld has a reference count of 0", i, blocks, ftype, d->name, l->deind, l->blk);
+			dprint("block %ulld of %ulld in %s %s with directory entry index %d in block %ulld has a reference count of 0\n", i, blocks, ftype, d->name, l->deind, l->blk);
 	}
 }
 
@@ -357,7 +357,7 @@
 	if(walkpath(ch, argv[1], nil) < 0)
 		goto error;
 	rlock(fsmain);
-	dprint("loc %ulld / %uld, offset %ulld\n", ch->loc->blk, ch->loc->deind, BLOCK * ch->loc->blk + (RBLOCK - BLOCK) + DENTRYSIZ * ch->loc->deind);
+	dprint("loc %ulld / %d, offset %ulld\n", ch->loc->blk, ch->loc->deind, BLOCK * ch->loc->blk + (RBLOCK - BLOCK) + DENTRYSIZ * ch->loc->deind);
 	b = getbuf(fsmain->d, ch->loc->blk, TDENTRY, 0);
 	if(b == nil){
 		runlock(fsmain);
@@ -366,8 +366,8 @@
 	d = &b->de[ch->loc->deind];
 	dprint("name %s\n", d->name);
 	dprint("uid %d, muid %d, gid %d\n", d->uid, d->muid, d->gid);
-	dprint("mode %#o, qid %ulld, type %#x, version %d\n", d->mode, d->path, d->type, d->vers);
-	dprint("size %d\n", d->size);
+	dprint("mode %#o, qid %ulld, type %#x, version %lud\n", d->mode, d->path, d->type, d->vers);
+	dprint("size %llud\n", d->size);
 	dprint("atime %ulld, mtime %ulld\n", d->atime, d->mtime);
 	putbuf(b);
 	runlock(fsmain);
--- a/sys/src/cmd/hjfs/dev.c
+++ b/sys/src/cmd/hjfs/dev.c
@@ -13,7 +13,7 @@
 	Buf *b;
 	Channel *r;
 	uchar buf[BLOCK];
-	
+
 	d = v;
 	for(;;){
 		qlock(&d->workl);
--- a/sys/src/cmd/hjfs/fns.h
+++ b/sys/src/cmd/hjfs/fns.h
@@ -43,7 +43,8 @@
 int	findentry(Fs *, FLoc *, Buf *, char *, FLoc *, int);
 void	modified(Loc *, Dentry *, short);
 int	trunc(Fs *, FLoc *, Buf *, uvlong);
-int	dprint(char *fmt, ...);
+void	dprint(char *fmt, ...);
+#pragma	varargck argpos dprint 1
 int	delete(Fs *, FLoc *, Buf *);
 int	chref(Fs *, uvlong, int);
 int	newentry(Fs *, Loc *, Buf *, char *, FLoc *, int);
--- a/sys/src/cmd/hjfs/fs1.c
+++ b/sys/src/cmd/hjfs/fs1.c
@@ -654,7 +654,7 @@
 		if(rc < 0)
 			goto end;
 		if(rc == 0){
-			dprint("getblk: block %lld has refcount 0\n");
+			dprint("getblk: block %lld has refcount 0\n", *loc);
 			werrstr("phase error -- getblk");
 			rc = -1;
 			goto end;
--- a/sys/src/cmd/hjfs/main.c
+++ b/sys/src/cmd/hjfs/main.c
@@ -62,21 +62,17 @@
 
 Fs *fsmain;
 
-int
+void
 dprint(char *fmt, ...)
 {
-	static char buf[2048];
-	static QLock lk;
+	char buf[128];
 	va_list va;
-	int rc;
 
-	qlock(&lk);
+	snprint(buf, sizeof(buf), "hjfs: %s", fmt);
+
 	va_start(va, fmt);
-	snprint(buf, 2048, "hjfs: %s", fmt);
-	rc = vfprint(2, buf, va);
+	vfprint(2, buf, va);
 	va_end(va);
-	qunlock(&lk);
-	return rc;
 }
 
 static void