From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by sourceware.org (Postfix) with ESMTPS id 283CE3858C83 for ; Tue, 26 Apr 2022 19:05:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 283CE3858C83 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-f42.google.com with SMTP id i5so7709809wrc.13 for ; Tue, 26 Apr 2022 12:05:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=509fWoGA2aDLt4ci5kXqJ0Bmc1RjoKFwR2EDfvACci8=; b=oCNY12TzBpF4ZK5CTMiqQhVmSeY29xRsLaMpBzGhlFsLWmPCPn+j7Gd6K7d30gYe3E HUkJisF+GvTn/QqGHnMCsXyxSxVe75tlE5+/6XwpiKczRAtA9WZcDrg0qqz0NDr8HZ34 H50CCvn0gJHmApCh591UCqMXt8gxn7ZYrVIAxFv241YzxBhsSCVgYMJrZhsuigUw+Oft /7CVujdxGJjzrRC+/8v9YYKgdtpSpV041mbCzokLAuH0K88gNeLCTsg6Ej6cSK4llGdb u8XWSBt7uAh8V6lnN47qGFGzFWR+Ao+gW1e7z6BNZcEswoOxRlx3xyCNJT4ifFYvG4WA Kz8Q== X-Gm-Message-State: AOAM532uJum5nfYA/ahYFkgGA1m0/JnZkfjvbx/vLh1YzNBJR+RPl+A5 ML+GLgCoJoILDWwV0aYckGOlOk1z1vs= X-Google-Smtp-Source: ABdhPJxqdm7sO3NVj9JQCP/cpKTVsWCfW6ZKwRES0EFTVHJXJtw/ipiVt0Wd63qCmm8Ib/sBdaPBUw== X-Received: by 2002:a05:6000:100c:b0:20a:c68a:e9a with SMTP id a12-20020a056000100c00b0020ac68a0e9amr19522289wrx.314.1650999910915; Tue, 26 Apr 2022 12:05:10 -0700 (PDT) Received: from ?IPV6:2001:8a0:f924:2600:209d:85e2:409e:8726? ([2001:8a0:f924:2600:209d:85e2:409e:8726]) by smtp.gmail.com with ESMTPSA id l11-20020a05600c1d0b00b00393fbabdddfsm1828854wms.36.2022.04.26.12.05.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 26 Apr 2022 12:05:08 -0700 (PDT) Message-ID: <746f3cae-3a0e-b0d0-4e86-c9cf282cdf57@palves.net> Date: Tue, 26 Apr 2022 20:05:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH v2 1/1] get page size using sysconf (_SC_PAGESIZE) instead of PAGE_SIZE Content-Language: en-US To: Zied Guermazi , gdb-patches@sourceware.org References: <20220425102333.155142-1-zied.guermazi@trande.de> <20220425102333.155142-2-zied.guermazi@trande.de> From: Pedro Alves In-Reply-To: <20220425102333.155142-2-zied.guermazi@trande.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, 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: Tue, 26 Apr 2022 19:05:13 -0000 On 2022-04-25 11:23, Zied Guermazi wrote: > + if (page_size == -1) > + error (_("Failed to get system page size: %s"), safe_strerror (errno)); This is equivalent to: if (page_size == -1) perror_with_name (_("Failed to get system page size")); > @@ -630,8 +634,12 @@ linux_enable_pt (ptid_t ptid, const struct btrace_config_pt *conf) ... > + long page_size = sysconf (_SC_PAGESIZE); > + if (page_size == -1) > + error (_("Failed to get system page size: %s"), safe_strerror (errno)); Indentation of that "if" seems off here. Also, that pattern appears a number of times in the patch, all in the same file. You could add a static function like so: /* Suitable intro comment. */ static long system_page_size () { long page_size = sysconf (_SC_PAGESIZE); if (page_size == -1) perror_with_name (_("Failed to get system page size: %s")); return page_size; } and then system_page_size throughout without having to worry about checking the return value for error everywhere.