NetBSD Problem Report #51440

From jose@pc2.bigmail.com  Tue Aug 23 19:15:21 2016
Return-Path: <jose@pc2.bigmail.com>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 622F17A217
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 23 Aug 2016 19:15:21 +0000 (UTC)
Message-Id: <20160823191517.97BA723EBFB1@pc2.bigmail.com>
Date: Tue, 23 Aug 2016 21:15:17 +0200 (CEST)
From: joseyluis@gmail.com
Reply-To: joseyluis@gmail.com
To: gnats-bugs@NetBSD.org
Subject: remove unnecessary kludge sbin/fsck_lfs/bufcache.c
X-Send-Pr-Version: 3.95

>Number:         51440
>Category:       bin
>Synopsis:       remove unnecessary kludge sbin/fsck_lfs/bufcache.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 23 19:20:00 +0000 2016
>Closed-Date:    Fri Aug 26 21:19:46 +0000 2016
>Last-Modified:  Fri Aug 26 21:19:46 +0000 2016
>Originator:     Jose Luis Rodriguez Garcia
>Release:        current
>Organization:
>Environment:
System: NetBSD pc2.bigmail.com 7.0.0_PATCH NetBSD 7.0.0_PATCH (GENERIC.201603182340Z) amd64
Architecture: x86_64
Machine: amd64
>Description:
	In bufcche.c the code access to structures inside of the implementation of the tail queues. Furthermore the code is more complex to understand. The same can be done using standard procedures of tailq lists.
>How-To-Repeat:
	Code review
>Fix:
	I have done  a full build, and a test creating a new filesystem with new_fs, The test checks that the new nexpresion and old expresion are always true or false at the same time. 

Index: bufcache.c
===================================================================
RCS file: /cvsroot/src/sbin/fsck_lfs/bufcache.c,v
retrieving revision 1.18
diff -u -r1.18 bufcache.c
--- bufcache.c	18 Aug 2016 08:08:02 -0000	1.18
+++ bufcache.c	23 Aug 2016 18:58:07 -0000
@@ -173,8 +174,6 @@
 	 * We only calculate the head of the freelist when removing
 	 * the last element of the list as that is the only time that
 	 * it is needed (e.g. to reset the tail pointer).
-	 *
-	 * NB: This makes an assumption about how tailq's are implemented.
 	 */
 	if (bp->b_flags & B_LOCKED) {
 		locked_queue_bytes -= bp->b_bcount;
@@ -182,7 +181,7 @@
 	}
 	if (TAILQ_NEXT(bp, b_freelist) == NULL) {
 		for (dp = bufqueues; dp < &bufqueues[BQUEUES]; dp++)
-			if (dp->tqh_last == &bp->b_freelist.tqe_next)
+			if (TAILQ_LAST(dp,bqueues) == bp)
 				break;
 		if (dp == &bufqueues[BQUEUES])
 			errx(1, "bremfree: lost tail");

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/51440 CVS commit: src/sbin/fsck_lfs
Date: Thu, 25 Aug 2016 03:43:18 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Thu Aug 25 07:43:18 UTC 2016

 Modified Files:
 	src/sbin/fsck_lfs: bufcache.c

 Log Message:
 PR/51440: Jose Luis Rodriguez Garcia: Use the standard queue.h macro instead
 of playing with the TAILQ's entrails.


 To generate a diff of this commit:
 cvs rdiff -u -r1.18 -r1.19 src/sbin/fsck_lfs/bufcache.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Fri, 26 Aug 2016 21:19:46 +0000
State-Changed-Why:
committed, thanks :-)


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.