Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makefs/ffs In bwrite() if the write() returned -1, ...



details:   https://anonhg.NetBSD.org/src/rev/fef289ed1ffc
branches:  trunk
changeset: 373891:fef289ed1ffc
user:      kre <kre%NetBSD.org@localhost>
date:      Tue Mar 14 10:36:06 2023 +0000

description:
In bwrite() if the write() returned -1, the associated errno was
being used after a (possible) call to printf (only happens when
debugging) and a certain call to free() (via brelse()).
Make a copy, and use that instead.

diffstat:

 usr.sbin/makefs/ffs/buf.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (43 lines):

diff -r 012d4537c5a2 -r fef289ed1ffc usr.sbin/makefs/ffs/buf.c
--- a/usr.sbin/makefs/ffs/buf.c Tue Mar 14 09:54:40 2023 +0000
+++ b/usr.sbin/makefs/ffs/buf.c Tue Mar 14 10:36:06 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buf.c,v 1.27 2023/03/14 09:25:13 kre Exp $     */
+/*     $NetBSD: buf.c,v 1.28 2023/03/14 10:36:06 kre Exp $     */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: buf.c,v 1.27 2023/03/14 09:25:13 kre Exp $");
+__RCSID("$NetBSD: buf.c,v 1.28 2023/03/14 10:36:06 kre Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -149,6 +149,7 @@
        off_t   offset;
        ssize_t rv;
        size_t  bytes;
+       int     e;
        fsinfo_t *fs = bp->b_fs;
 
        assert (bp != NULL);
@@ -160,6 +161,7 @@
        if (lseek(bp->b_fs->fd, offset, SEEK_SET) == -1)
                return errno;
        rv = write(bp->b_fs->fd, bp->b_data, bytes);
+       e = errno;
        if (debug & DEBUG_BUF_BWRITE)
                printf("%s: write %ld (offset %jd) returned %jd\n", __func__,
                    bp->b_bcount, (intmax_t)offset, (intmax_t)rv);
@@ -167,7 +169,7 @@
        if (rv == (ssize_t)bytes)
                return 0;
        if (rv == -1)           /* write error */
-               return errno;
+               return e;
        return EAGAIN;
 }
 



Home | Main Index | Thread Index | Old Index