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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 019FDCCA47B for ; Fri, 8 Jul 2022 20:09:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239933AbiGHUJR (ORCPT ); Fri, 8 Jul 2022 16:09:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239224AbiGHUJR (ORCPT ); Fri, 8 Jul 2022 16:09:17 -0400 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 388965FD5; Fri, 8 Jul 2022 13:09:16 -0700 (PDT) Received: by mail-qt1-f182.google.com with SMTP id z13so28955788qts.12; Fri, 08 Jul 2022 13:09:16 -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=g4cN28gLKvnxOr4BZ0S05ExiGP3ONr1wnsZDOx3J0h4=; b=fy0pERHibIWuVogxks19K+OvPgNDgPuVnVUXP/dGxP4CCAbXiBu8sXBgoTKAHOlUAh /0qWzh6e53YIK+yWTUsuLv5mnAM0P/N5QS9XZSvCSZCaJ3dhMWu1mfdNtajW+s8YE8uH 0ANX8JK3nsJRFU1rxO3X2MnfHAlVE0SiIPRwXnLNxSdpsu0T+n03bEUSs0cdBF2RInE/ MNtBq25AEVgw9YVkQcrDF2H66ZgQBkVkC6pQBrgEOi4NTDLc75gXG5d8xjdEQKun3FF9 7gwW+tVrcDuSmNLKd/sJN9aAG8FY2/GpL68pfQZO5Hn61ebAyxJXdq5D8hIZ1ykY4+GD dVFw== X-Gm-Message-State: AJIora9jIRu1kPfBPKmpgEIPjfPocWjWMnBKNetqpItPeS66nvA5mH1V x+GWFaeqOHTojln3se+PoPAmi3bte6ztBg== X-Google-Smtp-Source: AGRyM1s1qza4+zDp16FWevRs8BRlL8Squ2Gb62GtQsKIVbV9ILmtTCtE9U0HspRiBFoyTRm+Ut8aGQ== X-Received: by 2002:a05:622a:38f:b0:305:1ea5:4a7 with SMTP id j15-20020a05622a038f00b003051ea504a7mr4592763qtx.291.1657310954977; Fri, 08 Jul 2022 13:09:14 -0700 (PDT) Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com. [209.85.128.177]) by smtp.gmail.com with ESMTPSA id s12-20020a05620a29cc00b006a36b0d7f27sm39620509qkp.76.2022.07.08.13.09.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 08 Jul 2022 13:09:14 -0700 (PDT) Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-3137316bb69so207968357b3.10; Fri, 08 Jul 2022 13:09:13 -0700 (PDT) X-Received: by 2002:a0d:dd09:0:b0:31c:e3b9:7442 with SMTP id g9-20020a0ddd09000000b0031ce3b97442mr5915415ywe.47.1657310953183; Fri, 08 Jul 2022 13:09:13 -0700 (PDT) MIME-Version: 1.0 References: <64e2e9b14c26df28908789374253fd12072c26c2.1657301107.git.geert@linux-m68k.org> In-Reply-To: From: Geert Uytterhoeven Date: Fri, 8 Jul 2022 22:09:00 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/5] drm/modes: parse_cmdline: Handle empty mode name part To: Hans de Goede Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , DRI Development , Linux Fbdev development list , "Linux/m68k" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Hi Hans, On Fri, Jul 8, 2022 at 10:06 PM Geert Uytterhoeven wrote: > On Fri, Jul 8, 2022 at 9:28 PM Hans de Goede wrote: > > On 7/8/22 20:21, Geert Uytterhoeven wrote: > > > If no mode name part was specified, mode_end is zero, and the "ret == > > > mode_end" check does the wrong thing. > > > > > > Fix this by checking for a non-zero return value instead. > > > > Which is wrong to do, since now if you have e.g. a mode list > > with: > > > > "dblntsc", > > "dblntsc-ff" > > > > in there and the cmdline contains "dblntsc-ff" then you > > will already stop with a (wrong!) match at "dblntsc". > > It indeed behaves that way, and did so before, as str_has_prefix() > checks for a matching prefix, and thus may never get to the full > match. However, can we change that to an exact match, without > introducing regressions? > This can be avoided by reverse-sorting the modelist (or iterating > backwards through a sorted modelist), though. > > > > While at it, skip all named mode handling when mode_end is zero, as it > > > is futile. > > > > AFAICT, this is actually what needs to be done to fix this, while keeping > > the ret == mode_end check. > > "ret == mode_end" or "ret" doesn't matter (except for the special > case of mode_end is zero), as str_has_prefix() returns either zero or > the length of the prefix. Hence it never returns a non-zero value > smaller than the length of the prefix. Ignore that. I finally saw what's really happening. And I do agree with your comment. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds