From owner-freebsd-current Wed Feb 27 15: 1:49 2002 Delivered-To: freebsd-current@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id 901AA37B402 for ; Wed, 27 Feb 2002 15:01:43 -0800 (PST) Received: from [128.113.24.47] (gilead.acs.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.12.1/8.12.1) with ESMTP id g1RN1fll124100; Wed, 27 Feb 2002 18:01:42 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: References: Date: Wed, 27 Feb 2002 18:01:40 -0500 To: Julian Elischer , FreeBSD current users From: Garance A Drosihn Subject: Re: controversial fix or some errors breaking LINT Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: MIMEDefang 2.3 (www dot roaringpenguin dot com slash mimedefang) Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG At 1:27 PM -0800 2/27/02, Julian Elischer wrote: >There are saveral places (e.g. if_ie.c) where data >is copied out of a buffer that is shared with the hardware. > >The pointer to this is correctly labelled as "volatile", though >at the time we will copy the data out we know it to be stable. Note: "at the time we will copy the data ... we know" >A while ago I proposed the following patch: > >/* > * Note: the "volatile" below does not REQUIRE that the argument be > * volatile, but rather ony says that it is OK to use a volatile * i > * there. Same for the const. I know a const volatile sounds strange > * but it only indicates that either is acceptable. > */ >void bcopy __P((volatile const void *from, volatile void *to, > size_t len)); This will always allow bcopy to do the copy to or from any volatile location, even if the call is done at a bad time. Any programmer calling bcopy should at least get a little flag waved at them if they are working with volatile arguments. How philosophically sickening would it be to create a macro: #define bcopy_volatile(x,y) bcopy((casts)x,(casts)y) so that you can have cleaner-looking source code, but still have it so the programmer has to *explicitly* say "Yes, I know I am dealing with volatile memory here". -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message