mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] common: fastboot: send FAIL if variable does not exist
@ 2025-06-11 17:56 Andrei Lalaev
  2025-06-12  8:08 ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Andrei Lalaev @ 2025-06-11 17:56 UTC (permalink / raw)
  To: s.hauer; +Cc: andrey.lalaev, barebox

According to doc [1], new implementations should send FAIL if the
variable specified in the getvar command does not exist.

[1]: https://android.googlesource.com/platform/system/core/+show/refs/heads/main/fastboot/README.md#121

Signed-off-by: Andrei Lalaev <andrey.lalaev@gmail.com>
---
 common/fastboot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/fastboot.c b/common/fastboot.c
index 56bc4e82c4..3df3c227a3 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -372,7 +372,7 @@ static void cb_getvar(struct fastboot *fb, const char *cmd)
 		goto out;
 
 skip_partitions:
-	fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
+	fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "");
 out:
 	fastboot_free_variables(&partition_list);
 }
-- 
2.49.0




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] common: fastboot: send FAIL if variable does not exist
  2025-06-11 17:56 [PATCH] common: fastboot: send FAIL if variable does not exist Andrei Lalaev
@ 2025-06-12  8:08 ` Sascha Hauer
  2025-06-12 14:19   ` Andrei Lalaev
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2025-06-12  8:08 UTC (permalink / raw)
  To: Andrei Lalaev; +Cc: barebox

Hi Andrei,

On Wed, Jun 11, 2025 at 07:56:45PM +0200, Andrei Lalaev wrote:
> According to doc [1], new implementations should send FAIL if the
> variable specified in the getvar command does not exist.
> 
> [1]: https://android.googlesource.com/platform/system/core/+show/refs/heads/main/fastboot/README.md#121
> 
> Signed-off-by: Andrei Lalaev <andrey.lalaev@gmail.com>
> ---
>  common/fastboot.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/fastboot.c b/common/fastboot.c
> index 56bc4e82c4..3df3c227a3 100644
> --- a/common/fastboot.c
> +++ b/common/fastboot.c
> @@ -372,7 +372,7 @@ static void cb_getvar(struct fastboot *fb, const char *cmd)
>  		goto out;
>  
>  skip_partitions:
> -	fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
> +	fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "");

With this a "fastboot getvar all" fails.

I fixed this up as below.

Sascha

----------------------8<-------------------------------

>From dd377c937f8bd14842e8e1c119bd3323f85570f8 Mon Sep 17 00:00:00 2001
From: Andrei Lalaev <andrey.lalaev@gmail.com>
Date: Wed, 11 Jun 2025 19:56:45 +0200
Subject: [PATCH] common: fastboot: send FAIL if variable does not exist

According to doc [1], new implementations should send FAIL if the
variable specified in the getvar command does not exist.

[1]: https://android.googlesource.com/platform/system/core/+show/refs/heads/main/fastboot/README.md#121

Signed-off-by: Andrei Lalaev <andrey.lalaev@gmail.com>
Link: https://lore.barebox.org/20250611175645.144025-1-andrey.lalaev@gmail.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/fastboot.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/common/fastboot.c b/common/fastboot.c
index 7227149dfb..f678fe8ccb 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -348,8 +348,10 @@ static void cb_getvar(struct fastboot *fb, const char *cmd)
 	if (fastboot_tx_print_var(fb, &fb->variables, cmd))
 		goto out;
 
-	if (!all && !partition)
-		goto skip_partitions;
+	if (!all && !partition) {
+		fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "no such variable: %s", cmd);
+		goto out;
+	}
 
 	file_list_for_each_entry(fb->files, fentry) {
 		int ret;
@@ -371,8 +373,11 @@ static void cb_getvar(struct fastboot *fb, const char *cmd)
 	if (fastboot_tx_print_var(fb, &partition_list, cmd))
 		goto out;
 
-skip_partitions:
-	fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
+	if (all)
+		fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
+	else
+		fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "no such variable: %s", cmd);
+
 out:
 	fastboot_free_variables(&partition_list);
 }
-- 
2.39.5


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] common: fastboot: send FAIL if variable does not exist
  2025-06-12  8:08 ` Sascha Hauer
@ 2025-06-12 14:19   ` Andrei Lalaev
  0 siblings, 0 replies; 3+ messages in thread
From: Andrei Lalaev @ 2025-06-12 14:19 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 12.06.2025 10:08, Sascha Hauer wrote:
> Hi Andrei,
> 
> On Wed, Jun 11, 2025 at 07:56:45PM +0200, Andrei Lalaev wrote:
>> According to doc [1], new implementations should send FAIL if the
>> variable specified in the getvar command does not exist.
>>
>> [1]: https://android.googlesource.com/platform/system/core/+show/refs/heads/main/fastboot/README.md#121
>>
>> Signed-off-by: Andrei Lalaev <andrey.lalaev@gmail.com>
>> ---
>>  common/fastboot.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/common/fastboot.c b/common/fastboot.c
>> index 56bc4e82c4..3df3c227a3 100644
>> --- a/common/fastboot.c
>> +++ b/common/fastboot.c
>> @@ -372,7 +372,7 @@ static void cb_getvar(struct fastboot *fb, const char *cmd)
>>  		goto out;
>>  
>>  skip_partitions:
>> -	fastboot_tx_print(fb, FASTBOOT_MSG_OKAY, "");
>> +	fastboot_tx_print(fb, FASTBOOT_MSG_FAIL, "");
> 
> With this a "fastboot getvar all" fails.
> 
> I fixed this up as below.
> 
> Sascha

Hi,

Thanks a lot for the fix!
To be honest, I had only checked the original patch on Barebox 2025.02 and then
just backported it to the latest master :/

Would you be willing to take primary authorship for this commit?
Since you've reworked it completely, I think that would be more appropriate.

-- 
Best regards,
Andrei Lalaev



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-12 19:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-11 17:56 [PATCH] common: fastboot: send FAIL if variable does not exist Andrei Lalaev
2025-06-12  8:08 ` Sascha Hauer
2025-06-12 14:19   ` Andrei Lalaev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox