Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp974187iog; Wed, 29 Jun 2022 14:19:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uMjB3tSpzTR1DUN0SxjT9E42EHeMOIaUTshDX2pMLOfA6FeTcdT7449FKe9La7kbVE3Fj3 X-Received: by 2002:a63:3409:0:b0:40c:9736:287 with SMTP id b9-20020a633409000000b0040c97360287mr4570476pga.14.1656537567679; Wed, 29 Jun 2022 14:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656537567; cv=none; d=google.com; s=arc-20160816; b=bv+SS4pnmQ3SuoTt1TULDkEtx6pJhQYpcdwTjiqrLX17BMY8OOes2gpEcRI7m9kqQJ lCERJvtrTD3j+I7bEV6V13+37pc8UGLVJ6Hq3v3S0vJQfPGenI6kPmSxmbaJNscdsvee owqzrvjCd+Ulf2yleYpQJ5Vs/pWcLiKgp9ywpnRzcCArg3z83WUjYSYilSj8ZIDcviyh Ixf/sh88XoaHbCnbiCzBgY3WVpRh5VPiyXxa29Vc05wbJ82ZrbKXwKh6kB8NqTkkqrDF 5D3/nVe9nEHzpokNTSGo2VElLM/MHOmV3ggKgfjaAN9S1cmGi5RXDR8ESFhZ8nrJgC5g 982w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=kvaFn4IirzQUZQyZQ6KiSc2u5FM82PJYCtILbqOAW1U=; b=M8WWl3wv8N+oA26nqC/gFispPueIOrYTJhAsuqdqA4KiAOPPnTJJK71etxeIGvpjGL cBeFwDIWPEQgF55k4QTm0iecX6ltWUE7RLfBighvN53BS7/L+2ULYHdAWCfb2QegZehw LuSjoHpIdl+Ap550HFY853Rjmy/RAk+LUdsr5/duFKz8C5yDOr9A0XmV8KvMxqr0WX4K NPMeYTwmMOXehXmDuUuF0ppjMfWxMwSTt/Y7n8vSbyevEu1qMj6nLcvVPyfBQjlGLHKK 7MVY5h47qy97QtLhMYObhzY9FG/DP2/HBVr3me/20klVLG5q/QorKJy7VpC8P9EuEec+ XGLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YONX5KuT; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k193-20020a633dca000000b00408b913d6fdsi21900650pga.257.2022.06.29.14.19.13; Wed, 29 Jun 2022 14:19:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YONX5KuT; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230011AbiF2VRh (ORCPT + 99 others); Wed, 29 Jun 2022 17:17:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229875AbiF2VRh (ORCPT ); Wed, 29 Jun 2022 17:17:37 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B6403FD86 for ; Wed, 29 Jun 2022 14:17:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656537456; x=1688073456; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zNItVhoGjzoxHAkmOctou+y+s3aQ4QlGYYRgIt7SeLc=; b=YONX5KuT2WBDDBjYm3mQFPOmPpzN9UB5GfKqMTO724U39T8UZEPgBIJp 3apGcU3d/1lL86AY5B/ti66UihjcW5as70lkUwpjUOakeyDSLCTL6yB0E KKBAENCazSmP6STxLcWJTIsgw3v3zCjfinrwHY+MNhbynN+qaBQJzcsFH uce0OZDI1IYWRvQnvU4XlXTPCm/NGmM/v30lM79bUaxKAthGCmke65YyZ olLGdP6nFOYSpC74/crUq6KJJbhgoijQ+zMjXGwx/oaAPMf3KFxVOqJEK Of641i+dhpxtm8/lK2Sdp0dTNN2obieP9tXX97ubrK3F0QnznjExIZxYl A==; X-IronPort-AV: E=McAfee;i="6400,9594,10393"; a="282898071" X-IronPort-AV: E=Sophos;i="5.92,232,1650956400"; d="scan'208";a="282898071" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2022 14:16:50 -0700 X-IronPort-AV: E=Sophos;i="5.92,232,1650956400"; d="scan'208";a="647585408" Received: from bshamoun-mobl2.amr.corp.intel.com (HELO bgi1-mobl2.amr.corp.intel.com) ([10.212.96.196]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2022 14:16:49 -0700 From: Brian Gix To: linux-bluetooth@vger.kernel.org Cc: luiz.von.dentz@gmail.com, brian.gix@intel.com Subject: [PATCH BlueZ v2 1/2] core: make bt_uuid_hash() portable across archs Date: Wed, 29 Jun 2022 14:16:39 -0700 Message-Id: <20220629211640.65822-1-brian.gix@intel.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org bt_uuid_t is defined as a byte array, so it can cause alignment errors on some architectures, when the two 64 bit halves are treated as u64s. This patch ensures proper alignment across all architectures. Fixes: src/adapter.c: In function ‘bt_uuid_hash’: src/adapter.c:3617:8: error: cast increases required alignment of target type [-Werror=cast-align] val = (uint64_t *)&uuid_128.value.u128; ^ cc1: all warnings being treated as errors --- src/adapter.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/adapter.c b/src/adapter.c index afefa1d5d..c8b3d27a7 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -3607,16 +3607,14 @@ static void add_uuid_to_uuid_set(void *data, void *user_data) static guint bt_uuid_hash(gconstpointer key) { const bt_uuid_t *uuid = key; - bt_uuid_t uuid_128; - uint64_t *val; + uint64_t uuid_128[2]; if (!uuid) return 0; - bt_uuid_to_uuid128(uuid, &uuid_128); - val = (uint64_t *)&uuid_128.value.u128; + bt_uuid_to_uuid128(uuid, (bt_uuid_t *)uuid_128); - return g_int64_hash(val) ^ g_int64_hash(val+1); + return g_int64_hash(uuid_128) ^ g_int64_hash(uuid_128+1); } static gboolean bt_uuid_equal(gconstpointer v1, gconstpointer v2) -- 2.36.1