From: Mattijs Korpershoek <mkorpershoek@baylibre.com>
To: Svyatoslav Ryhel <clamor95@gmail.com>,
Simon Glass <sjg@chromium.org>, Lukasz Majewski <lukma@denx.de>,
Marek Vasut <marex@denx.de>,
Joe Hershberger <joe.hershberger@ni.com>,
Ramon Fried <rfried.dev@gmail.com>, Bin Meng <bmeng@tinylab.org>,
Ion Agorria <ion@agorria.com>,
Svyatoslav Ryhel <clamor95@gmail.com>,
Heinrich Schuchardt <xypron.glpk@gmx.de>,
Harald Seiler <hws@denx.de>,
Sean Anderson <sean.anderson@seco.com>,
Heiko Schocher <hs@denx.de>,
Dmitrii Merkurev <dimorinny@google.com>,
Patrick Delaunay <patrick.delaunay@foss.st.com>,
Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH v2 3/5] common: console: introduce overflow and isempty calls
Date: Tue, 21 Nov 2023 11:27:28 +0100 [thread overview]
Message-ID: <874jhfmmen.fsf@baylibre.com> (raw)
In-Reply-To: <20231115153836.16537-4-clamor95@gmail.com>
Hi Svyatoslav,
Thank you for your patch.
On mer., nov. 15, 2023 at 17:38, Svyatoslav Ryhel <clamor95@gmail.com> wrote:
> From: Ion Agorria <ion@agorria.com>
>
> Separate record overflow logic and add console_record_isempty
> as available calls don't serve to know output has been read
> fully with readline's.
>
> Signed-off-by: Ion Agorria <ion@agorria.com>
> Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
> ---
> common/console.c | 15 ++++++++++++---
> include/console.h | 14 ++++++++++++++
> test/ut.c | 9 ++++-----
> 3 files changed, 30 insertions(+), 8 deletions(-)
>
> diff --git a/common/console.c b/common/console.c
> index 98c3ee6ca6..8a869b137e 100644
> --- a/common/console.c
> +++ b/common/console.c
> @@ -818,6 +818,8 @@ int console_record_init(void)
> ret = membuff_new((struct membuff *)&gd->console_in,
> CONFIG_CONSOLE_RECORD_IN_SIZE);
>
> + gd->flags |= GD_FLG_RECORD;
> +
> return ret;
> }
>
> @@ -836,11 +838,13 @@ int console_record_reset_enable(void)
> return 0;
> }
>
> -int console_record_readline(char *str, int maxlen)
> +bool console_record_overflow(void)
> {
> - if (gd->flags & GD_FLG_RECORD_OVF)
> - return -ENOSPC;
> + return gd->flags & GD_FLG_RECORD_OVF ? true : false;
> +}
>
> +int console_record_readline(char *str, int maxlen)
> +{
> return membuff_readline((struct membuff *)&gd->console_out, str,
> maxlen, '\0');
> }
> @@ -850,6 +854,11 @@ int console_record_avail(void)
> return membuff_avail((struct membuff *)&gd->console_out);
> }
>
> +bool console_record_isempty(void)
> +{
> + return membuff_isempty((struct membuff *)&gd->console_out);
> +}
> +
We should also add a stub for console_record_isempty(), otherwise build
errors will creep in when when CONFIG_CONSOLE_RECORD is not set.
For example, on this series, we can see:
drivers/fastboot/fb_command.c: In function 'fastboot_multiresponse':
drivers/fastboot/fb_command.c:171:29: warning: implicit declaration of function 'console_record_isempty'; did you mean 'console_record_reset'? [-Wimplicit-function-declaration]
171 | if (console_record_isempty()) {
| ^~~~~~~~~~~~~~~~~~~~~~
| console_record_reset
The following diff fixes it:
diff --git a/include/console.h b/include/console.h
index c053bc9ba82c..b5adae740650 100644
--- a/include/console.h
+++ b/include/console.h
@@ -145,6 +145,12 @@ static inline int console_in_puts(const char *str)
return 0;
}
+static inline bool console_record_isempty(void)
+{
+ /* Always empty */
+ return true;
+}
+
With that addressed, please add:
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
> int console_in_puts(const char *str)
> {
> return membuff_put((struct membuff *)&gd->console_in, str, strlen(str));
> diff --git a/include/console.h b/include/console.h
> index ceb733b5cb..c053bc9ba8 100644
> --- a/include/console.h
> +++ b/include/console.h
> @@ -64,6 +64,13 @@ void console_record_reset(void);
> */
> int console_record_reset_enable(void);
>
> +/**
> + * console_record_overflow() - returns state of buffers overflow
> + *
> + * Return: true if the console buffer was overflowed
> + */
> +bool console_record_overflow(void);
> +
> /**
> * console_record_readline() - Read a line from the console output
> *
> @@ -84,6 +91,13 @@ int console_record_readline(char *str, int maxlen);
> */
> int console_record_avail(void);
>
> +/**
> + * console_record_isempty() - Returns if console output is empty
> + *
> + * Return: true if empty
> + */
> +bool console_record_isempty(void);
> +
> /**
> * console_in_puts() - Write a string to the console input buffer
> *
> diff --git a/test/ut.c b/test/ut.c
> index 28da417686..d202644a15 100644
> --- a/test/ut.c
> +++ b/test/ut.c
> @@ -53,15 +53,14 @@ long ut_check_delta(ulong last)
>
> static int readline_check(struct unit_test_state *uts)
> {
> - int ret;
> -
> - ret = console_record_readline(uts->actual_str, sizeof(uts->actual_str));
> - if (ret == -ENOSPC) {
> + if (console_record_overflow()) {
> ut_fail(uts, __FILE__, __LINE__, __func__,
> "Console record buffer too small - increase CONFIG_CONSOLE_RECORD_OUT_SIZE");
> - return ret;
> + return -ENOSPC;
> }
>
> + console_record_readline(uts->actual_str, sizeof(uts->actual_str));
> +
> return 0;
> }
>
> --
> 2.40.1
next prev parent reply other threads:[~2023-11-21 10:27 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 15:38 [PATCH v2 0/5] Implement fastboot multiresponce Svyatoslav Ryhel
2023-11-15 15:38 ` [PATCH v2 1/5] fastboot: multiresponse support Svyatoslav Ryhel
2023-11-21 9:25 ` Mattijs Korpershoek
2023-11-15 15:38 ` [PATCH v2 2/5] fastboot: implement "getvar all" Svyatoslav Ryhel
2023-11-21 13:53 ` Mattijs Korpershoek
2023-11-15 15:38 ` [PATCH v2 3/5] common: console: introduce overflow and isempty calls Svyatoslav Ryhel
2023-11-21 10:27 ` Mattijs Korpershoek [this message]
2023-11-15 15:38 ` [PATCH v2 4/5] lib: membuff: fix readline not returning line in case of overflow Svyatoslav Ryhel
2023-11-21 10:29 ` Mattijs Korpershoek
2023-12-27 17:48 ` Simon Glass
2023-11-15 15:38 ` [PATCH v2 5/5] fastboot: add oem console command support Svyatoslav Ryhel
2023-11-21 10:35 ` Mattijs Korpershoek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874jhfmmen.fsf@baylibre.com \
--to=mkorpershoek@baylibre.com \
--cc=bmeng@tinylab.org \
--cc=clamor95@gmail.com \
--cc=dimorinny@google.com \
--cc=hs@denx.de \
--cc=hws@denx.de \
--cc=ion@agorria.com \
--cc=joe.hershberger@ni.com \
--cc=lukma@denx.de \
--cc=marex@denx.de \
--cc=matthias.schiffer@ew.tq-group.com \
--cc=patrick.delaunay@foss.st.com \
--cc=rfried.dev@gmail.com \
--cc=sean.anderson@seco.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox