Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp802182pxb; Tue, 12 Apr 2022 13:52:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhDr5KLrmqDPQ+121rNVVM5VKHsM2eR72Mrqqou5DdXeqjK0utE/5xHGQPvxoUFsrKSwA4 X-Received: by 2002:a05:6a00:1145:b0:4f6:3ebc:a79b with SMTP id b5-20020a056a00114500b004f63ebca79bmr39473724pfm.41.1649796779407; Tue, 12 Apr 2022 13:52:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649796779; cv=none; d=google.com; s=arc-20160816; b=glYG5BEij29yfotj0Oac+LodS3h3LhTdPhg+bSRrIhWRvKtI15OFTvstcE4X3ejp1Z Q/zfX+aONwtX/9H7/Zgc+j7B2+yseDwxSRpwO/gJLSj/47zyRc0DlrwIxqOU0b9RJuVW O9tmHjRqaEnQxSGjrJM0I2PFjJ4yTqClrmrzXIU+0cqXUZyREdiAAv8TsNm6/brWuck3 84yiwInFeNAaDQBEPGd8KtD4W4+77BdujpquPWDr7Etew2AsIyhYeLPH284g1mrSyxmq wtmY8wbvnCcvDv/12gwub3m1crs6YmeB+9aH5HW8TJ6tXpg+lzF+gsrJDuwD3v7RV/Ra +f0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=UdFqlnyS6znWMBHrBHznevziGrO6hgWnoxAL9D9H1BY=; b=b88pDy35LiLxoHsfGRfun++FUZWGjlFwnvnqN2mHMbKx0QVcgljwnWrPCY7/da9fFH winvKxqDBY4JjPWJ49yrGNJeroQ+0NPvcXejWjV2A0Wv2UxZB9xPVRiCJdOxvyufijyw zq4E33UBA1acbEuWzQsSUbWGipgjrFWg/aLnNmJZNqrgAsVg8PO+e5FbGQe3L4a03uuw tF1BYw2wrisSzut3rJxFRJ5jAJw5d6LduT0ulb/Cs2POBdY77nJCPnBTaAnK7f62oaUX 3pMgbZV8cX+7fmtS4nSEusnbJEVETJ94FQog4Jgg/R/ijWVjcg2h0FjIGchE97PbHzLk Hgwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id z13-20020a17090a1fcd00b001cb56b40005si11964941pjz.185.2022.04.12.13.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 13:52:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9FF3319028; Tue, 12 Apr 2022 13:19:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344187AbiDKSJx (ORCPT + 99 others); Mon, 11 Apr 2022 14:09:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232992AbiDKSJw (ORCPT ); Mon, 11 Apr 2022 14:09:52 -0400 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 881CB26FF; Mon, 11 Apr 2022 11:07:37 -0700 (PDT) Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-2ec05db3dfbso54020767b3.7; Mon, 11 Apr 2022 11:07:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=UdFqlnyS6znWMBHrBHznevziGrO6hgWnoxAL9D9H1BY=; b=ZfxQtfuv/EMHqa1vjDU0OkLWr52lNFYIngBIdGjeUfyQyUqxor0NcS8m1JjkNUJRaG YsQsm9AgHGycVehWaBHS6p/eCrJOs/HrrUvjhCFKkUNbKnneu9p/2ilmhdhUtYtTklpH BItFJxGqKVwzY7yPrG4PyLPG78DwFS2DeoNJkp0oAmQCdzHciF510aDvv+BDq9Fr6wbH QShiTZ1Uc73uTs6V/C68TK4dsVNZuQTLrtVio3MzV09WOAGZ/QED14wsO5SCq4efwFsO LDnyyFI/5WVcka7q+rqBWXAPTy8WiVQo+7cg3repaG6+5dV9feb50vx0sqzHMemnoVk9 MnPQ== X-Gm-Message-State: AOAM533RFOFm1hOGUimTs1/8bbDeMHohzoIhwt0sbUxaLXCrqoxUWp3Z AA71hanQwx1VZQmPxR4fN9h164OMoM5S3m1ClPM= X-Received: by 2002:a81:b89:0:b0:2eb:e9e6:470a with SMTP id 131-20020a810b89000000b002ebe9e6470amr13058043ywl.7.1649700456794; Mon, 11 Apr 2022 11:07:36 -0700 (PDT) MIME-Version: 1.0 References: <1836398.tdWV9SEqCh@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 11 Apr 2022 20:07:25 +0200 Message-ID: Subject: Re: [PATCH v1] PM: runtime: Avoid device usage count underflows To: Andy Shevchenko Cc: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Linux PM , LKML , Ulf Hansson , Alan Stern Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 11, 2022 at 6:53 PM Andy Shevchenko wrote: > > On Mon, Apr 11, 2022 at 6:17 PM Rafael J. Wysocki wrote: > > On Mon, Apr 11, 2022 at 5:09 PM Andy Shevchenko > > wrote: > > > On Wed, Apr 6, 2022 at 11:49 PM Rafael J. Wysocki wrote: > > ... > > > > > + retval = rpm_drop_usage_count(dev); > > > > + if (retval > 0) { > > > > trace_rpm_usage_rcuidle(dev, rpmflags); > > > > return 0; > > > > + } else if (retval < 0) { > > > > + return retval; > > > > } > > > > > > Can be written in a form > > > > > > if (retval < 0) > > > return retval; > > > if (retval > 0) { > > > trace_rpm_usage_rcuidle(dev, rpmflags); > > > return 0; > > > } > > > > > > > I know. > > > > And why would it be better? > > Depends on the perception: Well, exactly. > a) less characters to parse (no 'else'); But to me, with the "else" it is clear that the conditionals are related to each other which is not so clear otherwise at first sight. YMMV > b) checking for errors first, which seems more or less standard pattern. So the checks can be reversed no problem, but this is such a minor point ,,,