From nobody Wed Mar 22 22:58:45 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PhkRV2gkFz41Ql0; Wed, 22 Mar 2023 22:58:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PhkRV0Qr6z3sfc; Wed, 22 Mar 2023 22:58:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679525926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vL+KoIAnbJ2BnfwpZaxpU3iFxdywjXK1+oCHxUcG6QM=; b=da9J0jr53avBjgTU2GKHVS1LjJuWPY2Kh7iPWSwEZJq5wUtWhwt1Wgq9OwwTsk0d4OiW04 Oz7c3Imx0LPDhnet8tbSu+7xv5/b6iL0Ojo+Bo7nH7kW3FomB87Z9ml7RCxnULGvKr1sUZ YIG9cGVJln3zbBotCNyp5nBTukLBOD7AcKUmS7IirSeS4/LX3pKYAlBJES40pTHEC0O7On /qbhYB297VJFgIhTouqN8dQlvu2fAR5PQdpvxfr5tG3hk/tLmAX/4jkbn1JJoS4SXoUr4U Gk6ufeLZsuxej7loeHZgbvcMCvJiIFl1APqOC6rC4dZpxjP3eRUtfx4A0CkDoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1679525926; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vL+KoIAnbJ2BnfwpZaxpU3iFxdywjXK1+oCHxUcG6QM=; b=yQbHaXTIXzMtBQ5Tma/tpxi6deF7NzasTDP2XCflYeE49AIHCAIEpyQqUX8wL4e55i+nUM Aq5+Z7vwf3RhbZwTEHxCewoMGMzh5Gq8cXBb/p5Pxp3WgIoveVMdgiq36661gpBpCOL6Jz dabUrW3CQZ4qWlXeRTfNnQwUth6TZdiuNBmV8aDcpBBR7zwjDPQawCrBq+uCdazYt/Bfbg 5fh75g7zDCl1FKYuFyy1skeMdi1nZ51iuI7z2Z1nwDz/nPFpS4aGZTuVRVg03/EsRN7vzz oNMdBGdPjrWO2XpeA9ozUGThjksZE5WsqdlXzEzzHAS6SDu6ghKPZ3afK2HWWw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1679525926; a=rsa-sha256; cv=none; b=QOfkIkTLX8xyhSqfoQrDO7FncFTzNrez3eU/TGRcr22bJut7ysur6+9KRGW8aRsflMLKfr KB1s9hvvBY7Ry4sZUQ6BJ1vTNUEKNk3eaSp1WYup/+iJFvodTM11/hmuyduGG+UnTwwkfz qnHbLyN1PJk3Gg48sVX4yD4cEXHcDua14JMaor2mbTslX+xHc8LrIAAsjWPl3/lmS6d5NU Ccf7M8y4CMnyXy2FqXrzbsSXMS5NCgPKxFns9J26S1ecOS0vl2M1TwdfyGI7t9Ne41Dv1O 2HkX7NJlTOJ9+ZeGV5fefiqqKfHHdmyg68Dkv8x1RNOaCcFieaG0s3pKes0eZQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PhkRT6PGCz1C5n; Wed, 22 Mar 2023 22:58:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 32MMwjKu051380; Wed, 22 Mar 2023 22:58:45 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32MMwjjL051379; Wed, 22 Mar 2023 22:58:45 GMT (envelope-from git) Date: Wed, 22 Mar 2023 22:58:45 GMT Message-Id: <202303222258.32MMwjjL051379@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: e5d0d1c5fbbc - main - Rewrite function definitions with identifier lists. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e5d0d1c5fbbc0ce44fdc720a35b499056fe60b06 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=e5d0d1c5fbbc0ce44fdc720a35b499056fe60b06 commit e5d0d1c5fbbc0ce44fdc720a35b499056fe60b06 Author: Kirk McKusick AuthorDate: 2023-03-22 22:57:26 +0000 Commit: Kirk McKusick CommitDate: 2023-03-22 22:58:18 +0000 Rewrite function definitions with identifier lists. A few functions snuck in with K&R style definitions. Also add some missing memory frees. MFC after: 1 week --- sbin/dump/tape.c | 54 +++++++++++++++++++++++++--------------- sbin/fsck_ffs/dir.c | 5 ++++ sbin/fsck_ffs/fsutil.c | 6 ++--- sbin/fsck_ffs/inode.c | 20 +++++---------- sbin/fsck_ffs/pass2.c | 1 + sbin/fsck_ffs/suj.c | 4 +-- tools/diag/prtblknos/main.c | 4 +-- tools/diag/prtblknos/prtblknos.c | 26 +++++-------------- 8 files changed, 57 insertions(+), 63 deletions(-) diff --git a/sbin/dump/tape.c b/sbin/dump/tape.c index 45ad0ee50487..c123f7fa9404 100644 --- a/sbin/dump/tape.c +++ b/sbin/dump/tape.c @@ -74,7 +74,8 @@ static long blocksthisvol; /* number of blocks on current output file */ static char *nexttape; static FILE *popenfp = NULL; -static int atomic(ssize_t (*)(), int, char *, int); +static int atomic_read(int, void *, int); +static int atomic_write(int, const void *, int); static void worker(int, int); static void create_workers(void); static void flushtape(void); @@ -236,7 +237,7 @@ flushtape(void) wp->req[trecno].count = 0; /* Sentinel */ - if (atomic(write, wp->fd, (char *)wp->req, siz) != siz) + if (atomic_write(wp->fd, (const void *)wp->req, siz) != siz) quit("error writing command pipe: %s\n", strerror(errno)); wp->sent = 1; /* we sent a request, read the response later */ @@ -247,7 +248,7 @@ flushtape(void) /* Read results back from next worker */ if (wp->sent) { - if (atomic(read, wp->fd, (char *)&got, sizeof got) + if (atomic_read(wp->fd, (void *)&got, sizeof got) != sizeof got) { perror(" DUMP: error reading command pipe in master"); dumpabort(0); @@ -264,8 +265,8 @@ flushtape(void) */ for (i = 0; i < WORKERS; i++) { if (workers[i].sent) { - if (atomic(read, workers[i].fd, - (char *)&got, sizeof got) + if (atomic_read(workers[i].fd, + (void *)&got, sizeof got) != sizeof got) { perror(" DUMP: error reading command pipe in master"); dumpabort(0); @@ -322,7 +323,7 @@ trewind(void) * fixme: punt for now. */ if (workers[f].sent) { - if (atomic(read, workers[f].fd, (char *)&got, sizeof got) + if (atomic_read(workers[f].fd, (void *)&got, sizeof got) != sizeof got) { perror(" DUMP: error reading command pipe in master"); dumpabort(0); @@ -446,7 +447,7 @@ rollforward(void) lastspclrec = savedtapea - 1; } size = (char *)ntb - (char *)q; - if (atomic(write, wp->fd, (char *)q, size) != size) { + if (atomic_write(wp->fd, (const void *)q, size) != size) { perror(" DUMP: error writing command pipe"); dumpabort(0); } @@ -486,7 +487,7 @@ rollforward(void) * worked ok, otherwise the tape is much too short! */ if (wp->sent) { - if (atomic(read, wp->fd, (char *)&got, sizeof got) + if (atomic_read(wp->fd, (void *)&got, sizeof got) != sizeof got) { perror(" DUMP: error reading command pipe in master"); dumpabort(0); @@ -676,8 +677,7 @@ dumpabort(int signo __unused) } void -Exit(status) - int status; +Exit(int status) { #ifdef TDEBUG @@ -735,8 +735,8 @@ create_workers(void) } for (i = 0; i < WORKERS; i++) - (void) atomic(write, workers[i].fd, - (char *) &workers[(i + 1) % WORKERS].pid, + (void) atomic_write(workers[i].fd, + (const void *) &workers[(i + 1) % WORKERS].pid, sizeof workers[0].pid); master = 0; @@ -777,7 +777,7 @@ worker(int cmd, int worker_number) /* * Need the pid of the next worker in the loop... */ - if ((nread = atomic(read, cmd, (char *)&nextworker, sizeof nextworker)) + if ((nread = atomic_read(cmd, (void *)&nextworker, sizeof nextworker)) != sizeof nextworker) { quit("master/worker protocol botched - didn't get pid of next worker.\n"); } @@ -785,7 +785,7 @@ worker(int cmd, int worker_number) /* * Get list of blocks to dump, read the blocks into tape buffer */ - while ((nread = atomic(read, cmd, (char *)wp->req, reqsiz)) == reqsiz) { + while ((nread = atomic_read(cmd, (void *)wp->req, reqsiz)) == reqsiz) { struct req *p = wp->req; for (trecno = 0; trecno < ntrec; @@ -794,8 +794,8 @@ worker(int cmd, int worker_number) blkread(p->dblk, wp->tblock[trecno], p->count * TP_BSIZE); } else { - if (p->count != 1 || atomic(read, cmd, - (char *)wp->tblock[trecno], + if (p->count != 1 || atomic_read(cmd, + (void *)wp->tblock[trecno], TP_BSIZE) != TP_BSIZE) quit("master/worker protocol botched.\n"); } @@ -858,7 +858,8 @@ worker(int cmd, int worker_number) * pass size of write back to master * (for EOT handling) */ - (void) atomic(write, cmd, (char *)&size, sizeof size); + (void)atomic_write(cmd, (const void *)&size, + sizeof size); } /* @@ -873,15 +874,28 @@ worker(int cmd, int worker_number) /* * Since a read from a pipe may not return all we asked for, - * or a write may not write all we ask if we get a signal, * loop until the count is satisfied (or error). */ static int -atomic(ssize_t (*func)(), int fd, char *buf, int count) +atomic_read(int fd, void *buf, int count) { int got, need = count; - while ((got = (*func)(fd, buf, need)) > 0 && (need -= got) > 0) + while ((got = read(fd, buf, need)) > 0 && (need -= got) > 0) + buf += got; + return (got < 0 ? got : count - need); +} + +/* + * Since a write to a pipe may not write all we ask if we get a signal, + * loop until the count is satisfied (or error). + */ +static int +atomic_write(int fd, const void *buf, int count) +{ + int got, need = count; + + while ((got = write(fd, buf, need)) > 0 && (need -= got) > 0) buf += got; return (got < 0 ? got : count - need); } diff --git a/sbin/fsck_ffs/dir.c b/sbin/fsck_ffs/dir.c index 18229ab96fb6..64e477c66ed8 100644 --- a/sbin/fsck_ffs/dir.c +++ b/sbin/fsck_ffs/dir.c @@ -525,6 +525,7 @@ linkup(ino_t orphan, ino_t parentdir, char *name) } } irelse(&ip); + free(idesc.id_name); if (lfdir == 0) { pfatal("SORRY. CANNOT CREATE lost+found DIRECTORY"); printf("\n\n"); @@ -621,6 +622,7 @@ changeino(ino_t dir, const char *name, ino_t newnum) idesc.id_parent = newnum; /* new value for name */ ginode(dir, &ip); error = ckinode(ip.i_dp, &idesc); + free(idesc.id_name); irelse(&ip); return (error); } @@ -655,15 +657,18 @@ makeentry(ino_t parent, ino_t ino, const char *name) } if ((ckinode(dp, &idesc) & ALTERED) != 0) { irelse(&ip); + free(idesc.id_name); return (1); } getpathname(pathbuf, parent, parent); if (expanddir(&ip, pathbuf) == 0) { irelse(&ip); + free(idesc.id_name); return (0); } retval = ckinode(dp, &idesc) & ALTERED; irelse(&ip); + free(idesc.id_name); return (retval); } diff --git a/sbin/fsck_ffs/fsutil.c b/sbin/fsck_ffs/fsutil.c index ac5dd3ebe08e..d58527231240 100644 --- a/sbin/fsck_ffs/fsutil.c +++ b/sbin/fsck_ffs/fsutil.c @@ -1163,9 +1163,7 @@ allocblk(long startcg, long frags, } ufs2_daddr_t -std_checkblkavail(blkno, frags) - ufs2_daddr_t blkno; - long frags; +std_checkblkavail(ufs2_daddr_t blkno, long frags) { struct bufarea *cgbp; struct cg *cgp; @@ -1279,9 +1277,11 @@ getpathname(char *namebuf, ino_t curdir, ino_t ino) ginode(ino, &ip); if ((ckinode(ip.i_dp, &idesc) & FOUND) == 0) { irelse(&ip); + free(idesc.id_name); break; } irelse(&ip); + free(idesc.id_name); namelookup: idesc.id_number = idesc.id_parent; idesc.id_parent = ino; diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index 057d49a1ea18..947e5e0cbc08 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -798,12 +798,8 @@ snapclean(struct inodesc *idesc) * must always have been allocated from a BLK_NOCOPY location. */ int -snapblkfree(fs, bno, size, inum, checkblkavail) - struct fs *fs; - ufs2_daddr_t bno; - long size; - ino_t inum; - ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags); +snapblkfree(struct fs *fs, ufs2_daddr_t bno, long size, ino_t inum, + ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags)) { union dinode *dp; struct inode ip; @@ -930,10 +926,8 @@ snapblkfree(fs, bno, size, inum, checkblkavail) * block. Here we need to check each block in the buffer. */ void -copyonwrite(fs, bp, checkblkavail) - struct fs *fs; - struct bufarea *bp; - ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags); +copyonwrite(struct fs *fs, struct bufarea *bp, + ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags)) { ufs2_daddr_t copyblkno; long i, numblks; @@ -953,10 +947,8 @@ copyonwrite(fs, bp, checkblkavail) } static void -chkcopyonwrite(fs, copyblkno, checkblkavail) - struct fs *fs; - ufs2_daddr_t copyblkno; - ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags); +chkcopyonwrite(struct fs *fs, ufs2_daddr_t copyblkno, + ufs2_daddr_t (*checkblkavail)(ufs2_daddr_t blkno, long frags)) { struct inode ip; union dinode *dp; diff --git a/sbin/fsck_ffs/pass2.c b/sbin/fsck_ffs/pass2.c index 4e17863ef04c..abe14549e6f4 100644 --- a/sbin/fsck_ffs/pass2.c +++ b/sbin/fsck_ffs/pass2.c @@ -602,6 +602,7 @@ fix_extraneous(struct inoinfo *inp, struct inodesc *idesc) if ((ckinode(ip.i_dp, &dotdesc) & FOUND)) inp->i_dotdot = dotdesc.id_parent; irelse(&ip); + free(dotdesc.id_name); } /* * We have the previously found old name (inp->i_parent) and the diff --git a/sbin/fsck_ffs/suj.c b/sbin/fsck_ffs/suj.c index c85f1f4b81cd..40bbe340bfc6 100644 --- a/sbin/fsck_ffs/suj.c +++ b/sbin/fsck_ffs/suj.c @@ -384,9 +384,7 @@ blk_isindir(ufs2_daddr_t blk, ino_t ino, ufs_lbn_t lbn) * they will only have usable blocks in them. */ ufs2_daddr_t -suj_checkblkavail(blkno, frags) - ufs2_daddr_t blkno; - long frags; +suj_checkblkavail(ufs2_daddr_t blkno, long frags) { struct bufarea *cgbp; struct cg *cgp; diff --git a/tools/diag/prtblknos/main.c b/tools/diag/prtblknos/main.c index 65efa786b700..e5b24ed3117a 100644 --- a/tools/diag/prtblknos/main.c +++ b/tools/diag/prtblknos/main.c @@ -44,9 +44,7 @@ void prtblknos(struct fs *fs, union dinode *dp); struct uufsd disk; int -main(argc, argv) - int argc; - char *argv[]; +main(int argc, char *argv[]) { union dinodep dp; struct fs *fs; diff --git a/tools/diag/prtblknos/prtblknos.c b/tools/diag/prtblknos/prtblknos.c index ae53471156a6..d6135f70eb46 100644 --- a/tools/diag/prtblknos/prtblknos.c +++ b/tools/diag/prtblknos/prtblknos.c @@ -53,9 +53,7 @@ static void indirprt(struct fs *, int, ufs_lbn_t, ufs_lbn_t, ufs2_daddr_t, ufs_lbn_t); void -prtblknos(fs, dp) - struct fs *fs; - union dinode *dp; +prtblknos(struct fs *fs, union dinode *dp) { int i, mode, frags; ufs_lbn_t lbn, lastlbn, len, blksperindir; @@ -154,13 +152,8 @@ prtblknos(fs, dp) } static void -indirprt(fs, level, blksperindir, lbn, blkno, lastlbn) - struct fs *fs; - int level; - ufs_lbn_t blksperindir; - ufs_lbn_t lbn; - ufs2_daddr_t blkno; - ufs_lbn_t lastlbn; +indirprt(struct fs *fs, int level, ufs_lbn_t blksperindir, ufs_lbn_t lbn, + ufs2_daddr_t blkno, ufs_lbn_t lastlbn) { char indir[MAXBSIZE]; ufs_lbn_t i, last; @@ -209,10 +202,7 @@ indirprt(fs, level, blksperindir, lbn, blkno, lastlbn) } static const char * -distance(fs, lastblk, firstblk) - struct fs *fs; - ufs2_daddr_t lastblk; - ufs2_daddr_t firstblk; +distance(struct fs *fs, ufs2_daddr_t lastblk, ufs2_daddr_t firstblk) { ufs2_daddr_t delta; int firstcg, lastcg; @@ -237,12 +227,8 @@ distance(fs, lastblk, firstblk) static const char *indirname[UFS_NIADDR] = { "First", "Second", "Third" }; static void -printblk(fs, lbn, blkno, numfrags, lastlbn) - struct fs *fs; - ufs_lbn_t lbn; - ufs2_daddr_t blkno; - int numfrags; - ufs_lbn_t lastlbn; +printblk(struct fs *fs, ufs_lbn_t lbn, ufs2_daddr_t blkno, int numfrags, + ufs_lbn_t lastlbn) { static int seq; static ufs2_daddr_t totfrags, lastindirblk, lastblk, firstblk;