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 X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_NONE,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D0DDC11F64 for ; Thu, 1 Jul 2021 06:19:18 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 08E4061490 for ; Thu, 1 Jul 2021 06:19:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08E4061490 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 968FD83203; Thu, 1 Jul 2021 08:17:12 +0200 (CEST) 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="tV9XACid"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0AFAA83253; Thu, 1 Jul 2021 08:16:52 +0200 (CEST) Received: from mail-qv1-xf2b.google.com (mail-qv1-xf2b.google.com [IPv6:2607:f8b0:4864:20::f2b]) (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 EE29483246 for ; Thu, 1 Jul 2021 08:16:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=seanga2@gmail.com Received: by mail-qv1-xf2b.google.com with SMTP id v17so2409462qvw.12 for ; Wed, 30 Jun 2021 23:16:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yl8F6yq7QDxvWNd6OBtUqPpk3X+bGE9fNd8SyQkV2yY=; b=tV9XACidYrZ+tu4CWUfpa52lbqTvDNkOzIop/brFtJ/8JuVRhBPJAb055zyRH/8cm3 pGzZ06Net1hju/asmWam8Slp9svHXnPE1J7O8WJtS5FrwM9TQWR8SjF96lFFs85lFvgT j+Rdtt4Lfeo5+BxvFP1IRx4at6nIx5ExjBH3s31wHYwaZzp9tr+mQDd6MWpk+D58k4aK BbKzZLd1zjdPYX5Nzs4OJ8GhHr/QvzYpzCJLX5VsSKKU9Iu3b/ai8Vij6wZQlqFqX2+L YY36xx9OcjMchvIwn/PGm3UTzNSf6uCod1od0gmbhh4uEJkmOObruwluXLivGvn+w+TU sDWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yl8F6yq7QDxvWNd6OBtUqPpk3X+bGE9fNd8SyQkV2yY=; b=C4Fv5RRC0iNbhROo6sw/pV3lErxoYaefJe9+Mhs0yX2snXKB6pFRHMTVzxeqt966E6 lVDdEL7UyY0ZeHB5sWuWGgaeaNWhUIdtonRJ5U9YArOL7mOOjs3XkCq77mLz87xaPVP7 h275QpxHLSyl5C62RhtQXoH2f4tCV48WXIQn0p+rdFG4rGTUgJJrMeZJ6JPZ4q1b5HPT ZawIHWFtWOfCl+ZIUm6+M7qdg0N0b3cz7E7WJ5TFChAgSt5Sx3Riiv7VBExp/fxDaC1u qLiCak2phf8bglvS9x1d63ykcqHWAjFeIsLukfZSKiPnN2pJr0ub3UOzLTwDU5oojFfC WzNA== X-Gm-Message-State: AOAM532/q8M57qw/izchlzLFzKH/dsH2shvILSCJiqyUj1+KEJn5zuFk QqGUm4cWGw4sm/Xb6rP+Rs7t9UAVSBg= X-Google-Smtp-Source: ABdhPJw9LLLw0Ku3IXZst8gTH4Db9108RFfp4k/prCCvo0k4pwZT0nbZE4VpzG+FEpjIp9wYEYlPrg== X-Received: by 2002:a0c:e494:: with SMTP id n20mr2040435qvl.58.1625120183631; Wed, 30 Jun 2021 23:16:23 -0700 (PDT) Received: from godwin.fios-router.home (pool-74-96-87-9.washdc.fios.verizon.net. [74.96.87.9]) by smtp.gmail.com with ESMTPSA id g21sm1684673qts.90.2021.06.30.23.16.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Jun 2021 23:16:23 -0700 (PDT) From: Sean Anderson To: u-boot@lists.denx.de, Tom Rini Cc: =?UTF-8?q?Marek=20Beh=C3=BAn?= , Wolfgang Denk , Simon Glass , Roland Gaudig , Heinrich Schuchardt , Kostas Michalopoulos , Sean Anderson Subject: [RFC PATCH 12/28] cli: lil: Check for ctrl-c Date: Thu, 1 Jul 2021 02:15:55 -0400 Message-Id: <20210701061611.957918-13-seanga2@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210701061611.957918-1-seanga2@gmail.com> References: <20210701061611.957918-1-seanga2@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Check for ctrl-c in lil_parse. This works out to around every time a function or command is called. We also check at the beginning of lil_eval_expr so that constructs like while {1} {} get interrupted. Since there are no non-trivial commands in that example, lil_parse never gets to its ctrlc check. However, we do need to evaluate the loop expression, so that's a good place to put a check. Signed-off-by: Sean Anderson --- common/cli_lil.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/cli_lil.c b/common/cli_lil.c index c19a25b2bf..50e314a643 100644 --- a/common/cli_lil.c +++ b/common/cli_lil.c @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -1117,6 +1118,11 @@ struct lil_value *lil_parse(struct lil *lil, const char *code, size_t codelen, lil_free_value(val); val = NULL; + if (ctrlc()) { + lil_set_error(lil, LIL_ERR_INTR, "interrupted"); + goto cleanup; + } + words = substitute(lil); if (!words || lil->err) goto cleanup; @@ -1671,6 +1677,11 @@ struct lil_value *lil_eval_expr(struct lil *lil, struct lil_value *code) { struct expreval ee; + if (ctrlc()) { + lil_set_error(lil, LIL_ERR_INTR, "interrupted"); + return NULL; + } + code = lil_subst_to_value(lil, code); if (lil->err) return NULL; -- 2.32.0