Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp2265569pxm; Fri, 4 Mar 2022 12:40:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJy5pFW7lVZEUTinozuyQXzqvlHG0RK1pbuydPzN61mjaQpZs2tZd5BqY7IKKMxnRnW2PgUU X-Received: by 2002:a63:950a:0:b0:375:64a3:f98c with SMTP id p10-20020a63950a000000b0037564a3f98cmr184503pgd.22.1646426428019; Fri, 04 Mar 2022 12:40:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646426428; cv=none; d=google.com; s=arc-20160816; b=NjDM+Z9+VdasJhguOgHONe7KpW4/0EUqAYNENiEDhXNGBoZh2iKv/0GzhVUhmO0vMF re9953jiJxcgS+nUfEbrQV3vrTfW4OgM3R1GYuYLgCN5pDZgiqWcHTZX87o7N7NcJFJC 0H0BEb6bnhpeTmJ6ZaT22GlN5jz9z4STDEV5lmgJ5GIvcgebpfcWgbYzAwHfgAzp0XOF KtyGC2hNMzt12FAGpzm9RQeJfVCJ0DAUL1zvpRMTqDWtOAaaXSJ6RFurrUeOqVwjPqPg ziMm7OIjVAq/sL42ByppgN3zp2u4wMmXGEqe+M/0nAjJjFlYxEJd+pk1iLhzFtPRVX5s kpdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=oDe1meAUtWuTlnXqNzelqa2lLmtZj8HzFUyEZySR1BA=; b=ebeVD0YxzvlamPh1r82M9Id22aMSDN3rL5oC3aEo4ormYjKxRqVFEYPqQJvcjNb8v9 zgtUdaWBf+4VB5wAcPXnco2ly9Pd6f4jRt7yMpC4IjhHde0UFnEBu92a2cmXBM0brMza 4B/UIX5kCdnkZ0mMt3WokrY+q47nqHN24PklJdyLH1SX8YzujnXLNGclLTKTK5Aybl8G 2Pf71GF1WGbq/ddnF5iaGAdYkmMFgXRPaARAYj6wEyhmRDoh672qyCasJdOq0iVSG2HX /w7X4BYINgrt98crF1THivC4Ay1buGy+fuwkJ6I4TlR5o2oQpheIPA8i7eBgOXQle4W8 3X7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TpyPI486; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n2-20020a17090aab8200b001bf2a2b918bsi423996pjq.51.2022.03.04.12.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Mar 2022 12:40:28 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TpyPI486; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D63772388C0; Fri, 4 Mar 2022 11:40:10 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238428AbiCDNyP (ORCPT + 99 others); Fri, 4 Mar 2022 08:54:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230098AbiCDNyN (ORCPT ); Fri, 4 Mar 2022 08:54:13 -0500 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16884532E5; Fri, 4 Mar 2022 05:53:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646402006; x=1677938006; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=EBV+8A/WSH+HEZn2WXFADUJhrDTrMNNGavJydqTbqEE=; b=TpyPI486IwuLTlbBIKbByPctIkCTcqCopfetMFCemqeHECpunCMyY3h4 KkOYqRzkM71RIs73pv5+iG0+KxderaHJsVtZTNFrpED3Wg4h25/vIJeob 8rFm8/M0TTWls1s98+p/98Ghb5hQjucAroOFCXjc19Go0LNo1dR6WPuTk GzxTzS++P0frb/I62QGZ4gDaogRjo9QvYd84k+XqUI2DPqXDAi1Cq3t9s aNKcb+U2KStjMxUu9X2CdxJA1zb/xt8rjrABNU+3AqYbLbPGIbDaGKwGc 3GNlStBW/5pRxvCFVLtBH39aKxZeRCLZWXTEXm70Ok3rbxhSoktbDCkZH A==; X-IronPort-AV: E=McAfee;i="6200,9189,10275"; a="254170019" X-IronPort-AV: E=Sophos;i="5.90,155,1643702400"; d="scan'208";a="254170019" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 05:53:25 -0800 X-IronPort-AV: E=Sophos;i="5.90,155,1643702400"; d="scan'208";a="642513908" Received: from smile.fi.intel.com ([10.237.72.59]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Mar 2022 05:53:22 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nQ8MG-00BF56-8O; Fri, 04 Mar 2022 15:52:36 +0200 Date: Fri, 4 Mar 2022 15:52:35 +0200 From: Andy Shevchenko To: Sakari Ailus Cc: Bjorn Andersson , Rob Herring , Daniel Scally , Heikki Krogerus , "Rafael J. Wysocki" , Hans de Goede , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Dmitry Baryshkov Subject: Re: [PATCH v3 1/6] device property: Helper to match multiple connections Message-ID: References: <20220303223351.141238-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, 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 Fri, Mar 04, 2022 at 03:41:33PM +0200, Sakari Ailus wrote: > On Fri, Mar 04, 2022 at 02:54:21PM +0200, Andy Shevchenko wrote: > > On Thu, Mar 03, 2022 at 02:33:46PM -0800, Bjorn Andersson wrote: ... > > > + if (count >= matches_len && matches) { > > > + fwnode_handle_put(ep); > > > + return count; > > > + } > > > > Wouldn't be the same as > > > > if (count >= matches_len) { > > fwnode_handle_put(ep); > > break; > > } > > Don't you need to check for non-NULL matches here? Right, this should be kept as in original patch. > I find return above easier to read. Okay, original code may work, so I have no strong opinion about return vs break, although I find slightly better to have a single point of return in such case. > > ? ... > > > + count_graph = fwnode_graph_devcon_matches(fwnode, con_id, data, match, > > > + matches, matches_len); > > > > > + matches += count_graph; > > > + matches_len -= count_graph; > > > > No, won't work when matches == NULL. > > > > Also, matches_len is expected to be 0 in that case (or at least being ignored, > > check with vsnprintf() behaviour in similar case). > > > > So, something like this, perhaps > > > > if (matches && matches_len) { > > matches += count_graph; > > matches_len -= count_graph; > > } > > Good find! I have checked vsnprintf() and indeed, it expects to have the size is 0 when the resulting buffer pointer is NULL, and it doesn't do any additional checks. > > > + count_ref = fwnode_devcon_matches(fwnode, con_id, data, match, > > > + matches, matches_len); -- With Best Regards, Andy Shevchenko