From owner-freebsd-arch@FreeBSD.ORG Wed Jun 1 15:11:55 2005 Return-Path: X-Original-To: freebsd-arch@FreeBSD.org Delivered-To: freebsd-arch@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 857D016A41C for ; Wed, 1 Jun 2005 15:11:55 +0000 (GMT) (envelope-from Hartmut.Brandt@dlr.de) Received: from smtp-1.dlr.de (smtp-1.dlr.de [195.37.61.185]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0E56B43D1D for ; Wed, 1 Jun 2005 15:11:52 +0000 (GMT) (envelope-from Hartmut.Brandt@dlr.de) Received: from beagle.kn.op.dlr.de ([129.247.173.6]) by smtp-1.dlr.de over TLS secured channel with Microsoft SMTPSVC(6.0.3790.211); Wed, 1 Jun 2005 17:11:50 +0200 Date: Wed, 1 Jun 2005 17:11:54 +0200 (CEST) From: Harti Brandt X-X-Sender: brandt_h@beagle.kn.op.dlr.de To: freebsd-arch@FreeBSD.org In-Reply-To: <20050601150344.GA39784@dragon.NUXI.org> Message-ID: <20050601170858.V51549@beagle.kn.op.dlr.de> References: <1117613456.771.16.camel@spirit> <20050601150344.GA39784@dragon.NUXI.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-OriginalArrivalTime: 01 Jun 2005 15:11:50.0714 (UTC) FILETIME=[3CA331A0:01C566BC] Cc: delphij@delphij.net Subject: Re: [PATCH RFC] Add a macro for null mount options to sbin/mount* X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Harti Brandt List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Jun 2005 15:11:55 -0000 On Wed, 1 Jun 2005, David O'Brien wrote: DO>On Wed, Jun 01, 2005 at 04:10:56PM +0800, Xin LI wrote: DO>> Hi, -arch@, DO>> DO>> In our mount* utilities, the null mount option, which is usually be used DO>> as a terminator of an option vector, is defined with some hand-rolled DO>> terms, e.g.: {NULL}, {NULL, 0, 0, 0}, etc. DO>> DO>> I think it would be nice to have a new macro to deal with this, say, DO>> MOPT_NULL, which would be extended to {NULL, 0, 0, 0}, which can act as DO>> an explicit initialize. And in my opinion, something like: DO> DO>I think it is better to leave it alone. The "NULL" termination of a list DO>like this is a C idiom that should be clear to any C programmer. Hiding DO>the details in a macro (is MOPT_NULL an integer or a sentinel?) makes it DO>harder to see the idiom and know exactly what is going on and how this DO>list will be processed. The problem is that with the right set of warning options gcc will warn if you write {NULL}, but there are more fields than just a pointer. If the structure definition is stable enough this is no problem - just go through all the programs and fix it once. If the definition is likely to change from time to time, a macro is better because it just does the right thing. harti