From: Przemyslaw Marczak <p.marczak@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 3/3] cmd:gpt: randomly generate each partition uuid if undefined
Date: Thu, 13 Mar 2014 21:13:28 +0100 [thread overview]
Message-ID: <53221168.5020305@samsung.com> (raw)
In-Reply-To: <53220BC2.4060504@wwwdotorg.org>
On 03/13/2014 08:49 PM, Stephen Warren wrote:
> On 03/13/2014 11:28 AM, Przemyslaw Marczak wrote:
>> On 03/10/2014 06:44 PM, Stephen Warren wrote:
>>> On 03/05/2014 09:45 AM, Przemyslaw Marczak wrote:
>>>> Changes:
>>>> - randomly generate each partition uuid if undefined
>>>> - print info about generated uuid
>>>> - save environment on gpt write success
>>>> - update doc/README.gpt
>>>
>>>> diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c
>
>>>> @@ -43,16 +45,25 @@ static char extract_env(const char *str, char **env)
>>>> memset(s + strlen(s) - 1, '\0', 1);
>>>> memmove(s, s + 2, strlen(s) - 1);
>>>> e = getenv(s);
>>>> - free(s);
>>>> if (e == NULL) {
>>>> - printf("Environmental '%s' not set\n", str);
>>>> - return -1; /* env not set */
>>>> + printf("%s unset. ", str);
>>>> + gen_rand_uuid_str(uuid_str);
>>>> + setenv(s, uuid_str);
>>>> +
>>
>> In this place ret is "-1".
>>
>>>> + e = getenv(s);
>>>> + if (e) {
>>>> + puts("Setting to random.\n");
>>>
>>> Shouldn't this be printed right after the "if (e == NULL)" check above?
>>> That's where the decision is made to generate a random UUID.
>>>
>>> Here, "if (!e)", the code should return an error.
>>>
>> If (!e) then ret is still "-1".
>> If (e) then ret = 0 and proper info is printed.
>
> But ret has nothing to do with it; there's no code in this function
> which prints messges based on ret.
>
> The code should be:
>
> e = getenv(s);
> if (e == NULL) {
> printf("Env var '%s' not set; using random UUID\n", str);
> // generate random UUID here
> if (UUID generation failed) {
> printf("ERROR generating random UUID\n");
> return -1;
> }
Take a note that gen_rand_uuid_str() doesn't return any error. So this
error is not true.
> }
>
> With the code in your patch, the following happens:
>
> * Env var is set: Nothing printed.
And env var is not changed - and this is as before.
>
> * Env var not set, but problem during UUID generation: "%s unset. " is
> printed without a \n at the end. The error does get propagated back tot
> he caller, which might print a message with \n at the end, but you
> shouldn't place that kind of requirement on the caller. Rather, this
> function should be fully self-contained.
>
> * Env var set, and UUID generated OK: "%s unset. Setting to random.\n"
> is printed.
>
>>> But, I still don't like changing the environment. Why can't the above
>>> few lines be:
>>>
>>> + gen_rand_uuid_str(uuid_str);
>>> + e = uuid_str;
>>
>> Such solution needs more code rewriting and breaking some existing
>> cmd_gpt design. "e" is used outside this function but uuid_str is local
>> here. I don't like to make it static.
>> Using getenv and return its pointer will work the same as previous.
>>
>> Please note that variables set by user are not overwritten here so this
>> code will only set null uuid env variables. Moreover user can see after
>> gpt command that environment is the same with mmc part shows, I think it
>> is useful instead of situation when uuid is set but not present in
>> environment.
>
> I don't think convenience of coding or the size of the patch is
> justification for writing values to the user's environment when they
> didn't ask for it. What if they run saveenv after executing this
> function, yet they specifically want the environment variables unset, so
> that a random UUID is generated each time this function/command is run?
>
Actually I don't understand what is the problem. What is the difference
when user set manually $uuid_gpt_* or use generated by gpt command if
next he write "save", in both situations variables are saved. I don't
think it is a problem.
Thanks
--
Przemyslaw Marczak
Samsung R&D Institute Poland
Samsung Electronics
p.marczak at samsung.com
next prev parent reply other threads:[~2014-03-13 20:13 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-28 15:18 [U-Boot] [PATCH 1/2] lib: uuid: add function to generate UUID version 4 Przemyslaw Marczak
2014-02-28 15:18 ` [U-Boot] [PATCH 2/2] cmd:gpt: randomly generate each partition uuid if undefined Przemyslaw Marczak
2014-02-28 17:03 ` Stephen Warren
2014-03-03 13:45 ` Przemyslaw Marczak
2014-03-03 14:13 ` Tom Rini
2014-03-03 15:31 ` Przemyslaw Marczak
2014-03-03 16:46 ` Tom Rini
2014-03-03 17:23 ` Przemyslaw Marczak
2014-03-03 17:35 ` Tom Rini
2014-03-03 17:58 ` Przemyslaw Marczak
2014-02-28 16:55 ` [U-Boot] [PATCH 1/2] lib: uuid: add function to generate UUID version 4 Stephen Warren
2014-03-03 13:44 ` Przemyslaw Marczak
2014-03-03 17:47 ` Stephen Warren
2014-03-05 16:45 ` [U-Boot] [PATCH V2 1/3] part_efi: move uuid_string() and string_uuid() to lib/uuid.c Przemyslaw Marczak
2014-03-05 16:45 ` [U-Boot] [PATCH V2 2/3] lib: uuid: add functions to generate UUID version 4 Przemyslaw Marczak
2014-03-10 17:37 ` Stephen Warren
2014-03-13 18:10 ` Przemyslaw Marczak
2014-03-13 18:41 ` Wolfgang Denk
2014-03-13 18:41 ` Wolfgang Denk
2014-03-13 19:18 ` Tom Rini
2014-03-13 19:48 ` Wolfgang Denk
2014-03-13 19:55 ` Stephen Warren
2014-03-13 19:51 ` Przemyslaw Marczak
2014-03-05 16:45 ` [U-Boot] [PATCH V2 3/3] cmd:gpt: randomly generate each partition uuid if undefined Przemyslaw Marczak
2014-03-10 17:44 ` Stephen Warren
2014-03-13 17:28 ` Przemyslaw Marczak
2014-03-13 19:49 ` Stephen Warren
2014-03-13 20:13 ` Przemyslaw Marczak [this message]
2014-03-10 17:24 ` [U-Boot] [PATCH V2 1/3] part_efi: move uuid_string() and string_uuid() to lib/uuid.c Stephen Warren
2014-03-10 17:28 ` Tom Rini
2014-03-10 17:52 ` Tom Rini
2014-03-10 17:29 ` Stephen Warren
2014-03-10 17:39 ` Tom Rini
2014-03-14 14:37 ` [U-Boot] [PATCH v3 1/3] part_efi: move uuid<->string conversion functions into lib/uuid.c Przemyslaw Marczak
2014-03-14 14:37 ` [U-Boot] [PATCH v3 2/3] lib: uuid: add functions to generate UUID version 4 Przemyslaw Marczak
2014-03-14 16:12 ` Wolfgang Denk
2014-03-17 9:16 ` Przemyslaw Marczak
2014-03-14 14:37 ` [U-Boot] [PATCH v3 3/3] cmd:gpt: randomly generate each partition uuid if undefined Przemyslaw Marczak
2014-03-14 16:16 ` Wolfgang Denk
2014-03-17 9:17 ` Przemyslaw Marczak
2014-03-14 16:06 ` [U-Boot] [PATCH v3 1/3] part_efi: move uuid<->string conversion functions into lib/uuid.c Wolfgang Denk
2014-03-17 9:15 ` Przemyslaw Marczak
2014-03-19 17:58 ` [U-Boot] [PATCH v4 1/6] " Przemyslaw Marczak
2014-03-19 17:58 ` [U-Boot] [PATCH v4 2/6] lib: uuid: code refactor for proper maintain between uuid bin and string Przemyslaw Marczak
2014-03-19 19:20 ` Wolfgang Denk
2014-03-25 19:12 ` Stephen Warren
2014-03-26 12:00 ` Przemyslaw Marczak
2014-03-26 18:43 ` Stephen Warren
2014-03-19 17:58 ` [U-Boot] [PATCH v4 3/6] lib: uuid: add functions to generate UUID version 4 Przemyslaw Marczak
2014-03-25 19:28 ` Stephen Warren
2014-03-26 12:00 ` Przemyslaw Marczak
2014-03-26 18:47 ` Stephen Warren
2014-03-27 9:17 ` Przemyslaw Marczak
2014-03-19 17:58 ` [U-Boot] [PATCH v4 4/6] new commands: uuid and guid - generate random unique identifier Przemyslaw Marczak
2014-03-25 19:37 ` Stephen Warren
2014-03-26 12:01 ` Przemyslaw Marczak
2014-03-26 18:32 ` Stephen Warren
2014-03-27 9:17 ` Przemyslaw Marczak
2014-03-19 17:58 ` [U-Boot] [PATCH v4 5/6] cmd:gpt: randomly generate each partition uuid if undefined Przemyslaw Marczak
2014-03-25 19:51 ` Stephen Warren
2014-03-26 12:01 ` Przemyslaw Marczak
2014-03-26 18:36 ` Stephen Warren
2014-03-27 9:17 ` Przemyslaw Marczak
2014-03-19 17:58 ` [U-Boot] [PATCH v4 6/6] trats/trats2: enable CONFIG_RANDOM_UUID Przemyslaw Marczak
2014-03-25 19:51 ` Stephen Warren
2014-03-26 12:01 ` Przemyslaw Marczak
2014-03-19 19:19 ` [U-Boot] [PATCH v4 1/6] part_efi: move uuid<->string conversion functions into lib/uuid.c Wolfgang Denk
2014-03-20 8:42 ` Przemyslaw Marczak
2014-03-25 19:03 ` Stephen Warren
2014-04-01 14:30 ` [U-Boot] [PATCH v5 " Przemyslaw Marczak
2014-04-01 14:30 ` [U-Boot] [PATCH v5 2/6] lib: uuid: code refactor for proper maintain between uuid bin and string Przemyslaw Marczak
2014-04-01 14:30 ` [U-Boot] [PATCH v5 3/6] lib: uuid: add functions to generate UUID version 4 Przemyslaw Marczak
2014-04-01 14:30 ` [U-Boot] [PATCH v5 4/6] new commands: uuid and guid - generate random unique identifier Przemyslaw Marczak
2014-04-01 14:30 ` [U-Boot] [PATCH v5 5/6] cmd:gpt: randomly generate each partition uuid if undefined Przemyslaw Marczak
2014-04-01 14:30 ` [U-Boot] [PATCH v5 6/6] trats/trats2: enable CONFIG_RANDOM_UUID Przemyslaw Marczak
2014-04-02 1:28 ` Minkyu Kang
2014-04-02 8:20 ` [U-Boot] [PATCH v6 1/6] part_efi: move uuid<->string conversion functions into lib/uuid.c Przemyslaw Marczak
2014-04-02 8:20 ` [U-Boot] [PATCH v6 2/6] lib: uuid: code refactor for proper maintain between uuid bin and string Przemyslaw Marczak
2014-04-02 21:18 ` [U-Boot] [U-Boot, v6, " Tom Rini
2014-04-02 8:20 ` [U-Boot] [PATCH v6 3/6] lib: uuid: add functions to generate UUID version 4 Przemyslaw Marczak
2014-04-02 8:25 ` Przemyslaw Marczak
2014-04-02 21:18 ` [U-Boot] [U-Boot, v6, " Tom Rini
2014-04-02 8:20 ` [U-Boot] [PATCH v6 4/6] new commands: uuid and guid - generate random unique identifier Przemyslaw Marczak
2014-04-02 21:18 ` [U-Boot] [U-Boot, v6, " Tom Rini
2014-04-02 8:20 ` [U-Boot] [PATCH v6 5/6] cmd:gpt: randomly generate each partition uuid if undefined Przemyslaw Marczak
2014-04-02 21:19 ` [U-Boot] [U-Boot, v6, " Tom Rini
2014-04-02 8:20 ` [U-Boot] [PATCH v6 6/6] trats/trats2: enable CONFIG_RANDOM_UUID Przemyslaw Marczak
2014-04-02 21:19 ` [U-Boot] [U-Boot, v6, " Tom Rini
2014-04-02 21:18 ` [U-Boot] [U-Boot, v6, 1/6] part_efi: move uuid<->string conversion functions into lib/uuid.c Tom Rini
2014-04-03 7:10 ` Przemyslaw Marczak
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=53221168.5020305@samsung.com \
--to=p.marczak@samsung.com \
--cc=u-boot@lists.denx.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