From patchwork Mon Jul 31 16:12:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 129755 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: 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 4067042FA6; Mon, 31 Jul 2023 18:12:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C3CEB40A89; Mon, 31 Jul 2023 18:12:44 +0200 (CEST) Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by mails.dpdk.org (Postfix) with ESMTP id EC1B14067B for ; Mon, 31 Jul 2023 18:12:43 +0200 (CEST) Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1bc02bd4eafso15633125ad.1 for ; Mon, 31 Jul 2023 09:12:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1690819962; x=1691424762; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=hJ+q38iz+OlhGxSuPDr0zc3ZDz5TUTyMQQCV2wTz+iI=; b=wYit8Nk+OGZYiC1V9kUGeInABKqfnJPllIOAjUftmqaHjjZ9/XfleQMyn+wGs45tEY 6JVB2eKjsRVTGRCWKXsWHMH0oYIfMOSBYPKND3ZiKvFDuj3meT281hTg2lMGMlimitSA sbi8wxoKKSZKKXYxZvID8+JWelUT6IzhbaL1dGbo+/xT6icYNwN2QiGXFApsXMcKseuS ak/gxHu1HZeUQF2dO6Arpk8TjcBWdZxbaPxonVwYjrnfPXTX2+q5dqpIibm5zfaHDFpe ghnGpi0Sdr8BSrPKvNy2ibFqx2/HaqSWUe9PjNVCZ7QczQ3vuA2suIYPZSKIO5Vk8JIw eh4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690819962; x=1691424762; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=hJ+q38iz+OlhGxSuPDr0zc3ZDz5TUTyMQQCV2wTz+iI=; b=SSa1WXaQ7ji09gRp3MT7UH8+2ZSxK/TQmgO11iT7ohSRqQtPBDyTwES39ZWtPuD5uY NxcMokWkMOIg/VEoYfK2dvVBgNldyY6LP5NKrs9IC5CRa6raBo4EbfWqNmX+rN3DXc2E iLgCkZo028o1f7zMnUyN9v27fhbhRxkF/mqNBonGyh1rLCbMA2Qiw8Zu0iAzeZ4/UcPA aILG+q5p99zBxQuXHN0OGmP17fI3eKeKodcfvWhuRT9SHbkmcgOkhjOzBv0zD4Z5LzU2 IobzqydxsuRmNo0cQj0biqia3LUYlQPPuUX9j2avI3yh2CawnpIuFc6y70gDT5S4dgei 7uIQ== X-Gm-Message-State: ABy/qLYRMULHxlEqPtYo8DiPTWLDvVOE6Vf7PTd4RrNCavtnTAxRcmwM wwGmKSdOBlQm7p11AWWsWK8D+cCId0GRpIRcwy/is1Lz X-Google-Smtp-Source: APBJJlGbtlQ42eh5+3zw5gGOlmr2P/7FIEp3fBURE1fDBroDRxYRJAJ8AYCdUAfwf/OQD5YuH5IMOQ== X-Received: by 2002:a17:902:d301:b0:1b0:6e16:b92c with SMTP id b1-20020a170902d30100b001b06e16b92cmr9050171plc.54.1690819962374; Mon, 31 Jul 2023 09:12:42 -0700 (PDT) Received: from hermes.local (204-195-127-207.wavecable.com. [204.195.127.207]) by smtp.gmail.com with ESMTPSA id ji20-20020a170903325400b001ac591b0500sm8789965plb.134.2023.07.31.09.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 09:12:41 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Olivier Matz Subject: [PATCH] cmdline: remove cmdline_poll() Date: Mon, 31 Jul 2023 09:12:32 -0700 Message-Id: <20230731161232.180420-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org The API functions cmdline_poll() was unused by any project, untested, and it was buggy. Remove it from 23.11 release. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- doc/guides/rel_notes/release_23_11.rst | 10 +--- lib/cmdline/cmdline.c | 34 ------------- lib/cmdline/cmdline.h | 16 ------ lib/cmdline/cmdline_os_unix.c | 12 ----- lib/cmdline/cmdline_os_windows.c | 68 -------------------------- lib/cmdline/cmdline_private.h | 3 -- lib/cmdline/version.map | 1 - 7 files changed, 1 insertion(+), 143 deletions(-) diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index 6b4dd21fd0e1..d4c123e5503b 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -59,15 +59,7 @@ New Features Removed Items ------------- -.. This section should contain removed items in this release. Sample format: - - * Add a short 1-2 sentence description of the removed item - in the past tense. - - This section is a comment. Do not overwrite or remove it. - Also, make sure to start the actual text at the margin. - ======================================================= - +* cmdline: Removed broken and unused function ``cmdline_poll``. API Changes ----------- diff --git a/lib/cmdline/cmdline.c b/lib/cmdline/cmdline.c index 355c7d8ca635..08721ee919be 100644 --- a/lib/cmdline/cmdline.c +++ b/lib/cmdline/cmdline.c @@ -177,40 +177,6 @@ cmdline_quit(struct cmdline *cl) rdline_quit(&cl->rdl); } -int -cmdline_poll(struct cmdline *cl) -{ - int status; - ssize_t read_status; - char c; - - if (!cl) - return -EINVAL; - else if (cl->rdl.status == RDLINE_EXITED) - return RDLINE_EXITED; - - status = cmdline_poll_char(cl); - if (status < 0) - return status; - else if (status > 0) { - c = -1; - read_status = cmdline_read_char(cl, &c); - if (read_status < 0) - return read_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; -} - void cmdline_interact(struct cmdline *cl) { diff --git a/lib/cmdline/cmdline.h b/lib/cmdline/cmdline.h index d631cd4bd459..992c84591456 100644 --- a/lib/cmdline/cmdline.h +++ b/lib/cmdline/cmdline.h @@ -43,22 +43,6 @@ __rte_experimental struct rdline * cmdline_get_rdline(struct cmdline *cl); -/** - * @deprecated Function is broken and scheduled for removal. - * - * This function is nonblocking equivalent of ``cmdline_interact()``. It polls - * *cl* for one character and interpret it. If return value is *RDLINE_EXITED* - * it mean that ``cmdline_quit()`` was invoked. - * - * @param cl - * The command line object. - * - * @return - * On success return object status - one of *enum rdline_status*. - * On error return negative value. - */ -__rte_deprecated -int cmdline_poll(struct cmdline *cl); void cmdline_interact(struct cmdline *cl); void cmdline_quit(struct cmdline *cl); diff --git a/lib/cmdline/cmdline_os_unix.c b/lib/cmdline/cmdline_os_unix.c index 9a4ec4e33477..0365e73c115e 100644 --- a/lib/cmdline/cmdline_os_unix.c +++ b/lib/cmdline/cmdline_os_unix.c @@ -28,18 +28,6 @@ terminal_restore(const struct cmdline *cl) tcsetattr(fileno(stdin), TCSANOW, &cl->oldterm); } -int -cmdline_poll_char(struct cmdline *cl) -{ - struct pollfd pfd; - - pfd.fd = cl->s_in; - pfd.events = POLLIN; - pfd.revents = 0; - - return poll(&pfd, 1, 0); -} - ssize_t cmdline_read_char(struct cmdline *cl, char *c) { diff --git a/lib/cmdline/cmdline_os_windows.c b/lib/cmdline/cmdline_os_windows.c index 80863bfc8a00..74dc8a18db49 100644 --- a/lib/cmdline/cmdline_os_windows.c +++ b/lib/cmdline/cmdline_os_windows.c @@ -72,74 +72,6 @@ cmdline_is_key_down(const INPUT_RECORD *record) record->Event.KeyEvent.bKeyDown; } -static int -cmdline_poll_char_console(HANDLE handle) -{ - INPUT_RECORD record; - DWORD events; - - if (!PeekConsoleInput(handle, &record, 1, &events)) { - /* Simulate poll(3) behavior on EOF. */ - return (GetLastError() == ERROR_HANDLE_EOF) ? 1 : -1; - } - - if ((events == 0) || !cmdline_is_key_down(&record)) - return 0; - - return 1; -} - -static int -cmdline_poll_char_file(struct cmdline *cl, HANDLE handle) -{ - DWORD type = GetFileType(handle); - - /* Since console is handled by cmdline_poll_char_console(), - * this is either a serial port or input handle had been replaced. - */ - if (type == FILE_TYPE_CHAR) - return cmdline_poll_char_console(handle); - - /* PeekNamedPipe() can handle all pipes and also sockets. */ - if (type == FILE_TYPE_PIPE) { - DWORD bytes_avail; - if (!PeekNamedPipe(handle, NULL, 0, NULL, &bytes_avail, NULL)) - return (GetLastError() == ERROR_BROKEN_PIPE) ? 1 : -1; - return bytes_avail ? 1 : 0; - } - - /* There is no straightforward way to peek a file in Windows - * I/O model. Read the byte, if it is not the end of file, - * buffer it for subsequent read. This will not work with - * a file being appended and probably some other edge cases. - */ - if (type == FILE_TYPE_DISK) { - char c; - int ret; - - ret = _read(cl->s_in, &c, sizeof(c)); - if (ret == 1) { - cl->repeat_count = 1; - cl->repeated_char = c; - } - return ret; - } - - /* GetFileType() failed or file of unknown type, - * which we do not know how to peek anyway. - */ - return -1; -} - -int -cmdline_poll_char(struct cmdline *cl) -{ - HANDLE handle = (HANDLE)_get_osfhandle(cl->s_in); - return cl->oldterm.is_console_input ? - cmdline_poll_char_console(handle) : - cmdline_poll_char_file(cl, handle); -} - ssize_t cmdline_read_char(struct cmdline *cl, char *c) { diff --git a/lib/cmdline/cmdline_private.h b/lib/cmdline/cmdline_private.h index 86a46cdea61a..b64f363903cd 100644 --- a/lib/cmdline/cmdline_private.h +++ b/lib/cmdline/cmdline_private.h @@ -84,9 +84,6 @@ void terminal_adjust(struct cmdline *cl); /* Restore terminal settings form oldterm. */ void terminal_restore(const struct cmdline *cl); -/* Check if a single character can be read from input. */ -int cmdline_poll_char(struct cmdline *cl); - /* Read one character from input. */ ssize_t cmdline_read_char(struct cmdline *cl, char *c); diff --git a/lib/cmdline/version.map b/lib/cmdline/version.map index db4d904ffbdb..97166789016c 100644 --- a/lib/cmdline/version.map +++ b/lib/cmdline/version.map @@ -40,7 +40,6 @@ DPDK_24 { cmdline_parse_num; cmdline_parse_portlist; cmdline_parse_string; - cmdline_poll; cmdline_printf; cmdline_quit; cmdline_set_prompt;