From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn28o-0004wk-Vl for qemu-devel@nongnu.org; Tue, 28 Apr 2015 05:49:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yn28k-0006gP-5B for qemu-devel@nongnu.org; Tue, 28 Apr 2015 05:49:22 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:28014) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yn28j-0006g4-JF for qemu-devel@nongnu.org; Tue, 28 Apr 2015 05:49:18 -0400 Message-ID: <553F5782.7020707@huawei.com> Date: Tue, 28 Apr 2015 17:48:50 +0800 From: Shannon Zhao MIME-Version: 1.0 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> <20150428113503.0fe6fe9c@nial.brq.redhat.com> In-Reply-To: <20150428113503.0fe6fe9c@nial.brq.redhat.com> Content-Type: text/plain; charset="ISO-8859-1" 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: Igor Mammedov 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 2015/4/28 17:35, Igor Mammedov wrote: > 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 */ > ... > Yes, it's better to first four bytes. But there are hyphens /-/, for offset 04, 05 and etc it doesn't work. We can't use following expression: build_append_byte(var->buf, Hex2Byte(uuid, 5)); /* ff - at offset 04 */ build_append_byte(var->buf, Hex2Byte(uuid, 4)); /* ee - at offset 05 */ ...