From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id XwalAtIVBGClegAAWB0awg (envelope-from ) for ; Sun, 17 Jan 2021 05:47:46 -0500 Received: by simark.ca (Postfix, from userid 112) id F04531EF80; Sun, 17 Jan 2021 05:47:45 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 0340D1E940 for ; Sun, 17 Jan 2021 05:47:45 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9460F382D83C; Sun, 17 Jan 2021 10:47:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9460F382D83C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610880464; bh=1yt02vpVIV440Jxy/VGb0W99MEdPDbwKfRoRlcFxeY4=; h=Subject:In-Reply-To:Date:References:To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=w5P10Mbs+v01FARmGI1yE9mTS5IftditDmiRjaDOE5LiYTC/9VuAXYLpuVxrYg+V4 Dkw+OTFKc8TgnRY2lUM/1n8QDXx7fmPMl8dKmsh3qx4A2XA4TYwdgVpSEZHXzpo4NE kesn9iL+akNFdbhL83qXLCZDFE+QPDqiVAH2rBio= Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 455EB386EC55 for ; Sun, 17 Jan 2021 10:47:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 455EB386EC55 Received: by mail-wm1-x330.google.com with SMTP id o10so4383543wmc.1 for ; Sun, 17 Jan 2021 02:47:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=1yt02vpVIV440Jxy/VGb0W99MEdPDbwKfRoRlcFxeY4=; b=toNLmbf7YxuYYZsjQUvued5ips7e1sRLTxpTYCc/i8eZj4SJdAVfVhVKUgPO0S6b+V GxkuML1GiafC0CHL0XrwmPqBnS0mNWVoCRmGCVradTCtnZWcJEprXWrJgoIt3b7MgOOp 1p1YMGwyAovrFXNU4jqyahPa1B+bD61bDivnFoJuxMY4G40+mox2X3XMI1I+KluOIdE7 TY41aWNjRhvf4ZRAj7Lye8EdfkrYCxpocPqR72/tPrzZqf/uLIo2bGKXe9yoHqaaZ+48 zKnXtMH0hX6JH9SodXwofneqFByOyuKqJSf4i1jakLOom/rBB7k0Kisf1YJi7IMlkkAX 7LFw== X-Gm-Message-State: AOAM530GltvQallVlj6kzbt9ydQ30MyA7KrxA4MXEyi3WM9t+Z3mVWKK ng3t39h5urkRfuowruENQa40U5JWmUbe/75L X-Google-Smtp-Source: ABdhPJwhTbii1ObB5GV1aAUZA+oakb/5qy0Z6famyQ3xTC3/BolpkF9vtq/b5fxQr9f7t4YJItUKSw== X-Received: by 2002:a1c:6383:: with SMTP id x125mr16339201wmb.46.1610880460209; Sun, 17 Jan 2021 02:47:40 -0800 (PST) Received: from [192.168.0.103] (cpc159317-cmbg20-2-0-cust151.5-4.cable.virginm.net. [81.111.29.152]) by smtp.gmail.com with ESMTPSA id z21sm19098284wmk.20.2021.01.17.02.47.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jan 2021 02:47:39 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.40.0.2.32\)) Subject: Re: [PATCH 1/4] gdb: add lookup_cmd_exact to simplify a common pattern In-Reply-To: <20210110000432.GA24151@gwenhwyvar> Date: Sun, 17 Jan 2021 10:47:38 +0000 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20210108100706.96190-1-mbarisione@undo.io> <20210108100706.96190-2-mbarisione@undo.io> <20210110000432.GA24151@gwenhwyvar> To: Lancelot SIX X-Mailer: Apple Mail (2.3654.40.0.2.32) X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Marco Barisione via Gdb-patches Reply-To: Marco Barisione Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 10 Jan 2021, at 00:06, Lancelot SIX wrote: >=20 > Hi >=20 > I just have a few style-related remarks above. >=20 > On Fri, Jan 08, 2021 at 10:07:03AM +0000, Marco Barisione via = Gdb-patches wrote: >> +/* See command.h. */ >> + >> +struct cmd_list_element * >> +lookup_cmd_exact (const char *name, >> + struct cmd_list_element *list, >> + bool ignore_help_classes) >> +{ >> + const char *tem =3D name; >> + struct cmd_list_element *cmd =3D lookup_cmd (&tem, list, "", NULL, = -1, >=20 > Probably s/NULL/nullptr/ ? >=20 >> + ignore_help_classes); >> + if (cmd && strcmp (name, cmd->name) !=3D 0) >=20 > I think gdb prefers explicit comparison to check for null pointers: >=20 > = https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#Compari= son_With_NULL_And_Zero >=20 > + if (cmd !=3D nullptr && strcmp (name, cmd->name) !=3D 0) I tried (but I noticed I didn=E2=80=99t succeed!) to use nullptr and = compare with nullptr in new code or code which already looked like that. Otherwise, I tried to stick to the style used in nearby code. That is, if there's code like this: foo *bar =3D NULL; When adding a new variable on the next line, I would use NULL for consistency. What is the approach used in GDB? 1. Add new code using the current style even if inconsistent with nearby code. 2. Stick to the style of nearby code. 3. Also update nearby code. --=20 Marco Barisione