Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp5461364yba; Mon, 13 May 2019 11:12:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjM6yHoNtprv9RfMYht89XEbzG3Ba7s0nexfiBG9MJ+W6He8gE88Pq8pscf68XhXBsM9Yi X-Received: by 2002:a17:902:1cb:: with SMTP id b69mr6173045plb.158.1557771153415; Mon, 13 May 2019 11:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557771153; cv=none; d=google.com; s=arc-20160816; b=xjEsxzP9BIU23SQ+bZNHQI56N7FCmJ4xSLCVmQdNiZxmrnbNCNotAHvpcjBDfWTVC9 mAEwGIlF3mYc7Y2Wu3Cfzvvk2udx1VePaAtXhelTMX+2e4wuRZOkHPpuLbqBfl+Avzwp TifWwPTcnnb3RwOU57ItHIeJ20phN+Q3OKPiJq8/IoTeH6ZMtUIRVfNjZwZl7el+mZB5 cBQscirRogO45G6WSqKfb+tZnUX+cHjwkw+C/zXJIBQVi35PN+jTOpfJc8BYgxw8TNYX +ledGTgDRvzbMrDhcl1U+QYfc3Rs/Kr/tlmMguidtivsLkX+FWh/xFf/sWXtwq53EqQZ tlaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=bl/hfcfkfSD+4GttqBp7HTlYuBUtHaa9hM+nRCkgv/w=; b=r+2yTNMpq0xF0IUanULZ5MHHni6LkYqIM1VpT+/yy5Hi821ThZAH6c4vo3MaeoJ8Oj qmdRWGgnjl2NCuAm79KmjjaRoy10RdXlQznbAPcpKi0iVsV9kE8xrKGlD7H59rV+xN6Q auLbwfSCY/xCqdnILXRRq+YqTMCtIrKR9qW4/eMJNPxQ0yWJx1afgmGDBBOvWVW53l6k rlLmPR2v1fH7USpCBYG4m6ll90yZHDVRv3GeXi+WJ8wFalDbb3vvsjEFPpvrTYKtgwxN 62bAf/t+9aQNAVsh/Cj1volIfMRXJ1tuhTxXRKffioTP/zoA4HRhPxNHrwozZgVIq3h5 kTvQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gn19si17269271plb.67.2019.05.13.11.12.04; Mon, 13 May 2019 11:12:33 -0700 (PDT) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729702AbfEMQZe convert rfc822-to-8bit (ORCPT + 99 others); Mon, 13 May 2019 12:25:34 -0400 Received: from mga02.intel.com ([134.134.136.20]:42237 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728381AbfEMQZd (ORCPT ); Mon, 13 May 2019 12:25:33 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 May 2019 09:25:33 -0700 X-ExtLoop1: 1 Received: from orsmsx108.amr.corp.intel.com ([10.22.240.6]) by fmsmga006.fm.intel.com with ESMTP; 13 May 2019 09:25:33 -0700 Received: from orsmsx103.amr.corp.intel.com ([169.254.5.182]) by ORSMSX108.amr.corp.intel.com ([169.254.2.171]) with mapi id 14.03.0415.000; Mon, 13 May 2019 09:25:32 -0700 From: "Gix, Brian" To: Michal Lowas-Rzechonek , "linux-bluetooth@vger.kernel.org" CC: "Stotland, Inga" , "jakub.witowski@silvair.com" Subject: RE: [PATCH] mesh: Fixed log MIC usage in segmented messages Thread-Topic: [PATCH] mesh: Fixed log MIC usage in segmented messages Thread-Index: AQHVCUxamMxUmrxa9kagkMwDtpes56ZpOA0g Date: Mon, 13 May 2019 16:25:32 +0000 Message-ID: References: <20190507072702.27144-1-michal.lowas-rzechonek@silvair.com> In-Reply-To: <20190507072702.27144-1-michal.lowas-rzechonek@silvair.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjgyNjkyNGMtN2E3Ni00Zjc0LWExM2YtMTAxZjQ5YTk5YzFlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiU1dDaHRtSVNTUGdaY2k5aDVTTkd1QXRNc2VoV3ZFNGpFb3pCR2dVS1ZvWExwT3FtZnhTeTQ1dHlwQlFkMXdUSiJ9 dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-originating-ip: [10.22.254.140] Content-Type: text/plain; charset="iso-8859-2" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org Hi Michal & Jakub, > From: Michal Lowas-Rzechonek > > +#define CEILDIV(val, div) (((val) / (div)) + ((val) % (div) != 0)) > + > /* Use large MIC if it doesn't affect segmentation */ > if (msg_len > 11 && msg_len <= 376) { > - if ((out_len / 12) == ((out_len + 4) / 12)) { > + if (CEILDIV(out_len, 12) == CEILDIV(out_len + 4, 12)) { > szmic = true; > out_len = msg_len + sizeof(uint64_t); > } I see what you are doing here, and agree that it will fix a problem... for instance with out_len == 20 I am uncomfortable with two things: 1. The name CEILDIV... I found a definition for it (divide and round up) but I think it perhaps either the macro should be renamed something like "SEG_COUNT" *or* a comment added defining what CEILDIV means for the uninitiated (like me): /* CEILDIV() is a Divide and Round Up macro */ 2. Using a Boolean result as an Integer for addition makes the macro a bit difficult to puzzle out, if you don't know what it is trying to do. What about: (((val) / (div)) + (((val) % (div)) ? 1 : 0))