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 0D76D42F94; Wed, 2 Aug 2023 01:48:46 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 911C6410DC; Wed, 2 Aug 2023 01:48:45 +0200 (CEST) Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by mails.dpdk.org (Postfix) with ESMTP id 5FE4040DDB for ; Wed, 2 Aug 2023 01:48:44 +0200 (CEST) Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-5646f8ac115so705797a12.2 for ; Tue, 01 Aug 2023 16:48:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1690933723; x=1691538523; 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=GbGdsDIQzsGnCPK4icY7CTZbGrhy95GFvM6noMnyQ94=; b=WgoavowIFc6OIBJa5J4Goi3tN/8DzPImUuvb2CGulkTopRPErgpv+qXMyPBss/SZ0N HQk0cwKUAnmojwpbYECeWC2X4FQorvsc82KB50j5OdCgJSj45+1ucwbdB+qJ5F9kuXKH V4l5LsOx40yj3N8LCkZf7bmmIbQS6GWjFeXJishjIyFRbsCoYxAllQes90b69pY21hxG biaE1Ge/1qt+kve9DStwhfdqXeIWNswP7AGT5oy0u9QfRTf4uSYIDZ78IZovZfmOomIl iy0UDowaxHKB7iIPt+PY0MwXSB8GOr5nlCkjOpHDn03zlYAilRpokI0reKsUT45ABzOb ZJBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690933723; x=1691538523; 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=GbGdsDIQzsGnCPK4icY7CTZbGrhy95GFvM6noMnyQ94=; b=KO8fLNCz0hgKFPZHdwGHTAjK9PmVR4sA9ZbmSJueP5F04lAhBtWXopGTY7HxaCe+/e f3xrVtzVXjbExNLk6ZrhEIJdH1yooIsy/myw0vcO2pOpbW5QCbGFaLWiVgwrEiwDmZaB Hzdtihw5RvzrIxheitz5iHeD6NZJeCYNiyP4+X5i3eehEUvPXB/rrPA1WasPXM2XpR0b 1jhfA8/jrnajt+3tVyPpUKVdVPiMtM7B9MoNh+MXzJ3dNZeP0UKoeKuYNhUiLkMlvKUW RygjwS6vYLduXfzDC/1NwD1C/ZJbPwY4fBRUAebwQ/+MBlqcHPcjGyWPOeuH1THaoJTk TtxA== X-Gm-Message-State: ABy/qLZAc3rkRJ/4xswumRaYq/RUdNRsgQlGQEQRRizoW2M+WgTGZbgA 3Z3ksGmT8LhipMTPP5A2VcV2MhPdSY++tR70XnX6xQ== X-Google-Smtp-Source: APBJJlHjrndWJcjzKIV5wEgZp5qeF44LhDRNjj8smA6zn9I6Hqi4kJojIvcGN528ItKW3bYV05ecyQ== X-Received: by 2002:a17:90a:6c45:b0:262:ece1:5fd0 with SMTP id x63-20020a17090a6c4500b00262ece15fd0mr12442612pjj.12.1690933722970; Tue, 01 Aug 2023 16:48:42 -0700 (PDT) Received: from hermes.local (204-195-127-207.wavecable.com. [204.195.127.207]) by smtp.gmail.com with ESMTPSA id o4-20020a17090aac0400b0026833291740sm59508pjq.46.2023.08.01.16.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Aug 2023 16:48:42 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Bruce Richardson , Olivier Matz Subject: [PATCH v2] cmdline: remove cmdline_poll() Date: Tue, 1 Aug 2023 16:48:32 -0700 Message-Id: <20230801234832.120349-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230731161232.180420-1-stephen@networkplumber.org> References: <20230731161232.180420-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 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 buggy. Remove it from 23.11 release. Signed-off-by: Stephen Hemminger Acked-by: Bruce Richardson --- doc/guides/rel_notes/release_23_11.rst | 1 + 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(+), 134 deletions(-) diff --git a/doc/guides/rel_notes/release_23_11.rst b/doc/guides/rel_notes/release_23_11.rst index 6b4dd21fd0e1..0e206219a83e 100644 --- a/doc/guides/rel_notes/release_23_11.rst +++ b/doc/guides/rel_notes/release_23_11.rst @@ -68,6 +68,7 @@ Removed Items 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; -- 2.39.2