From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by sourceware.org (Postfix) with ESMTPS id 7A3C73858402 for ; Fri, 24 Sep 2021 11:13:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7A3C73858402 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=palves.net Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f50.google.com with SMTP id t8so26453514wri.1 for ; Fri, 24 Sep 2021 04:13:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=0mPC4U4HeUYKtGCPXWCYnof54Rco4OVkj/ADKHWSXb8=; b=liwosH5TaIL9fPV74AaVz17kWYbOY83joMVigJ5GqszAJBIGGjwwpzNyESJ5RavSJE T68ZjP/Zlj521nFcjFQyvPPyo08+iFYoOOGDz+C2ZdjP6EwYii4pn5XniRnWzEnqS2Te yPzlmYeX7R5teNsF6SKNDoxLWeTG4QZ3msk7AvPa2DOQq9rxzBdhxgF8p+imSovfBeeg xd3v0nNjQcyBtP+xEx5lju8QBRyVnYSH1zZfMsMJiStVNeHpYiq+LBm/G2PqCGjaB4+o jQdRrD/dOHGvE4CciEyYwC/wNA9Nsq8uAo673QMDQGBg58ll+r8fw2X8hQ4n6CZaGy5b 2phQ== X-Gm-Message-State: AOAM530cpqQY7wiKILlSy6oTWO75qLXoFYAdJpOAR57Cji5Lr5lIxm+U SzpPpQL4a++GNSdq1XIPp+fIjSoC8dvo6g== X-Google-Smtp-Source: ABdhPJyq2c6gb74lbca2kWNscUciFt2obJWA0Pq/A62TiCARLpXcsAjnWDlZPiMMNpgZ7l/aUw1xag== X-Received: by 2002:a05:600c:2109:: with SMTP id u9mr1471176wml.6.1632481983763; Fri, 24 Sep 2021 04:13:03 -0700 (PDT) Received: from [192.168.0.201] (bl22-100-144.dsl.telepac.pt. [2.83.100.144]) by smtp.gmail.com with ESMTPSA id c9sm6190898wmb.41.2021.09.24.04.13.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Sep 2021 04:13:02 -0700 (PDT) Subject: Re: [PATCH] Move value_true to value.h From: Pedro Alves To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20210911181206.2818419-1-tom@tromey.com> <9a9f2f75-ef9d-72dd-47ea-71f96ca60d3d@palves.net> <871r5fnh07.fsf@tromey.com> Message-ID: <66b04dd9-c7eb-47d7-bb41-d01b96a5079c@palves.net> Date: Fri, 24 Sep 2021 12:13:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <871r5fnh07.fsf@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 24 Sep 2021 11:13:06 -0000 On 2021-09-23 10:01 p.m., Tom Tromey wrote: > commit 12fb19e547b8352fb2fdaafc9e0895eb34804d0d > Author: Tom Tromey > Date: Thu Aug 26 18:17:40 2021 -0600 > > Move value_true to value.h > > I noticed that value_true is declared in language.h and defined in > language.c. However, as part of the value API, I think it would be > better in one of those files. And, because it is very short, I > changed it to be an inline function in value.h. I've also removed a > comment from the implementation, on the basis that it seems obsolete > -- if the change it suggests was needed, it probably would have been > done by now; and if it is needed in the future, odds are it would be > done differently anyway. > > Finally, this patch also changes value_true and value_logical_not to > return a bool, and updates some uses. Still OK. Though I noticed a couple comments that could use tweaking. > diff --git a/gdb/valarith.c b/gdb/valarith.c > index 9ebad648b27..8acd83545f7 100644 > --- a/gdb/valarith.c > +++ b/gdb/valarith.c > @@ -1655,7 +1655,7 @@ value_binop (struct value *arg1, struct value *arg2, enum exp_opcode op) > > /* Simulate the C operator ! -- return 1 if ARG1 contains zero. */ "Return true". Consider moving to .h file. > > -int > +bool > value_logical_not (struct value *arg1) > { > int len; > diff --git a/gdb/value.h b/gdb/value.h > index e1c6aabfa29..c5847290564 100644 > --- a/gdb/value.h > +++ b/gdb/value.h > @@ -1022,7 +1022,14 @@ extern int value_equal_contents (struct value *arg1, struct value *arg2); > > extern int value_less (struct value *arg1, struct value *arg2); > > -extern int value_logical_not (struct value *arg1); > +extern bool value_logical_not (struct value *arg1); > + > +/* Returns non-zero if the value VAL represents a true value. */ "Returns true". > +static inline bool > +value_true (struct value *val) > +{ > + return !value_logical_not (val); > +} > > /* C++ */ > >