Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4223256rwe; Tue, 30 Aug 2022 06:44:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR6p4lR9ucoUVAYM2g3oIPBk2sV1n31Eu8hovkYqkZskCyNQ+PANYCGETdmDB70ri3BnenWb X-Received: by 2002:a17:907:743:b0:740:ef93:2ffc with SMTP id xc3-20020a170907074300b00740ef932ffcmr13189865ejb.514.1661867072697; Tue, 30 Aug 2022 06:44:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661867072; cv=none; d=google.com; s=arc-20160816; b=Gq09jgoT/Fh5oOGYyg2fkyWfGI7vi2XBY6z26IIOxrEYcWUtnoGdLauqV0iUu6Kur4 Tgv+cg/lKRnwmmh+fC8ZLU0QRrO5rx2Cs94nNe3V3DapWutGdUg3k3vtvOCU+RxhQD57 rSdM4dCrFG2Wswq00I/FTcux8WfrvkiY9OycgWim0WAVchEYED+KcD7HVhPglln5ynfW PpvTyKu5b30mzTd4/DJP19SZobD9rByCxIZqvkPGxO/ejwoa4Wxnv5PKafz4g85As2C6 BfBNeyiFsqAlododIgq9YtPA9dtYI3VSbtatizDqfCjYjHvgbCCs5/xPg1UD3sL9600+ gxHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=ZEpDK2FLjm3Ohej8Ml0+ET+4WmXotE5Gv4DWzMq9VV0=; b=ZTKyTwt8CP6QTzB+//zT16BttmjenLn9W+SC6tofXY0iQtuL2zJ5xmvZhpoI7lOUjA pYrdooyBgxzJbd223HB4n/tSTJzcu2USZVegAsqMbCzBBvimFts2UGDQ2Loy/6uBqCEx WKvw0+rvxctdo0681rTJ32Yl3ntJVOXDs2t+yC+0p87q9sEq/qDzV+2McJj0eE8u8Zlv KN/1UkbpBeZfO3FSgP17OT8ETbWOkCqm4O/0Hx9UQML1/FSiFtC/JEf8MBu0HXUcCLkA 4ALAB+1vYxXbq7ay/ufK+43wUogsxQ21P88p2F8rn6RmcbZ1/tGl6XJtLT1yrOf9D/kR 6ZKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=d8YuDrvs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ds9-20020a170907724900b0073dd7598685si10895973ejc.10.2022.08.30.06.44.03; Tue, 30 Aug 2022 06:44:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=d8YuDrvs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230394AbiH3Ngu (ORCPT + 99 others); Tue, 30 Aug 2022 09:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230365AbiH3Ngr (ORCPT ); Tue, 30 Aug 2022 09:36:47 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD194E39B6 for ; Tue, 30 Aug 2022 06:36:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661866599; x=1693402599; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=O9CgTkDBOczWNsw6xgnL7AlVgHCVygWfHTMUKa/QgD8=; b=d8YuDrvsUXU2NT992PGZ3eotpCrktdhojJf8pVMRj+fcwKWLbe0GZZtm jIBdjYv2oBkMDZIFCGt0iwkkk+w3bWFoJQMIJbJcuzWe+hJ2ghHT98L4i OMusSZaWd7GqULYvF89gQeXFn4tQxEDnoT1jX4trc5g8wxt9atYHYqTpw 6F4yJsF+gDuDjh7aPBm2xnpL6W2GHTa+xsIr4QOmKae71qY0PTx6HzO56 QmD6PPInon52r0u7HIqpLW0eLTI54DM2sDmukr+j+/wrnWS/qNSAgIYBx uTnL1+dOqEX7tnhE1iHeTHce9nEtcN5FjQRoHFnYqerJvY/6Uv8pJFc2O w==; X-IronPort-AV: E=McAfee;i="6500,9779,10455"; a="359136439" X-IronPort-AV: E=Sophos;i="5.93,275,1654585200"; d="scan'208";a="359136439" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2022 06:36:38 -0700 X-IronPort-AV: E=Sophos;i="5.93,275,1654585200"; d="scan'208";a="672867819" Received: from amrabet-mobl.ger.corp.intel.com (HELO localhost) ([10.252.41.211]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Aug 2022 06:36:31 -0700 From: Jani Nikula To: Maxime Ripard Cc: Geert Uytterhoeven , Ben Skeggs , David Airlie , Chen-Yu Tsai , Thomas Zimmermann , Lyude Paul , Philipp Zabel , Maarten Lankhorst , Rodrigo Vivi , Tvrtko Ursulin , Jernej Skrabec , Samuel Holland , Karol Herbst , Noralf =?utf-8?Q?Tr=C3=B8nnes?= , Emma Anholt , Daniel Vetter , Joonas Lahtinen , Hans de Goede , Linux ARM , Phil Elwell , Intel Graphics Development , Dave Stevenson , DRI Development , Dom Cobley , Linux Kernel Mailing List , Nouveau Dev , linux-sunxi@lists.linux.dev, Mateusz Kwiatkowski Subject: Re: [PATCH v2 14/41] drm/modes: Move named modes parsing to a separate function In-Reply-To: <20220830120330.6f5f22d35gu7cbr3@houat> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20220728-rpi-analog-tv-properties-v2-0-459522d653a7@cerno.tech> <20220728-rpi-analog-tv-properties-v2-14-459522d653a7@cerno.tech> <87czcidnb8.fsf@intel.com> <20220830120330.6f5f22d35gu7cbr3@houat> Date: Tue, 30 Aug 2022 16:36:23 +0300 Message-ID: <875yi9etuw.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 Tue, 30 Aug 2022, Maxime Ripard wrote: > Hi, > > On Tue, Aug 30, 2022 at 01:43:07PM +0300, Jani Nikula wrote: >> On Tue, 30 Aug 2022, Geert Uytterhoeven wrote: >> > On Mon, Aug 29, 2022 at 3:13 PM Maxime Ripard wrote: >> >> +#define STR_STRICT_EQ(str, len, cmp) \ >> >> + ((strlen(cmp) == len) && !strncmp(str, cmp, len)) >> > >> > This is not part of the move, but newly added. >> >> The same construct is also duplicated elsewhere in the series, and I >> kept being confused by it. > > I'm not sure what is confusing, but I can add a comment if needed. STR_STRICT_EQ() is what's confusing. I have to look at the implementation to understand what it means. What does "strict" string equality mean? > >> The above is precisely the same as: >> >> str_has_prefix(str, cmp) == len > > Here, it's used to make sure we don't have a named mode starting with > either e, d, or D. > > If I understood str_has_prefix() right, str_has_prefix("DUMB-MODE", "D") > == strlen("DUMB-MODE") would return true, while it's actually what we > want to avoid. That's not true, str_has_prefix("DUMB-MODE", "D") == strlen("D") is. > It's also used indeed in drm_get_tv_mode_from_name(), where we try to > match a list of names with one passed as argument. > > With drm_get_tv_mode_from_name("NSTC", strlen("NTSC")), we would end up > calling str_has_prefix("NTSC-J", "NTSC") == strlen("NTSC-J") which would > work. However, we end up calling prefix not a prefix, but an entire > string we want to match against, which is very confusing to me too. If I get this right, you have a string and you want to check if that has a certain prefix. Additionally, you want to check the prefix is a certain length. Sure, that the prefix is a certain length is more of a property of the string, which is NUL terminated later than at length, but that's doesn't really matter. That condition is simply str_has_prefix(string, prefix) == length. BR, Jani. -- Jani Nikula, Intel Open Source Graphics Center