From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22051 invoked by alias); 11 Dec 2012 06:07:03 -0000 Received: (qmail 22019 invoked by uid 22791); 11 Dec 2012 06:07:00 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Dec 2012 06:06:50 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBB66kuD007715 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 11 Dec 2012 01:06:47 -0500 Received: from host2.jankratochvil.net (ovpn-116-35.ams2.redhat.com [10.36.116.35]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBB66gcA023648 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Tue, 11 Dec 2012 01:06:45 -0500 Date: Tue, 11 Dec 2012 06:07:00 -0000 From: Jan Kratochvil To: Joel Brobecker Cc: gdb-patches@sourceware.org, Matt Rice , Pedro Alves Subject: Re: [doc patch] coding style: 0 vs. NULL + [patch] Code cleanup: skip.c Message-ID: <20121211060641.GA7775@host2.jankratochvil.net> References: <20121210184220.GA29321@host2.jankratochvil.net> <20121211015343.GM31477@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121211015343.GM31477@adacore.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-12/txt/msg00297.txt.bz2 On Tue, 11 Dec 2012 02:53:43 +0100, Joel Brobecker wrote: > > But GDB (IMO fortunately) already uses everywhere properly NULL vs. 0. > [...] > > I have added a new rule for the coding style for it. > > So, just to be certain, this also includes testing for NULL, right? I did not think about this case. > Code like... > > first = strstr (big, small); > if (first) > > ... should be written instead: > > if (first != NULL) I find '(first)' OK myself but IIRC Pedro recently in some mail wrote he likes more an explicit NULL comparison there. Although I cannot find his mail now so I hope I do not put these words in Pedro's mouth. >From my point of view: OK if (first) not great if (!first) OK if (first == NULL) OK if (first != NULL) BAD if (first == 0) BAD if (first != 0) There can be probably just disagreements about the first two cases, whether they should be forbidden or not, I do not mind. Thanks, Jan