Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp270294pxb; Sat, 10 Apr 2021 02:14:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPmNyMtM69xx4DTJXYMbvRbIt722atUCLx1xWF89LxbQYllLHWbWhEFLmw3Gh9SeOJ3bO5 X-Received: by 2002:a63:5c25:: with SMTP id q37mr16911396pgb.218.1618046085445; Sat, 10 Apr 2021 02:14:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618046085; cv=none; d=google.com; s=arc-20160816; b=0oUJxgGoN4NCsKKIFyvMqP26YYG5sZ5HW2Z7pDdoF8+zwAkrmely5lv75jlgZzRh9f JTrnyNmreuykzhU50utI+iX2kL+Gb9nm4wOYAf9jdo1XeT49fWCKOl9mnr0g6Fm9HEV6 UfX6tg5jFkjzYzhOR1im3NLgkDJqSeoE+VtJAJRmNPjgGXd+3RuDe+jqEd/ctHxIhS5b V7OYxy+G5Y6ywTk3m4Enke/zh5aZut4OcPhHS4PIeFtPfhKhSJlCH8CzflWDl7Hsz3TZ wZQIGy541qrisQ04OKMolPc9fHQ6zsTpK6c9hXfTrihQK6TIyAxogHA3HtC93OwSlUB7 N62Q== 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:dkim-signature:dkim-filter; bh=+hdfayiNVQX2n4soZ0P6JpA8C3ANS1WRtJuZiigUefQ=; b=VcGhuDrY9cXkvZeZK0wmm4uxFhHTLtmnQBoQ0h7jd5SK1alnMzFPnIQwoaVvCcUohh 7Zcrj/l3FuEdtzvx6AMB0Tk3v7V3D/H3RwBeexDZfOdrtZ13sVxP6UjUH4sv7zAnut5m u/rVIYZIt7yYcQ2mLuise7UC8uWtZ0RmnwMa6nNzenmyteZ2QeY15q/lcx6mC1ojZFjd UAvJF23aGF8H/kgg2QS1d+Bv4oOL4+ZuVnn3AcEoYS32Tq0RIqSKH91xipJse+979aBS 86jLnU3nWcF4AsSj0us/R1QKtJhYkS85k8yD5z0WAtHQ8JArfiH/yZWJxM3A5M880VAD wwcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=BS6PRJQQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce15si6595879pjb.15.2021.04.10.02.14.32; Sat, 10 Apr 2021 02:14:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=BS6PRJQQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234609AbhDJJOE (ORCPT + 99 others); Sat, 10 Apr 2021 05:14:04 -0400 Received: from conssluserg-04.nifty.com ([210.131.2.83]:37837 "EHLO conssluserg-04.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234386AbhDJJOA (ORCPT ); Sat, 10 Apr 2021 05:14:00 -0400 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (authenticated) by conssluserg-04.nifty.com with ESMTP id 13A9DWjZ007591 for ; Sat, 10 Apr 2021 18:13:33 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-04.nifty.com 13A9DWjZ007591 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1618046013; bh=+hdfayiNVQX2n4soZ0P6JpA8C3ANS1WRtJuZiigUefQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=BS6PRJQQO1EO/wDXpKcXXkrJNg78sjWcw6g0f0iNl1ewbSz8mwCLW7K5XU/a22G4D ph5YVFBn6WibUblDrLCeWbBSE05EUe9DKv2X5IvN6Owm7CQ0tyDLmPB81ct2fjVCLP 5DTkNRp8gTcAn+ToQ89QbmG0IzoMtYmnDBUsUVKPeJWwIRZL2xP2g/F8dcS+fDDp74 m8STriyiVahLnMSNBTBw+wkjCjLzuwJvgs3N+f5r5xwwYDVcOFpI0z6JpwPEgWMHh/ T/HEwDdDGGOLk9IiU1r5KaGuJNfs6WcKRSgnULbmKhh0S2H1d8WhSdDgl33K85+Mo3 fIkmFb+CbGWmQ== X-Nifty-SrcIP: [209.85.216.51] Received: by mail-pj1-f51.google.com with SMTP id t23so4080035pjy.3 for ; Sat, 10 Apr 2021 02:13:32 -0700 (PDT) X-Gm-Message-State: AOAM5307guSUzo61a9O6f0hXXqCYkd865c7uuvXQiuiTk1/HAs+TnP29 MnwXl+CWhyoLecmo9PfkBViJ+xGYAXGpFOiIP6E= X-Received: by 2002:a17:90a:f68a:: with SMTP id cl10mr17980591pjb.87.1618046012066; Sat, 10 Apr 2021 02:13:32 -0700 (PDT) MIME-Version: 1.0 References: <20210327120155.500-1-ionic@ionic.de> <20210328095227.24323-1-ionic@ionic.de> <9e8d429f-c21c-7d9e-0dcd-8947846fe9ba@ionic.de> In-Reply-To: <9e8d429f-c21c-7d9e-0dcd-8947846fe9ba@ionic.de> From: Masahiro Yamada Date: Sat, 10 Apr 2021 18:12:54 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] kconfig: nconf: stop endless search-up loops To: Mihai Moldovan Cc: Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 10, 2021 at 4:00 PM Mihai Moldovan wrote: > > * On 4/10/21 7:47 AM, Masahiro Yamada wrote: > > On Sun, Mar 28, 2021 at 6:52 PM Mihai Moldovan wrote: > >> + if ((index == -1) && (index == match_start)) > >> + return -1; > > > > We know 'index' is -1 in the second comparison. > > So, you can also write like this: > > > > if (match_start == -1 && index == -1) > > return -1; > > I know, but I sided for the other form for semantic reasons - this more closely > directly describes what we actually care about (both being the same value and > either one being -1). > > > > But, it is not the correct fix, either. > > > > The root cause of the bug is match_start > > becoming -1. > > > > > > The following is the correct way to fix the bug > > without increasing the number of lines. > > > > > > > > diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c > > index e0f965529166..af814b39b876 100644 > > [...] > > + match_start = (match_start + items_num) % items_num; > > index = match_start; > > - index = (index + items_num) % items_num; > > This is probably more elegant and fixes two issues at the same time: match_start > becoming -1 or n (which is likewise invalid, but was implicitly handled through > the remainder operation). > > No objections from my side. Could you send v3 please? Then, I will apply it. -- Best Regards Masahiro Yamada