From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16D93C433ED for ; Mon, 10 May 2021 17:59:06 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7236A611AB for ; Mon, 10 May 2021 17:59:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7236A611AB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:45112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgABM-0001t0-6v for qemu-devel@archiver.kernel.org; Mon, 10 May 2021 13:59:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51838) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgAAR-000135-9V for qemu-devel@nongnu.org; Mon, 10 May 2021 13:58:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:26190) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgAAH-0008CK-Vl for qemu-devel@nongnu.org; Mon, 10 May 2021 13:58:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620669476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XicTCUN+OxWOMUgQA6FsdiauVSgR4QXyEvYrd/ilcv4=; b=JXFzouHMqG0ChuR/nr6YRtPircngaySIExyZ5YM3ixjaB7XsO/Jh6AQiHF3wWAm9sFJ/yI 6tcD4HtYTXVU3E8WMB+R9PRdjZZMbfUavdYTrbAcy4ql495lYgnsu4gYJz5IOSPUtrqyAR ogHTHiAEhBw0w6VHEUjLoNJEy2A0pEk= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-562-mskKA2yhOfal1hVpvkESdQ-1; Mon, 10 May 2021 13:57:55 -0400 X-MC-Unique: mskKA2yhOfal1hVpvkESdQ-1 Received: by mail-ej1-f71.google.com with SMTP id p25-20020a1709061419b0290378364a6464so5070056ejc.15 for ; Mon, 10 May 2021 10:57:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=XicTCUN+OxWOMUgQA6FsdiauVSgR4QXyEvYrd/ilcv4=; b=gU7DggJlN7yz/Sni18nvSoG0JJrLhF2I4xsTSRhxxxc3tqb6eqIBAgL4lSJcT/EjIu H3Kntt3vgcdBYjYr59MmSeWysjaiR7jYMMZmBExQxtPr9NZxJO3NctAWXPj3gglXklrs TEIHaUYuikALThxeyHIhqNkTfeI+jo+80zFaDdL5Y1A7twWeBCYVFxbK74RMWTlKGD1/ 4iyG0nGkYaJo0ssj7zTfcDfNyUimzDl6S3MbR6gCAPPepEYJiANQ3Hra+J783F4mW2+r CDzRky7TRQo2VK4YzChuQGIKyk8YurznY/FJfDQhSz1cGfVyA5k4noiFPVKVWdT5AlrP yT+A== X-Gm-Message-State: AOAM532PZXrYK0BLU5gB0Rcb3wh1CMGpi0+iZLY9fXrfZruvqeozENHD xDGRfEKw8+HH0NX4D5OPDFz+4LmMHys5vTW7WXavhzDBYofq4ttcQ5MIGmNlufBU4iBdUut0Xh2 /O8oO4aLnegv+ApjjPpl4Ea9Xtam3Ayb44pNhUguuhCs1YdH2ZoUjpJjKU0oX3FgJDYY= X-Received: by 2002:a50:ba88:: with SMTP id x8mr30506891ede.28.1620669473933; Mon, 10 May 2021 10:57:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK8rXPgFD4+ehtHuhbEBuqfYRgLGOO3+pPyPfpdkNvsbMrnyKoRhwfexQ4xIOBTqR2ka+FqQ== X-Received: by 2002:a50:ba88:: with SMTP id x8mr30506855ede.28.1620669473556; Mon, 10 May 2021 10:57:53 -0700 (PDT) Received: from localhost.localdomain ([2a04:ee41:4:31cb:e591:1e1e:abde:a8f1]) by smtp.gmail.com with ESMTPSA id b9sm11740036edt.2.2021.05.10.10.57.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 May 2021 10:57:53 -0700 (PDT) Subject: Re: [PATCH 4/6] progressmeter: protect with a mutex To: Vladimir Sementsov-Ogievskiy , qemu-block@nongnu.org References: <20210510085941.22769-1-eesposit@redhat.com> <20210510085941.22769-5-eesposit@redhat.com> <946e8544-8183-25b4-6a6a-17eed8c1b009@virtuozzo.com> <3d7d8bf6-a750-045a-0e47-5c496995e1c8@redhat.com> <47ca990e-5bd1-b446-3dd3-2956e9aa9111@virtuozzo.com> From: Emanuele Giuseppe Esposito Message-ID: <887327d9-485e-4a46-7c53-8033ab9d5669@redhat.com> Date: Mon, 10 May 2021 19:57:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <47ca990e-5bd1-b446-3dd3-2956e9aa9111@virtuozzo.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eesposit@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=170.10.133.124; envelope-from=eesposit@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.698, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz , Stefan Hajnoczi , Paolo Bonzini , John Snow Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" >>> >>> We don't have caller that pass only one pointer. So we can just do >>> >>> *current = pm->current; >>> *total = pm->total; >>> >>> implicitly requiring both pointers to be non NULL. >> >> Is it so performance critical that we need to skip these safety checks? >> IMHO we can keep it as it is. > > > Not performance. It's just less code. You propose more complex interface > (pointers may be valid pointers or NULL), implemented by more complex > code (extra if blocks). And there no users for this. So, I don't see any > reason for extra logic and code lines. > > What kind of safety you want? All current callers pass non-zero > pointers, it's obvious. If someone will create new call, he should look > first at function itself, not blindly pass NULL pointers. And if not, he > will get clean crash on zero pointer dereference. Ok, makes sense. Will remove the ifs. Thank you, Emanuele