From patchwork Wed Jun 29 21:16:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 585903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72853C433EF for ; Wed, 29 Jun 2022 21:17:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230012AbiF2VRh (ORCPT ); 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 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) From patchwork Wed Jun 29 21:16:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brian Gix X-Patchwork-Id: 586656 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30C3BC43334 for ; Wed, 29 Jun 2022 21:17:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229927AbiF2VRi (ORCPT ); Wed, 29 Jun 2022 17:17:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbiF2VRi (ORCPT ); Wed, 29 Jun 2022 17:17:38 -0400 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A68D83FD86 for ; Wed, 29 Jun 2022 14:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656537457; x=1688073457; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=g/luvEaLinQrCM+LWbxbhgfJFVtoq5zUGl3Wlh5mxFg=; b=bwSjtGekalZElIA/IrC3GqV2tHpwGM6cYrFdu5gfi0qK398GaVwOQWUg /vncuzGjgiGF3m5fLeLgUIh9ZZUoMYLiBc0Otqluele8VLwsn3liuNYqP ru3br4BQNDPXHgrRsn1leVlxScIPwdenhrdSLvX1bpNd2gnQMIrvFJRCn tZGT0jsn/5rZ5Rkj1Tpf+uo9kl5unagvy4BX7FK988Rk5May3fMYAcm5M IWNTQv9rtDl0UFgE9Nk6IlYNJJet6V85N22n/snd39NU06QjuziwFa7xo RUtzptV1RS12/tM7EPzKqiDfXLCdXOySydnUVxzWGHD1t6xf6HGTMpth7 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10393"; a="282898076" X-IronPort-AV: E=Sophos;i="5.92,232,1650956400"; d="scan'208";a="282898076" 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="647585413" 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 2/2] core: Fix signed vs unsigned compare Date: Wed, 29 Jun 2022 14:16:40 -0700 Message-Id: <20220629211640.65822-2-brian.gix@intel.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220629211640.65822-1-brian.gix@intel.com> References: <20220629211640.65822-1-brian.gix@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org __time_t is not a portable data type, and can cause sign mismatch on some compares. Fixes: CC src/bluetoothd-device.o src/device.c: In function ‘device_is_name_resolve_allowed’: src/device.c:4092:17: error: comparison of integer expressions of different signedness: ‘__time_t’ {aka ‘long int’} and ‘long unsigned int’ [-Werror=sign-compare] if (now.tv_sec >= device->name_resolve_failed_time + ^~ cc1: all warnings being treated as errors --- src/device.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/device.c b/src/device.c index 7b451e458..b91e5dc58 100644 --- a/src/device.c +++ b/src/device.c @@ -4088,8 +4088,8 @@ bool device_is_name_resolve_allowed(struct btd_device *device) /* now >= failed_time + name_request_retry_delay, meaning the * period of not sending name request is over. */ - if (now.tv_sec >= device->name_resolve_failed_time + - btd_opts.name_request_retry_delay) + if (now.tv_sec >= (time_t)(device->name_resolve_failed_time + + btd_opts.name_request_retry_delay)) return true; return false;