Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp937866rwb; Mon, 26 Sep 2022 07:43:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6jdJGWfeQZfQbn8ht9gi7wrLfYT31x68OImbiQpqafF45sQcss5OYND36g9CtyPoy34+sI X-Received: by 2002:a63:c142:0:b0:43c:9fcc:c9f2 with SMTP id p2-20020a63c142000000b0043c9fccc9f2mr7831744pgi.44.1664203387096; Mon, 26 Sep 2022 07:43:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664203387; cv=none; d=google.com; s=arc-20160816; b=m8ztS+TvBadnehS5n5wdlszwc3DHNcV1h137sTV+/O3YIomPOS8Vi0Dwrv3krAFGya Z5Axfow9VmEhmuWbftB0VEwhOGtomDm3p7KohIWbow+7B4mwWSVi/cEjKX2HSZ2irY4H ZH2YJJPyADHLzb6zAcJMTVGpTG8a8tZOx0a7Al6I/Z497/DiH2EmjRqtM3O+CIVAK8Ra GwlVaWCGabzPprEdAj7s1CnFMyY335hrOLbY2dZb6z6IKRN3nFXle+sk7hQW0kMRyYhP 4hwlCbHy3HfXmzWbi9MLOitHigT8k57KdnLaSs3JRFHu9MRDuWEdxqpwfTgIM7SRP8ky FNTQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=MOd30O5pDKhboxEcArbKwzK2XwQcKdeVPXf7bY9DKPs=; b=mAJm6caU5RyrFfVvuIqidCW3mIp4t7bioYh5vgXtR68Fy1q7Z5q+W2WbhDYJFHbqAw 3Tn0YB4vs+9T53E9zPA4sHgsxms5eX8jY2Ky77/sUl8fWqJOFN/uYT81uazzQFDm378I Pu2BUxBQwpWZbn5qmI9ugLvYau5zaQ1LRK0oxCj8hY/6XlbNBD4a5ymnuXadfLL16tUA UawLr+u9Ioksu4dFNGIllkSr2jQvPeP3OrmmTEfJijtF3T4Krt5Gnl2CJ+9E7UzlBQ67 B+TZiRaXu+CNGQidyNN9Qr7WNTDG1c9+ALOb0QxMqfdVt0EH8eebvSXu/1DDqfyk2DmD McBw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f7-20020a63f107000000b004392fa3ea5dsi18912567pgi.557.2022.09.26.07.41.54; Mon, 26 Sep 2022 07:43:07 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235194AbiIZOl3 (ORCPT + 99 others); Mon, 26 Sep 2022 10:41:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234432AbiIZOlC (ORCPT ); Mon, 26 Sep 2022 10:41:02 -0400 Received: from voyager.loytec.com (voyager.loytec.com [88.198.4.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C298F3135 for ; Mon, 26 Sep 2022 06:01:44 -0700 (PDT) Received: from 212-17-98-152.static.upcbusiness.at ([212.17.98.152] helo=lexx.office.loytec.com) by voyager.loytec.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ocnjy-00046k-Kp for linux-bluetooth@vger.kernel.org; Mon, 26 Sep 2022 15:01:42 +0200 Received: from loytec-dev-vm.delta.corp ([10.101.25.21]) by lexx.office.loytec.com (8.15.2/8.15.2/Some OS 1.2.3-4.5) with ESMTP id 28QD1bCV1107873; Mon, 26 Sep 2022 15:01:40 +0200 From: Isak Westin To: linux-bluetooth@vger.kernel.org Cc: Isak Westin Subject: [PATCH BlueZ 1/4] mesh: Correct u32 to u8 log transformation Date: Mon, 26 Sep 2022 15:01:07 +0200 Message-Id: <20220926130110.2146-2-isak.westin@loytec.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220926130110.2146-1-isak.westin@loytec.com> References: <20220926130110.2146-1-isak.westin@loytec.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 212.17.98.152 X-SA-Exim-Mail-From: isak.westin@loytec.com X-SA-Exim-Scanned: No (on voyager.loytec.com); SAEximRunCond expanded to false X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE 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 Fixed the log transformation to correctly follow the value mapping defined in the mesh profile (section 4.1.2). --- mesh/cfgmod-server.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 9bc2f1c97..33796d05a 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -455,14 +455,14 @@ done: static uint8_t uint32_to_log(uint32_t value) { uint32_t val = 1; - uint8_t ret = 1; + uint8_t ret = 0; if (!value) return 0; else if (value > 0x10000) return 0xff; - while (val < value) { + while (val <= value) { val <<= 1; ret++; } @@ -495,7 +495,7 @@ static uint16_t hb_subscription_get(struct mesh_node *node, int status) l_put_le16(sub->dst, msg + n); n += 2; msg[n++] = uint32_to_log(time_now.tv_sec); - msg[n++] = uint32_to_log(sub->count); + msg[n++] = sub->count != 0xffff ? uint32_to_log(sub->count) : 0xff; msg[n++] = sub->count ? sub->min_hops : 0; msg[n++] = sub->max_hops; @@ -538,7 +538,7 @@ static uint16_t hb_publication_get(struct mesh_node *node, int status) msg[n++] = status; l_put_le16(pub->dst, msg + n); n += 2; - msg[n++] = uint32_to_log(pub->count); + msg[n++] = pub->count != 0xffff ? uint32_to_log(pub->count) : 0xff; msg[n++] = uint32_to_log(pub->period); msg[n++] = pub->ttl; l_put_le16(pub->features, msg + n); -- 2.20.1