From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47596) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn1v7-0003Qc-NC for qemu-devel@nongnu.org; Tue, 28 Apr 2015 05:35:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yn1v4-00022q-Hn for qemu-devel@nongnu.org; Tue, 28 Apr 2015 05:35:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49545) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn1v4-00022j-D8 for qemu-devel@nongnu.org; Tue, 28 Apr 2015 05:35:10 -0400 Date: Tue, 28 Apr 2015 11:35:03 +0200 From: Igor Mammedov Message-ID: <20150428113503.0fe6fe9c@nial.brq.redhat.com> In-Reply-To: <553F4A43.2090104@huawei.com> References: <1429104309-3844-1-git-send-email-zhaoshenglong@huawei.com> <1429104309-3844-14-git-send-email-zhaoshenglong@huawei.com> <20150428085412.5d215d01@nial.brq.redhat.com> <553F3ACE.2060208@huawei.com> <20150428101529.5feb4915@nial.brq.redhat.com> <553F4A43.2090104@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v5 13/20] hw/acpi/aml-build: Add ToUUID macro List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Shannon Zhao Cc: peter.maydell@linaro.org, hangaohuai@huawei.com, mst@redhat.com, a.spyridakis@virtualopensystems.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, peter.huangpeng@huawei.com, alex.bennee@linaro.org, hanjun.guo@linaro.org, pbonzini@redhat.com, lersek@redhat.com, christoffer.dall@linaro.org, shannon.zhao@linaro.org On Tue, 28 Apr 2015 16:52:19 +0800 Shannon Zhao wrote: > On 2015/4/28 16:15, Igor Mammedov wrote: > >>> btw: > >>> > > whole thing might be simpler if an intermediate conversion is avoided, > >>> > > just pack buffer as in spec byte by byte: > >>> > > > >>> > > /* format: aabbccdd-eeff-gghh-iijj-kkllmmnnoopp */ > >>> > > assert(strlen(uuid) == ...); > >>> > > build_append_byte(var->buf, HEX2BYTE(uuid[3]); /* dd */ > >> > > >> > use build_append_byte(var->buf, HEX2BYTE(uuid + 7); ? > >> > > >>> > > build_append_byte(var->buf, HEX2BYTE(uuid[2]); /* cc */ > >> > > >> > use build_append_byte(var->buf, HEX2BYTE(uuid + 5); ? > > if you mean hyphens /-/ then they are not encoded, > > but you surely can add checks for them to make sure that > > UUID format is as expected. > > > > I mean uuid[3] points to b not dd. Maybe use following way: > > static uint8_t Hex2Byte(char *src) or even better: Hex2Byte(char *src, byte_idx) and do pointer arithmetic inside [...] > build_append_byte(var->buf, Hex2Byte(uuid + (3 * 2))); /* dd */ build_append_byte(var->buf, Hex2Byte(uuid, 3)); /* dd - at offset 00 */ build_append_byte(var->buf, Hex2Byte(uuid, 2)); /* cc - at offset 01 */ ...