Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1466496rwb; Fri, 13 Jan 2023 12:44:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXsmBid3epedn14NIZjGcRbfLfT0l7ONX/FZ8WTHtbkFHTXKfC7SQlp2wM0PtkQzqOF1D2LP X-Received: by 2002:a05:6402:b14:b0:498:21b3:aeaf with SMTP id bm20-20020a0564020b1400b0049821b3aeafmr21188207edb.1.1673642641637; Fri, 13 Jan 2023 12:44:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673642641; cv=none; d=google.com; s=arc-20160816; b=jiktPgdjQg4cggnTyPjPs4GX8j5RzYvqghm1bECKMf8TvcJf45L4Ia6pcWsVs044w5 wbh0K/eJF7tPHDDp59FqMfR2DbXfa//JFoM1XhlQWbX9JHK5aOaJ8IjDmPY9SaPLVwYV /izrtuvGXpTBaJcbYmDXrZw5uzafdiSA5aUGPCvgYhfIC5PFiMjkJAmmpBMapkdqqSSL UBzaxECWb/kVM7Y1qcjwjz8OmSb1/7ahHiZoac3oDiSsJ167IeRWIk4hqX0JkryVlUlg L4qRE8/HLtWLq98y/zOMKskfoNv/Sduedu4dT+3x+mN5giIVclW5jPTYj3fvkeUoFl8F DJfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SrgzAQowrS3UwmksIPIBQcj8wLvZ/KEDNoTak6lFfyI=; b=gU2RwCcGoLqH3NfGbQiPYDXIzrlhOE1Xsx8E204fwOnw+f6F+ws0EvN4C8Fyko+yTj jenuP5ThNXnu1YmD48r72F4HX4NP+Z9NqaRvEjlY/2Ly2T0tIouTtB5p8YypW6vVB49R 6d3vsQIrC/EnxdCPmAxLE0JsqS85eYtAmgoi7q6lAsgLhUVDu3MBM4SmfKh3eGG4H86s 4eNw4A2QGr0EKqVb4NxyTphneUZyh1+VZLYzMuMD9TlZTLRm52Cq7KcfutEbgiWC0Bqt fVN+cxWvcD3RczayBPlU3Lj0EZ9ARr5qZ/tj3XdZk4BgVMsPCJHGxKxTOH0ZNejzw+oE cPTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=RYZAzuA3; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q23-20020a056402249700b00499b2eb6a0csi16509364eda.348.2023.01.13.12.42.44; Fri, 13 Jan 2023 12:44:01 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=RYZAzuA3; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229854AbjAMUmb (ORCPT + 99 others); Fri, 13 Jan 2023 15:42:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229704AbjAMUma (ORCPT ); Fri, 13 Jan 2023 15:42:30 -0500 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CCB38793C for ; Fri, 13 Jan 2023 12:42:28 -0800 (PST) Received: by mail-lj1-x236.google.com with SMTP id y19so2353206ljq.7 for ; Fri, 13 Jan 2023 12:42:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SrgzAQowrS3UwmksIPIBQcj8wLvZ/KEDNoTak6lFfyI=; b=RYZAzuA3QkDWefRdzmNWK0fjSeUJOIFLydI2XDNH2jrTJIj18mshkj5vU33Ol4WFMi Ryd0+oiGQHTW1sFjh9YPllKc9LvNp3MYLzicfwXR0XjmsTwJZwfL9XjDtT4LFeemuo+O wtJIKQBicd67wwiP4SNOHSD4IOdVlXsX7WKbYg3RLf+sXOZt16Pkj5rs74HMJOurp0Zb ew/T5lVIILa6Eei/4+GWM+1MvjztG7fRatBgLHk/xewIn/3bdqza+5GUyH5UThMNtncB qd5cqHP2OW/PqC4hCCTq9qZ5sMl1CWB8zhKKY/UIf9mfuNXIo/7CKopevFDtRBmF/Nrb h1wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SrgzAQowrS3UwmksIPIBQcj8wLvZ/KEDNoTak6lFfyI=; b=c6SKMCBWSWEjNTk4FGWEyMwOgwY03Qp2EWhEmbk3dU4lAall862div/JZzJ4cA3rUW ce6a4XKE3aGNjfiuCV2d/qSf3Pp6awsog+6Bxk3PiQ9CX4916Ek+9M0pLvdbbkcwIILC yHeZDNMPOuREn7omDz5OiDDUewAmSbzP5LmhbVhXGbOZT6DLio9XcY2x4GbTbUmKyOpo ja/kREFdqvxx9qwtKFjWZYxnJFJiFDeRhdmsspDoiDy/KUakTeSWE02Mv+cAj3t14bTD bsUTTaRu1Xsl8cWnpkUO0xN3W6T8BiwoLAzKfv8q7p+7Xy+L56FLEw1OVzLE5Vqj0Qom 89/Q== X-Gm-Message-State: AFqh2kpGIMFpSOx+424EuN7pYLj4dfu0nP5BmQ8pYsfiwzmbszzivp64 vSZudMbtzZ4YmFUy1o2cRmUUxfo+6idmSBqi3Ww= X-Received: by 2002:a2e:8750:0:b0:28b:63dc:4c7 with SMTP id q16-20020a2e8750000000b0028b63dc04c7mr241229ljj.423.1673642546766; Fri, 13 Jan 2023 12:42:26 -0800 (PST) MIME-Version: 1.0 References: <20230113050604.71398-1-abhay.maheshbhai.maheta@intel.com> In-Reply-To: <20230113050604.71398-1-abhay.maheshbhai.maheta@intel.com> From: Luiz Augusto von Dentz Date: Fri, 13 Jan 2023 12:42:15 -0800 Message-ID: Subject: Re: [PATCH BlueZ v3] shared/bap: Fixing Company ID, Vendor ID and Metadata handling To: Abhay Maheta Cc: linux-bluetooth@vger.kernel.org, Abhay Maheta Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 Hi Abhay, On Thu, Jan 12, 2023 at 9:11 PM Abhay Maheta wrote: > > This fixes Company ID, Vendor Codec ID and metadata storing > PAC record. > --- > src/shared/bap.c | 21 ++++++++++++++------- > 1 file changed, 14 insertions(+), 7 deletions(-) > > diff --git a/src/shared/bap.c b/src/shared/bap.c > index 0cafb75e6..463cdb7a6 100644 > --- a/src/shared/bap.c > +++ b/src/shared/bap.c > @@ -344,8 +344,10 @@ static void pac_foreach(void *data, void *user_data) > > p = util_iov_push(iov, sizeof(*p)); > p->codec.id = pac->codec.id; > - p->codec.cid = pac->codec.cid; > - p->codec.vid = pac->codec.vid; > + if (p->codec.id == 0xff) { > + p->codec.cid = cpu_to_le16(pac->codec.cid); > + p->codec.vid = cpu_to_le16(pac->codec.vid); > + } > > if (pac->data) { > p->cc_len = pac->data->iov_len; > @@ -2773,7 +2775,7 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type, > struct bt_pac *p; > struct bt_ltv *cc; > struct bt_pac_metadata *meta; > - struct iovec data, metadata; > + struct iovec data, *metadata = NULL; > > p = util_iov_pull_mem(&iov, sizeof(*p)); > if (!p) { > @@ -2802,8 +2804,11 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type, > data.iov_len = p->cc_len; > data.iov_base = cc; > > - metadata.iov_len = meta->len; > - metadata.iov_base = meta->data; > + if (meta->len) { > + metadata = new0(struct iovec, 1); > + metadata->iov_len = meta->len; > + metadata->iov_base = meta->data; > + } I'm trying to understand why you have done an extra copy of the metadata if later it will be copied by the likes of util_iov_dup inside bap_pac_new? > > util_iov_pull_mem(&iov, meta->len); > > @@ -2813,12 +2818,14 @@ static void bap_parse_pacs(struct bt_bap *bap, uint8_t type, > /* Check if there is already a PAC record for the codec */ > pac = bap_pac_find(bap->rdb, type, &p->codec); > if (pac) { > - bap_pac_merge(pac, &data, &metadata); > + bap_pac_merge(pac, &data, metadata); > + free(metadata); > continue; > } > > pac = bap_pac_new(bap->rdb, NULL, type, &p->codec, NULL, &data, > - &metadata); > + metadata); > + free(metadata); > if (!pac) > continue; > > -- > 2.25.1 > -- Luiz Augusto von Dentz