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 <step...@networkplumber.org>
---
 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;
-- 
2.39.2

Reply via email to