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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6D1FBECAAD4 for ; Tue, 30 Aug 2022 13:37:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=itK09qmOrT2mZJ9rH7QUTWe7WsqxL55J0PkDk4cu5SQ=; b=t0NjmipcdCCLyz +Db7rHjT5nTxXXEoi2QL2o8dy7+kKs2RdHFA1JyaZlu+eAsLkWKR+K2nf1mDnA5kLB3oZTkvUTvRk eNrrg6TYmTjv3q8f5PuHL69rjuLaf77eYKFxBdAU97y3vY+kxbO0qP4JIWGBv5Etkic7WalJsRj+K 6HVRk7+6djaWmnODvD1GvCvch7hi71vvW7lSZLWf+1arbTJWZnf1drhXzWZvXdg94lAiuT504rNP2 Tz+Img0nDWBaqalkZPzxk1ioPcIHPavsZ8QjnvDh3fh19joflUkmHgSezfMBL7jBolrd9bW7qyaKJ ro1XV2FJ2XiI4faItiqg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oT1Q5-00HOTF-2n; Tue, 30 Aug 2022 13:36:45 +0000 Received: from mga07.intel.com ([134.134.136.100]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oT1Q0-00HOSX-Fk for linux-arm-kernel@lists.infradead.org; Tue, 30 Aug 2022 13:36:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1661866600; x=1693402600; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=O9CgTkDBOczWNsw6xgnL7AlVgHCVygWfHTMUKa/QgD8=; b=kR+wgfpCsCvo1wNMLn+s9Gkr1R70HkuXvC8wlm78uw6a4X4KgQQ6O1Bh n5nqCVyhcQuUsGbGD5QetIwRDO9nb8ZSUw4wtIo5N9ru9oovnXOtWS4DB /qaR8KPjtx2yI+hnuMBNftRhcPj3AgL5IVTl26JuW73BzPphqKWwxSizi Ng9LzWxal3cTWOxXIdMYwrOfSY1lV8aRk5j8WjJ4Gw0ctKqWxoPa8bJdw PCmIIy7xQn7RLUZz47s8yOMCc9+xtaAsYF1KIg5BnKU7+4N14jOMpUa80 uA4HPlr1Mj9vfGrhUsSDmho6HN4QMiBMNlp6jwxQuNmjngST5WND2hCau w==; X-IronPort-AV: E=McAfee;i="6500,9779,10455"; a="359136444" X-IronPort-AV: E=Sophos;i="5.93,275,1654585200"; d="scan'208";a="359136444" 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220830_063640_624555_BA980AD8 X-CRM114-Status: GOOD ( 23.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel