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 Do not use *bp after freeing it in brelse.



details:   https://anonhg.NetBSD.org/src/rev/5f0af5f544aa
branches:  trunk
changeset: 784426:5f0af5f544aa
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Mon Jan 28 10:16:35 2013 +0000

description:
Do not use *bp after freeing it in brelse.

diffstat:

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

diffs (45 lines):

diff -r 91d671495c70 -r 5f0af5f544aa usr.sbin/makefs/ffs/buf.c
--- a/usr.sbin/makefs/ffs/buf.c Mon Jan 28 09:06:19 2013 +0000
+++ b/usr.sbin/makefs/ffs/buf.c Mon Jan 28 10:16:35 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buf.c,v 1.15 2013/01/27 20:05:46 christos Exp $        */
+/*     $NetBSD: buf.c,v 1.16 2013/01/28 10:16:35 mlelstv 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.15 2013/01/27 20:05:46 christos Exp $");
+__RCSID("$NetBSD: buf.c,v 1.16 2013/01/28 10:16:35 mlelstv Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -136,20 +136,22 @@
 {
        off_t   offset;
        ssize_t rv;
+       int     bytes;
 
        assert (bp != NULL);
        offset = bp->b_blkno * sectorsize;      /* XXX */
+       bytes  = bp->b_bcount;
        if (debug & DEBUG_BUF_BWRITE)
-               printf("bwrite: blkno %lld offset %lld bcount %ld\n",
-                   (long long)bp->b_blkno, (long long) offset, bp->b_bcount);
+               printf("bwrite: blkno %lld offset %lld bcount %d\n",
+                   (long long)bp->b_blkno, (long long) offset, bytes);
        if (lseek(bp->b_fd, offset, SEEK_SET) == -1)
                return (errno);
-       rv = write(bp->b_fd, bp->b_data, bp->b_bcount);
+       rv = write(bp->b_fd, bp->b_data, bytes);
        if (debug & DEBUG_BUF_BWRITE)
                printf("bwrite: write %ld (offset %lld) returned %lld\n",
                    bp->b_bcount, (long long)offset, (long long)rv);
        brelse(bp, 0);
-       if (rv == bp->b_bcount)
+       if (rv == bytes)
                return (0);
        else if (rv == -1)              /* write error */
                return (errno);



Home | Main Index | Thread Index | Old Index