NetBSD Problem Report #52112
From www@NetBSD.org Mon Mar 27 16:03:58 2017
Return-Path: <www@NetBSD.org>
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 4F63A7A279
for <gnats-bugs@gnats.NetBSD.org>; Mon, 27 Mar 2017 16:03:58 +0000 (UTC)
Message-Id: <20170327160357.2ABEF7A2B6@mollari.NetBSD.org>
Date: Mon, 27 Mar 2017 16:03:57 +0000 (UTC)
From: dcb314@hotmail.com
Reply-To: dcb314@hotmail.com
To: gnats-bugs@NetBSD.org
Subject: arch/xen/xenbus/xenbus_dev.c:400: pointless assignment in critical section
X-Send-Pr-Version: www-1.0
>Number: 52112
>Category: port-xen
>Synopsis: arch/xen/xenbus/xenbus_dev.c:400: pointless assignment in critical section
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: port-xen-maintainer
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Mar 27 16:05:00 +0000 2017
>Closed-Date: Mon Mar 27 18:40:49 +0000 2017
>Last-Modified: Mon Mar 27 18:40:49 +0000 2017
>Originator: David Binderman
>Release: cvs-20170327
>Organization:
>Environment:
>Description:
src/sys/arch/xen/xenbus/xenbus_dev.c:395] -> [src/sys/arch/xen/xenbus/xenbus_dev.c:400]: (style) Variable 'u' is reassigned a value before the old one has been used.
Source code is
struct xenbus_dev_data *u = kfs->kfs_v;
struct xenbus_dev_lwp *xlwp;
struct xenbus_dev_transaction *trans;
mutex_enter(&xenbus_dev_open_mtx);
u = kfs->kfs_v;
Second assignment looks pointless. Suggest remove.
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
From: Manuel Bouyer <bouyer@antioche.eu.org>
To: gnats-bugs@NetBSD.org
Cc: port-xen-maintainer@netbsd.org, gnats-admin@netbsd.org,
netbsd-bugs@netbsd.org
Subject: Re: port-xen/52112: arch/xen/xenbus/xenbus_dev.c:400: pointless
assignment in critical section
Date: Mon, 27 Mar 2017 18:13:26 +0200
On Mon, Mar 27, 2017 at 04:05:00PM +0000, dcb314@hotmail.com wrote:
> src/sys/arch/xen/xenbus/xenbus_dev.c:395] -> [src/sys/arch/xen/xenbus/xenbus_dev.c:400]: (style) Variable 'u' is reassigned a value before the old one has been used.
>
> Source code is
>
> struct xenbus_dev_data *u = kfs->kfs_v;
> struct xenbus_dev_lwp *xlwp;
> struct xenbus_dev_transaction *trans;
>
> mutex_enter(&xenbus_dev_open_mtx);
> u = kfs->kfs_v;
>
> Second assignment looks pointless. Suggest remove.
Actually it's the first one that should be removed. The xenbus_dev_open_mtx
mutex protects kfs. Maybe kfs assignement should be moved under the
mutex too.
Will look and fix later today
--
Manuel Bouyer <bouyer@antioche.eu.org>
NetBSD: 26 ans d'experience feront toujours la difference
--
From: "Manuel Bouyer" <bouyer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/52112 CVS commit: src/sys/arch/xen/xenbus
Date: Mon, 27 Mar 2017 18:39:55 +0000
Module Name: src
Committed By: bouyer
Date: Mon Mar 27 18:39:55 UTC 2017
Modified Files:
src/sys/arch/xen/xenbus: xenbus_dev.c
Log Message:
Avoid variable reassignement; reported by dcb314@hotmail.com in
PR port-xen/52112
To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/xen/xenbus/xenbus_dev.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: bouyer@NetBSD.org
State-Changed-When: Mon, 27 Mar 2017 18:40:49 +0000
State-Changed-Why:
Fix commited
>Unformatted:
(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.