From mboxrd@z Thu Jan 1 00:00:00 1970 From: Przemyslaw Marczak Date: Thu, 27 Mar 2014 10:17:41 +0100 Subject: [U-Boot] [PATCH v4 5/6] cmd:gpt: randomly generate each partition uuid if undefined In-Reply-To: <53331E29.1020608@wwwdotorg.org> References: <5ef7cdb8df4fb05c3c371e29d7a61e28e1563a68.1394807506.git.p.marczak@samsung.com> <1395251911-26540-1-git-send-email-p.marczak@samsung.com> <1395251911-26540-5-git-send-email-p.marczak@samsung.com> <5331DE2F.1070502@wwwdotorg.org> <5332C186.5000508@samsung.com> <53331E29.1020608@wwwdotorg.org> Message-ID: <5333ECB5.2000603@samsung.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 03/26/2014 07:36 PM, Stephen Warren wrote: > On 03/26/2014 06:01 AM, Przemyslaw Marczak wrote: >> On 03/25/2014 08:51 PM, Stephen Warren wrote: >>> On 03/19/2014 11:58 AM, Przemyslaw Marczak wrote: >>>> Changes: >>>> - randomly generate partition uuid if any is undefined and >>>> CONFIG_RAND_UUID >>>> is defined >>>> - print debug info about set/unset/generated uuid >>>> - update doc/README.gpt >>>> >>>> Update existing code to the new library functions. > >>>> diff --git a/common/cmd_gpt.c b/common/cmd_gpt.c >>>> - if ((strncmp(str, "${", 2) == 0) && (str[strlen(str) - 1] == '}')) { >>>> - s = strdup(str); >>>> - if (s == NULL) >>>> - return -1; >>>> - memset(s + strlen(s) - 1, '\0', 1); >>>> - memmove(s, s + 2, strlen(s) - 1); >>>> + if (!((strncmp(str, "${", 2) == 0) && (str[strlen(str) - 1] == '}'))) >>>> + return -1; >>> >>> Since you're inverting that test, you need to change && to || too. >>> >> No, because the invertion refers to the result of "if" - not one of >> conditions. >> !(cond1 && cond2) is the same as: >> (!cond1 || !cond2) >> so this change is ok. > > Ah yes, right. > >>>> diff --git a/doc/README.gpt b/doc/README.gpt >>>> index 5c133f3..51515c8 100644 >>>> --- a/doc/README.gpt >>>> +++ b/doc/README.gpt >>>> @@ -101,7 +101,7 @@ Offset Size Description >>>> 40 8 B First usable LBA for partitions (primary partition >>>> table last >>>> LBA + 1) >>>> 48 8 B Last usable LBA (secondary partition table first >>>> LBA - 1) >>>> -56 16 B Disk GUID (also referred as UUID on UNIXes) >>>> +56 16 B Disk GUID (also referred as UUID on UNIXes) in big >>>> endian >>> >>> According to your earlier comment, GUIDs have a mix of LE and BE fields, >>> so I would simply drop this change and the similar change below. Let >>> wikipedia or the comment you added near to top of lib/uuid.c specify the >>> details. >>> >> Actually I think that this is an important info here. The information >> about endianness is also placed in few places in lib/uuid.c > > Why isn't the endianness of all the fields in this structure defined in > this comment then? > Right notice, I will add there more info. Thanks -- Przemyslaw Marczak Samsung R&D Institute Poland Samsung Electronics p.marczak at samsung.com