Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1168842AbdDXKns (ORCPT ); Mon, 24 Apr 2017 06:43:48 -0400 Received: from mailout3.hostsharing.net ([176.9.242.54]:60631 "EHLO mailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1166480AbdDXKnk (ORCPT ); Mon, 24 Apr 2017 06:43:40 -0400 Date: Mon, 24 Apr 2017 12:44:02 +0200 From: Lukas Wunner To: Andy Shevchenko Cc: "Winkler, Tomas" , Andrew Morton , "linux-kernel@vger.kernel.org" , Arnd Bergmann , Mika Westerberg , "alsa-devel@alsa-project.org" , "linux-input@vger.kernel.org" , "kvm@vger.kernel.org" , "devel@linuxdriverproject.org" , "linux-efi@vger.kernel.org" , "linux-acpi@vger.kernel.org" , Liam Girdwood , Mark Brown , "Koul, Vinod" , Srinivas Pandruvada , Benjamin Tissoires , Kirti Wankhede , Alex Williamson , "K. Y. Srinivasan" , Haiyang Zhang , Stephen Hemminger , Matt Fleming , Ard Biesheuvel , "Rafael J. Wysocki" Subject: Re: [PATCH v1 1/8] lib/uuid: Introduce uuid_{be|le}_cmp_p{p}() helpers Message-ID: <20170424104402.GA9723@wunner.de> References: <20170421144645.45189-1-andriy.shevchenko@linux.intel.com> <5B8DA87D05A7694D9FA63FD143655C1B543E8399@hasmsx108.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5B8DA87D05A7694D9FA63FD143655C1B543E8399@hasmsx108.ger.corp.intel.com> User-Agent: Mutt/1.6.1 (2016-04-27) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2728 Lines: 73 > New helpers take pointers to uuid_{be|le} as parameters. > > When using them on a raw data we don't need to do an ugly dereference and, > in some cases, a type casting. > > Cc: Andrew Morton > Cc: Arnd Bergmann > Cc: Liam Girdwood > Cc: Mark Brown > Cc: Vinod Koul > Cc: Srinivas Pandruvada > Cc: Benjamin Tissoires > Cc: Kirti Wankhede > Cc: Alex Williamson > Cc: "K. Y. Srinivasan" > Cc: Haiyang Zhang > Cc: Stephen Hemminger > Cc: Tomas Winkler > Cc: Matt Fleming > Cc: Ard Biesheuvel > Cc: "Rafael J. Wysocki" > > Signed-off-by: Andy Shevchenko > --- > include/linux/uuid.h | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/include/linux/uuid.h b/include/linux/uuid.h index > 4dff73a89758..45312cb5ac65 100644 > --- a/include/linux/uuid.h > +++ b/include/linux/uuid.h > @@ -58,6 +58,26 @@ static inline int uuid_be_cmp(const uuid_be u1, const > uuid_be u2) > return memcmp(&u1, &u2, sizeof(uuid_be)); } > > +static inline int uuid_le_cmp_p(const uuid_le *pu1, const uuid_le u2) { > + return memcmp(pu1, &u2, sizeof(uuid_le)); } > + > +static inline int uuid_be_cmp_p(const uuid_be *pu1, const uuid_be u2) { > + return memcmp(pu1, &u2, sizeof(uuid_be)); } > + > +static inline int uuid_le_cmp_pp(const uuid_le *pu1, const uuid_le > +*pu2) { > + return memcmp(pu1, pu2, sizeof(uuid_le)); } > + > +static inline int uuid_be_cmp_pp(const uuid_be *pu1, const uuid_be > +*pu2) { > + return memcmp(pu1, pu2, sizeof(uuid_be)); } > + > void generate_random_uuid(unsigned char uuid[16]); > > extern void uuid_le_gen(uuid_le *u); There's a bug in gcc wherein constant compound literals are generated on the stack at runtime, rather than stored in rodata. The bug occurs if the compound literal is passed by reference. It does not manifest itself when passing by value: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68725 Hence this patch is unfortunately counterproductive if the UUIDs are declared const. FWIW I've posted a series back in January to constify UUIDs as much as possible, but I got some objections and lacked the time so far to address them. In fact I'm thinking that gcc needs to be fixed first, then we can focus on improving the kernel side of things: https://www.spinics.net/lists/linux-efi/msg10093.html Best regards, Lukas