Message ID | 20230130200914.22049-2-stephen@networkplumber.org (mailing list archive) |
---|---|
State | Superseded, archived |
Delegated to: | Ferruh Yigit |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 43B2941B83; Mon, 30 Jan 2023 21:09:25 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C273740EE5; Mon, 30 Jan 2023 21:09:21 +0100 (CET) Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by mails.dpdk.org (Postfix) with ESMTP id AFEF040DF6 for <dev@dpdk.org>; Mon, 30 Jan 2023 21:09:19 +0100 (CET) Received: by mail-pl1-f174.google.com with SMTP id b5so5602218plz.5 for <dev@dpdk.org>; Mon, 30 Jan 2023 12:09:19 -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=F0TvJ8nJ0Fd60VAC5BMfbvVD61R5TzEkC3vXEl183Do=; b=8DTEy2SM4DtmV1KsbZ1Nyo5P+WVBCq9uXyBbkmA0R1EIfLBKCIDhqVztccdO+UCaq+ qi13RqvrI6riPAv5tBP3Lw3JyWPVLqMwNgOUEbD4pqjQXx3oN/NgxYL01EPgBBIV60Pc 76IGIxPRnIKE0H+giPmUa+pWW53Isd6ZfDSQoZ8908/QvOS36PO5FHMTE4D+kpjKtYoe fsj08Wpx5ICvghseriaFwU1rtXkSoVhaXYX6hiSI2AiNfZe6OjY8N4L+P0Ndd4q40aAO mEsHtcmdW87GZejPupsQy4QiM3WY39DujNsal14qaO8ctwy7T0BcURMRg4/Kjad+2T0v S8jw== 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=F0TvJ8nJ0Fd60VAC5BMfbvVD61R5TzEkC3vXEl183Do=; b=Ch3coMt84X66HC/AbRwuJ+wXhNV7cJjLN/OBWxLw4IeE/7We2A/KbJgOIRS33HFA9T rztnHf2GaZyb/KnHRn4DwN+6x+689muCj4/4E1BI5MZGgZnwC3X9YCXYfClVzJ8BnoQi 3NTVu5S/qL6WBYYGzSYvpQF6lMFGF8rJRdYUrvG9uXLUl6vftESdwLfoxIOTha7naOQ4 OSqmzmZVB3RKtpv2fr6OtgbCT2NOLSnzD1QPJ1p96rOEqpE02farCv9+zLwQEiTdd2gp dqo/9UmgdDON4GB1FoIJxIVGd+v6butf9v0KquPh7oS609s+0MK8nQQky1oaM/INskYf ABjA== X-Gm-Message-State: AO0yUKXMj4IlGr2K4bjkXIRll3ES8HvRGI1DHRhY5Wrajuxnd7a5OIUd VVgJPZPYuKnVx+7FY3+OOBfugMNZxTTF7WTtfbw= X-Google-Smtp-Source: AK7set89nDXmYus7EN64e7ChvIF8kF5TfiIM77vmZKOPfbVc37fAwBaaH8n/0b2GCyfsHeO2h1Y3Aw== X-Received: by 2002:a05:6a20:6993:b0:bc:13bd:89c8 with SMTP id t19-20020a056a20699300b000bc13bd89c8mr20234245pzk.42.1675109358628; Mon, 30 Jan 2023 12:09:18 -0800 (PST) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id p19-20020a637413000000b004774b5dc24dsm7024329pgc.12.2023.01.30.12.09.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 12:09:18 -0800 (PST) From: Stephen Hemminger <stephen@networkplumber.org> To: dev@dpdk.org Cc: Stephen Hemminger <stephen@networkplumber.org> Subject: [PATCH v10 1/2] cmdline: handle EOF in cmdline_poll Date: Mon, 30 Jan 2023 12:09:13 -0800 Message-Id: <20230130200914.22049-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230130200914.22049-1-stephen@networkplumber.org> References: <20221014172328.185219-1-stephen@networkplumber.org> <20230130200914.22049-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions <dev.dpdk.org> List-Unsubscribe: <https://mails.dpdk.org/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://mails.dpdk.org/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <https://mails.dpdk.org/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org |
Series |
testpmd: handle signals safely
|
|
Checks
Context | Check | Description |
---|---|---|
ci/checkpatch | success | coding style OK |
Commit Message
Stephen Hemminger
Jan. 30, 2023, 8:09 p.m. UTC
If end of file is reached on input, then cmdline_read_char()
will return 0. The problem is that cmdline_poll() was not checking
for this and would continue and not return the status.
Fixes: 9251cd97a6be ("cmdline: add internal wrappers for character input")
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/cmdline/cmdline.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 1/30/2023 8:09 PM, Stephen Hemminger wrote: > If end of file is reached on input, then cmdline_read_char() > will return 0. The problem is that cmdline_poll() was not checking > for this and would continue and not return the status. > > Fixes: 9251cd97a6be ("cmdline: add internal wrappers for character input") > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> > --- > lib/cmdline/cmdline.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c > index e1009ba4c413..de41406d61e0 100644 > --- a/lib/cmdline/cmdline.c > +++ b/lib/cmdline/cmdline.c > @@ -194,7 +194,7 @@ cmdline_poll(struct cmdline *cl) > else if (status > 0) { > c = -1; > read_status = cmdline_read_char(cl, &c); > - if (read_status < 0) > + if (read_status <= 0) > return read_status; According API doc it will be wrong to return '0', which imply 'RDLINE_INIT'. But function may return any negative value on error, what about to get eof as and error case: if (read_status < 0) return read_status; else if (read_status == 0) return -EIO; With this 'cmdline_poll()' can be used in testpmd as it is used in v9 of this patch: while (f_quit == 0 && cl_quit == 0) { if (cmdline_poll(cl) < 0) break; } But still I guess this is an ABI break because of API behavior change.
On Mon, 30 Jan 2023 22:12:42 +0000 Ferruh Yigit <ferruh.yigit@amd.com> wrote: > On 1/30/2023 8:09 PM, Stephen Hemminger wrote: > > If end of file is reached on input, then cmdline_read_char() > > will return 0. The problem is that cmdline_poll() was not checking > > for this and would continue and not return the status. > > > > Fixes: 9251cd97a6be ("cmdline: add internal wrappers for character input") > > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org> > > --- > > lib/cmdline/cmdline.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c > > index e1009ba4c413..de41406d61e0 100644 > > --- a/lib/cmdline/cmdline.c > > +++ b/lib/cmdline/cmdline.c > > @@ -194,7 +194,7 @@ cmdline_poll(struct cmdline *cl) > > else if (status > 0) { > > c = -1; > > read_status = cmdline_read_char(cl, &c); > > - if (read_status < 0) > > + if (read_status <= 0) > > return read_status; > > According API doc it will be wrong to return '0', which imply 'RDLINE_INIT'. The API doc is a mess. It says function returns things enum that is only defined in cmdline_private.h. Therefore no application could safely depend on it. End of File is not an error in most API's.
diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c index e1009ba4c413..de41406d61e0 100644 --- a/lib/cmdline/cmdline.c +++ b/lib/cmdline/cmdline.c @@ -194,7 +194,7 @@ cmdline_poll(struct cmdline *cl) else if (status > 0) { c = -1; read_status = cmdline_read_char(cl, &c); - if (read_status < 0) + if (read_status <= 0) return read_status; status = cmdline_in(cl, &c, 1);