From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6D6FC41BC0 for ; Fri, 3 Feb 2023 20:14:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E42942D40; Fri, 3 Feb 2023 20:14:18 +0100 (CET) Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by mails.dpdk.org (Postfix) with ESMTP id 71F2C4067B for ; Fri, 3 Feb 2023 20:14:15 +0100 (CET) Received: by mail-pj1-f45.google.com with SMTP id mi9so5961216pjb.4 for ; Fri, 03 Feb 2023 11:14:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oZ73CW2sv1WMVI5SidqFd5zlO8UshcK9PT2qEQBScYQ=; b=eU/HxpMAB4SVoruqG8RINpuhgaS58R89gh4b4p6xTmaoVWEYXfGsyFy0DSa2LoDeyP 4ruyOm3bSApbSg7fOpnzb8o589ybELn+OQw6A4DvpfJWzfw03gE2IXHMDidzBO3JdWT+ 4kWhjFH30pQDKPCDnUkAC34QAmqtO1eU9rdgdNeMr6Ko2umx8DRUanVPA2zRUxVy1j1s 8spDC9g2gk3asyJR3thhPUf0sHOWCpbB8dSc3amsdMDJIeBqrJ3hMwfGFKmD4sIr/N91 Slf2MnluXdeacnmkFziUzmeKAozPcX7wXvdBiks05PjDxI9UUEUjH/LPSiTHSpD6pEya xdCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oZ73CW2sv1WMVI5SidqFd5zlO8UshcK9PT2qEQBScYQ=; b=n7NuqYk3eprqNsr6+6Gkao2SOLxeRf18/eRAhYir3ePiuVJb0OkpEPA7bS+Qdyt9wO zbucKosSrQkUl+KZ8zJ88ZaSxSqAWwJq1RvyQGNspzmYSX9B3IIrZPWHc/Gpr5bg0BT9 I3v6gjjSlzn9CNA/nhWFifL4vlmR2LdX1RK9nLTf1mVClFIHhbF5CULdmv+1hjVSfIKO N56ZC0eCQiBSAFElaG1zVFpNOuWl9CoFXqNaxe5HYCJ3c7h3k6jMKEvsfHmeRqzpl5/j ti3BmdIjxdQJxz/6DDzXbxJpPz7dWmV9Og6kTyRP5YIyMl/0zXut60Y+bka/lnTo2Lbz 8+lg== X-Gm-Message-State: AO0yUKUIrMI3XeEgSV7JZpcdtdsZsW+3ZcCbB9FbhnrO2bKCiKsWUnHN 7LP6NxXR06uH/OTXEXhVY6LNFg== X-Google-Smtp-Source: AK7set+A8j83A5Wz7U/08raGgbns7iPdg0MDB7iA7Bf5XctpLTh0CS8mery/ZZ79awZlgOzflcxprQ== X-Received: by 2002:a05:6a20:e18c:b0:bd:8b67:4e6b with SMTP id ks12-20020a056a20e18c00b000bd8b674e6bmr11566802pzb.19.1675451654691; Fri, 03 Feb 2023 11:14:14 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id l9-20020a056a00140900b00593edee1af6sm2200898pfu.67.2023.02.03.11.14.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 11:14:14 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: stable@dpdk.org, Stephen Hemminger , pawelx.wodkowski@intel.com Subject: [PATCH v11 2/3] cmdline: handle EOF in cmdline_poll Date: Fri, 3 Feb 2023 11:14:08 -0800 Message-Id: <20230203191409.97567-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230203191409.97567-1-stephen@networkplumber.org> References: <20230130200914.22049-1-stephen@networkplumber.org> <20230203191409.97567-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org If end of file is reached on input, then cmdline_poll() will return 1 (ie file has something); and then the cmdline_in() call to read will return 0. With the existing code, caller has no way to tell that end of file has been reached and will retry forever. A good way to handle this is to make end of file equivalent to the quit command. Since no more input is possible at that point. Fixes: 067855e651d6 ("cmdline: add polling mode") Cc: pawelx.wodkowski@intel.com Signed-off-by: Stephen Hemminger --- Note: cmdline_poll() should not have been added back in 2015, looks like there is no users, and no tests for this. lib/cmdline/cmdline.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c index e1009ba4c413..8ad0690d8533 100644 --- a/lib/cmdline/cmdline.c +++ b/lib/cmdline/cmdline.c @@ -197,9 +197,14 @@ cmdline_poll(struct cmdline *cl) if (read_status < 0) return read_status; - status = cmdline_in(cl, &c, 1); - if (status < 0 && cl->rdl.status != RDLINE_EXITED) - return status; + if (read_status == 0) { + /* end of file is implicit quit */ + cmdline_quit(cl); + } else { + status = cmdline_in(cl, &c, 1); + if (status < 0 && cl->rdl.status != RDLINE_EXITED) + return status; + } } return cl->rdl.status; -- 2.39.0