Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2479522ybl; Thu, 9 Jan 2020 13:31:49 -0800 (PST) X-Google-Smtp-Source: APXvYqwvBbhUAZShqYNQcc44S+d4UmadppWGqWQPljbIGhWU3QWOFGZven0CMih2Gka6nmqTXnK2 X-Received: by 2002:a9d:5c86:: with SMTP id a6mr10447750oti.68.1578605509387; Thu, 09 Jan 2020 13:31:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578605509; cv=none; d=google.com; s=arc-20160816; b=VwvPO+cHJfRL3kVBit0QmT0T4X9gf11GFQ0SM7FI8nIzLHcx0b33/kHVXV2b6Q8chC B9SGkE9dsjPrV5IrUMOXCngTx9M4V1O1IYmZELSLST46ebyFjuuWX0rGRYoMvBOUbIG0 GmQnMmeb5Qt37lKA5kcb52oU7ALUFPttLfi1vjcZGqfwd3mbuKj9y/b/8SWPPgz7gUP/ OtEQeG3MkCCOuJmLdBWSsDNwrSru+4Z25ZYjhEkmlMlNUoxCLDj0+njzbnH6lLo9+SYM yLr3+XixZCeaQh6a+9FiyM7qhVNxDz8nb/c1nFOBG20McEuxmtBudTT1tE7XF9onq5Mm g9Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=dr6hmUOEEVkx566zXdNca4NBj3yQTAAohBNMUPSdoBA=; b=XURFPOop6ysc8VLOaXKeB/lIDst0KCQRz9VFQsE9hxB2SeZaSHwWlnvQkMjj5uB1X2 zQK8vcr3Vx5VLHEclm31vxX+SZpbgbQwBKa76yxifwSxm4M+GyJX0VOyXntGJLWSwc32 iYuYp5kLrZ6bo8rQNhXmmtb+QT2vYnn64KYxl+Xso2e5BG5JwEP6kwYf1eBqW0hTHvi+ vM4LeSx50F+8mnmZ+u40JI4t9s3TdBe9aHwaINMFJK7K2WjKtZRhzeQoxK0URfh62vQ4 HWJX78xmOjQihdtUGg0SGT84D7VYGdw55+PExgSxD50Epv+48lXV5hO10j3jGOPKdOPq s/TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=MaONT6uX; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n8si4523110otr.102.2020.01.09.13.31.03; Thu, 09 Jan 2020 13:31:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=MaONT6uX; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728902AbgAIV3k (ORCPT + 99 others); Thu, 9 Jan 2020 16:29:40 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:35187 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725763AbgAIV3j (ORCPT ); Thu, 9 Jan 2020 16:29:39 -0500 Received: by mail-lj1-f193.google.com with SMTP id j1so8830710lja.2 for ; Thu, 09 Jan 2020 13:29:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=dr6hmUOEEVkx566zXdNca4NBj3yQTAAohBNMUPSdoBA=; b=MaONT6uXfuuVD5gWQEblvW1acQSkm9YVNGLJEgAxCMLdQKhlOd9reo97sv/nb6XsOm V/XTswK0XDP5RUTxogF25ToykYzZ83Uom4sbtEkiP72dllElsBbhzI9gAVCyVNzc6N8u Q4WzMRJPGlN7EsQFk69UlVsHQs4P57E0sNGI7RY7Poqm8LrSgUeiM28+kcpEfJO8yCgq jxtjD1uk1DRqeFwg8LG/lkKJaGnt7ynhJdkbTzvOrPl00tsiQtuqcZSApnkYeaW+cRMh 5SQo4nE0HJqd1XsNxAVNdShW3XZAfX1f+ilrs9wBfQ5bm3WMLcY3YTnR3k3WwQMokSJh zHdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=dr6hmUOEEVkx566zXdNca4NBj3yQTAAohBNMUPSdoBA=; b=W/vT1Jmcbi1IG6A3vy9X46QTE9D/q49xymQWasGAhsPJoVldUWWqs4WV2bhbfc+bal PXmlZwtRiFk+qes7xKmWEZUhBbJONVsdFP29tCQBIp48iS69JgQx38x6wwQwGC6jNVRS 7xTe42fIIsthF6dMFFuVOf1EJeTZrISfQ0dD6FhqQBeYqXMhP8Gj4ZL9j0ldSGIni6qX 49kv1VVMynAYhi24+dOKct/QTEuupRNoxzx6TzZZrMQT7JwPqW2kWaLXSp1B8eLyRsE7 0SH2thm1vDP1CjVDeMVh8fI57gdU3IxhDQClxxvQ/fqD2HobmcP+G0qsPOxxoH+dUoGj 80AQ== X-Gm-Message-State: APjAAAWEPZWxZ2l8NcrPrCJWJzXSK1+7tY1TE9wt0k8WaqbLJGGz2ZIY OSpzwS0J6DM2ta+BB3vcWySoow== X-Received: by 2002:a2e:6c13:: with SMTP id h19mr44316ljc.221.1578605377664; Thu, 09 Jan 2020 13:29:37 -0800 (PST) Received: from kynes (apn-37-7-124-67.dynamic.gprs.plus.pl. [37.7.124.67]) by smtp.gmail.com with ESMTPSA id g24sm3622404lfb.85.2020.01.09.13.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jan 2020 13:29:37 -0800 (PST) Date: Thu, 9 Jan 2020 22:29:35 +0100 From: "michal.lowas-rzechonek@silvair.com" To: "Stotland, Inga" Cc: "Gix, Brian" , "linux-bluetooth@vger.kernel.org" Subject: Re: [PATCH BlueZ] mesh: Correctly generate NetKey list Message-ID: <20200109212935.6dn5ivmnupfd5f2d@kynes> Mail-Followup-To: "Stotland, Inga" , "Gix, Brian" , "linux-bluetooth@vger.kernel.org" References: <20200109175715.22925-1-inga.stotland@intel.com> <20200109210006.e3qv6uxnr2w3isc5@kynes> <31a576190ecbd1ba3f7e779d746baf35815fbed9.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <31a576190ecbd1ba3f7e779d746baf35815fbed9.camel@intel.com> User-Agent: NeoMutt/20180716 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org On 01/09, Stotland, Inga wrote: >> Please don't use bit shifts for division. > Why? Because it's a different operation, and is less readable. It's a formula, so use math operators for numbers and bit operators for bits. For example, idx_pair <<= 12 is fine, because the *context* is bit-packing. Noone sane would write this as idx_pair *= 4096. This reasoning applies the other way as well: don't write foo >> 2 where you mean foo / 4. >> Also, I think it's clearer to write this as: >> req_size = num_keys * 3 - num_keys % 2 > > No, this is not how I read the spec. We need to pack 2 key indices in 3 octets. > For example, 4 keys are packed in 6 octets and 5 keys are packed in 8 octets. Yes, you're right. Sorry. -- Michał Lowas-Rzechonek Silvair http://silvair.com Jasnogórska 44, 31-358 Krakow, POLAND