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 phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61F38C433F5 for ; Sun, 30 Jan 2022 20:14:58 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AC1E680FD2; Sun, 30 Jan 2022 21:14:55 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MyV7N2rN"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 306FB811B3; Sun, 30 Jan 2022 21:14:54 +0100 (CET) Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B99DE80D1C for ; Sun, 30 Jan 2022 21:14:51 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-wr1-x434.google.com with SMTP id f17so21529529wrx.1 for ; Sun, 30 Jan 2022 12:14:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=cka3whlDhUTtrQ3UQ/KMMWu3zElKXnCKBqSG8qI81A8=; b=MyV7N2rNdZtHJyOyba+J7jbAul5ej5SaOitE+9RawHycDy5bWGGKLEb6bpfeOyXNDl 4nV9JiUUO3ShAGYEOb2/VW6LX5b2B1w8FmeryG19Hg6oopyj+rsvv90qA9nw34CkUHdz HtXE29ejK35H41omfFw1hmtJtSKmHW258ds1iVHMxnBI8grEnSCZVFixV25J2ha4xHjU E4EsPhtwFgn42Um3zcbba2JS357ZoxggZIO2yrVveziSomvRUbEUkYilgfLXk2oqBzxl I5s4exYtQP4t5iqziFSjPGFGaez9adpot8A5Ro1/j5An1XHCOV5L5x9rKmprXaFQGW5m gL4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=cka3whlDhUTtrQ3UQ/KMMWu3zElKXnCKBqSG8qI81A8=; b=qPEivfVz6ZhYwgeO1fOScnLJjhkgdXIwlNGJt2gMtsq6p5FlTqaGJEObACUz+eFlAS J7tYvD2Lu6mzjmFBTyo+Ma2+ckksekzaGlfm+qwxHfdEbq+kJVDXr92zI/E2vVGmY68t k4kKKIi7sfE9t+HUCYbon0Ceqmb8enq6oM0fggDWo91CGeNfDab/OD+KdwUYoKU66Fpl SAIQefd3YST7orPSSSQ2FkDIbBfpfVl5b8cQxFiCcWxj9eF2oFqhk3wTBmeapAs73YIc usQ0/iglL/3lB4aO4M3vKNBKt+W/QadVSBXG5MLo/s7t+c+5dKIU8PjnaNuJIPlopfun L1Cg== X-Gm-Message-State: AOAM531qmLS4+wLWa4/iTO/e7oIZuQVhJG0B6HUJODayAg8ml1Lk0nAu xRoX3S06MGxpoWfyMWl0NGE= X-Google-Smtp-Source: ABdhPJweBA8ypItLW3puWFNGhgD0pP0lm0i+CYWLCN5P1srdjkxnuNyQsdAc7rMVnOpIZidMHKtsmA== X-Received: by 2002:adf:ed4c:: with SMTP id u12mr14553955wro.110.1643573691247; Sun, 30 Jan 2022 12:14:51 -0800 (PST) Received: from [192.168.0.74] ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id m4sm7207718wmc.1.2022.01.30.12.14.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 30 Jan 2022 12:14:50 -0800 (PST) Message-ID: <829a247a-65aa-af5f-8065-23f7aca3f040@gmail.com> Date: Sun, 30 Jan 2022 23:14:46 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.5.1 Subject: Re: [PATCH] moveconfig: Fix code relying on now-stripped newline characters Content-Language: en-US To: Simon Glass Cc: U-Boot Mailing List , Masahiro Yamada , Trevor Woerner , Heinrich Schuchardt References: <20220129152209.14850-1-alpernebiyasak@gmail.com> From: Alper Nebi Yasak In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean On 30/01/2022 00:09, Simon Glass wrote: > On Sat, 29 Jan 2022 at 08:22, Alper Nebi Yasak wrote: >> Commit 37f815cad07d ("moveconfig: Use a function to read files") adds a >> helper function that can read a file as lines, but strips the newline >> characters. This change broke parts of moveconfig code that relied on >> their existence, resulting in a few issues > > I was a little worried about the subtleties here. Thanks for fixing > it! I almost got annoyed and wrote some tests, but I guess we can limp > on without them. Can't guarantee I found everything, just lucky I was trying a migration on REMAKE_ELF :) >> >> diff --git a/tools/moveconfig.py b/tools/moveconfig.py >> index 35fe6710d70a..1bcf58caf14c 100755 >> --- a/tools/moveconfig.py >> +++ b/tools/moveconfig.py >> @@ -451,7 +451,7 @@ def cleanup_one_extra_option(defconfig_path, configs, args): >> """ >> >> start = 'CONFIG_SYS_EXTRA_OPTIONS="' >> - end = '"\n' >> + end = '"' > > '' Looks to me like the double-quote character is necessary here, if I add CONFIG_SYS_EXTRA_OPTIONS="REMAKE_ELF" to chromebook_bob_defconfig and try migrating CONFIG_REMAKE_ELF the line doesn't get removed otherwise. Trying to add more lines of diff context below: >> >> lines = read_file(defconfig_path) >> for i, line in enumerate(lines): if line.startswith(start) and line.endswith(end): break else: # CONFIG_SYS_EXTRA_OPTIONS was not found in this defconfig return old_tokens = line[len(start):-len(end)].split(',') new_tokens = [] for token in old_tokens: pos = token.find('=') if not (token[:pos] if pos >= 0 else token) in configs: new_tokens.append(token)