Message ID | 20221029214058.25159-1-tegongkang@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1520565wru; Sat, 29 Oct 2022 14:48:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7VHoOS6X/WPYMPAYyxjJA1/Yr4ACx53GpI8vqY96lCGzzaCPL2/uiQiBmoZYrcdT6b6S8n X-Received: by 2002:a17:906:8b81:b0:7ad:93d1:5eae with SMTP id nr1-20020a1709068b8100b007ad93d15eaemr5658901ejc.29.1667080117824; Sat, 29 Oct 2022 14:48:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667080117; cv=none; d=google.com; s=arc-20160816; b=09CZ004QdfgHHmhHB7YYWP7cKdze3XTPg6BK0PLStJRTiKL65IlzGJTwXBtxFvogcF ENsqOQ+YX81TkDv6PKgfQQuiFMe5zrpd+A6Jn3lLHUlsTxrIu6jWkrNGpAdCaT8e1mYX IwzoVjY/NjFQXLoV2glGr5ghd7QYpMJov2DiPT18hYDsssDGrAkwESs6sw2BQbmZ0bxb iVPGFRgviasIdhVLqHtyjxo3i3R4UOla6dktreGaBTAIY+RRH37o/GU3zhtOkm7JVYrZ 1HH0fbXvTrZrK10Iv7iJwweziaTYkwWZarFO2jPv/PwrJYrJVkLHqX0Whn7OYV4LkGwM m3VA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=/861UoRf3F+2YILewsi3E4Q/g8WnmJGSnP8oXVC9Ulo=; b=CSLlnzUjGybiaB7HgJ01hU6BVEOKWWNNTb1tPPT5PqxeSrlZJWEoLMsN0qU0x0Z7c8 ErMpomPnUmaa/zBFwViG9lcPaaQc1b683d3YB05rmBsbMtAetXNwNOjsy+xJDiVdhfaj MSpYWi9xCi0cGXlMAdoQLW4bohpOARonu7o4LfvsXPFSWKQNQ2tiRCSZI2DKH47Dte3j fszpNwgRabEVD2FOSFltD30JloJ17J92abEMtg0F8Oj8ENWCFaEo4rTBAvRU/9diWrAS s5xE8MN/5GtZq50DopFIjfzMK3unX0p9hEKBxJ13sUKOxkp9LC0IBzZCqeFC4cuRzfGk SqKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Ad6qNuVd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l13-20020a056402254d00b00460ce6c3a1asi2941134edb.454.2022.10.29.14.48.10; Sat, 29 Oct 2022 14:48:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=Ad6qNuVd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S229695AbiJ2VlJ (ORCPT <rfc822;ezelljr.billy@gmail.com> + 99 others); Sat, 29 Oct 2022 17:41:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbiJ2VlH (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 29 Oct 2022 17:41:07 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF300C7; Sat, 29 Oct 2022 14:41:05 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id 3-20020a17090a0f8300b00212d5cd4e5eso12836411pjz.4; Sat, 29 Oct 2022 14:41:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/861UoRf3F+2YILewsi3E4Q/g8WnmJGSnP8oXVC9Ulo=; b=Ad6qNuVd703mDsl9h9ZAFsw+rsT5SEsCTchCIKfFP44Xw+gJ4ZfiSGIYWEhlj5L7Sx 2tpFfUK8v9ilSz10X4y5m7vL+RN7tmz8XEIySk2o7ZVIxe72uDQTBOP63kf/83y7hpiF bryuzIiGOO3huvQOXoDCZecEV7CTb6OS8uaAhP0NdeAB9vI3Avs1I+3LOwUPf9gTUJg+ mdHCwIGiHP2idwSOiSFMdRqSmo0kYVClECsemKd44LEYQn5IzFPe/vZnKqlkQpAIiwnz Y41wH/aOcqn5m0P3Kwji/Bn7zMWI+56Qx6BRfY4d1zonOslZfhsDPIosTEo+fE9YsJfr tSfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/861UoRf3F+2YILewsi3E4Q/g8WnmJGSnP8oXVC9Ulo=; b=cYlIm5XsoBqzmFsI+mS9pG8CWpVupsYvXYWb+L+kzx4yJO1e0htNoJeRQ+Vm9tyXZH SvK/IQtyIpNa1KJt4HeaVzeVSRxX56Aq2obnbS11Wi/tsWwFUFo16X7fMorrvqZ91AyK l5+6biPtZlaXFRo8bvdD3cqTgtzfPS1JaCO69FJB1g3l2PeYYMimFHTmoy8V8Lji4bmS Mz+RwewiKi6d44j64aFAOcbVMFrIxfG+0LuaPUbUS197IQwk6BtWjgO8QVdJ64F1ePjh fbWO9lgLztobzRscVIDfn3YVwNs3uIJ9PN1bC+jQYeXEGeN9gYdqhh2G+NtZkTyeNcRz q5bQ== X-Gm-Message-State: ACrzQf1yLhey2/DvQmmU3026rN9tQZhbx1o8U8AxCYM6LV6YkjdIGXIZ 1fSuf1ZYLWjR3rjXZvXfrIs= X-Received: by 2002:a17:90b:2751:b0:20a:e437:a9e8 with SMTP id qi17-20020a17090b275100b0020ae437a9e8mr23139521pjb.181.1667079665307; Sat, 29 Oct 2022 14:41:05 -0700 (PDT) Received: from uftrace.. ([14.5.161.231]) by smtp.gmail.com with ESMTPSA id 17-20020a17090a19d100b002036006d65bsm1448759pjj.39.2022.10.29.14.41.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 14:41:04 -0700 (PDT) From: Kang Minchul <tegongkang@gmail.com> To: Marcel Holtmann <marcel@holtmann.org>, Johan Hedberg <johan.hedberg@gmail.com>, Luiz Augusto von Dentz <luiz.dentz@gmail.com> Cc: "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, linux-bluetooth@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kang Minchul <tegongkang@gmail.com> Subject: [PATCH v2] Bluetooth: Use kzalloc instead of kmalloc/memset Date: Sun, 30 Oct 2022 06:40:58 +0900 Message-Id: <20221029214058.25159-1-tegongkang@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748060201745625635?= X-GMAIL-MSGID: =?utf-8?q?1748060201745625635?= |
Series |
[v2] Bluetooth: Use kzalloc instead of kmalloc/memset
|
|
Commit Message
Kang Minchul
Oct. 29, 2022, 9:40 p.m. UTC
This commit replace kmalloc + memset to kzalloc
for better code readability and simplicity.
Following messages are related cocci warnings.
WARNING: kzalloc should be used for d, instead of kmalloc/memset
Signed-off-by: Kang Minchul <tegongkang@gmail.com>
---
V1 -> V2: Change subject prefix
net/bluetooth/hci_conn.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
Comments
Dear Kang, Thank you for the patch. Am 29.10.22 um 23:40 schrieb Kang Minchul: > This commit replace kmalloc + memset to kzalloc replace*s* (Though starting with “This commit …” is redundant. > for better code readability and simplicity. > > Following messages are related cocci warnings. Maybe: This addresse the cocci warning below. > WARNING: kzalloc should be used for d, instead of kmalloc/memset > > Signed-off-by: Kang Minchul <tegongkang@gmail.com> > --- > V1 -> V2: Change subject prefix > > net/bluetooth/hci_conn.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c > index 7a59c4487050..287d313aa312 100644 > --- a/net/bluetooth/hci_conn.c > +++ b/net/bluetooth/hci_conn.c > @@ -824,11 +824,10 @@ static int hci_le_terminate_big(struct hci_dev *hdev, u8 big, u8 bis) > > bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", big, bis); > > - d = kmalloc(sizeof(*d), GFP_KERNEL); > + d = kzalloc(sizeof(*d), GFP_KERNEL); > if (!d) > return -ENOMEM; > > - memset(d, 0, sizeof(*d)); > d->big = big; > d->bis = bis; > > @@ -861,11 +860,10 @@ static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, u16 sync_handle) > > bt_dev_dbg(hdev, "big 0x%2.2x sync_handle 0x%4.4x", big, sync_handle); > > - d = kmalloc(sizeof(*d), GFP_KERNEL); > + d = kzalloc(sizeof(*d), GFP_KERNEL); > if (!d) > return -ENOMEM; > > - memset(d, 0, sizeof(*d)); > d->big = big; > d->sync_handle = sync_handle; Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> Kind regards, Paul
> Am 29.10.22 um 23:40 schrieb Kang Minchul: > > This commit replace kmalloc + memset to kzalloc > > replace*s* > > (Though starting with “This commit …” is redundant. > > > for better code readability and simplicity. > > > > Following messages are related cocci warnings. > > Maybe: This addresse the cocci warning below. > > > WARNING: kzalloc should be used for d, instead of kmalloc/memset > > > > Signed-off-by: Kang Minchul <tegongkang@gmail.com> > > --- > > V1 -> V2: Change subject prefix > > > > net/bluetooth/hci_conn.c | 6 ++---- > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c > > index 7a59c4487050..287d313aa312 100644 > > --- a/net/bluetooth/hci_conn.c > > +++ b/net/bluetooth/hci_conn.c > > @@ -824,11 +824,10 @@ static int hci_le_terminate_big(struct hci_dev *hdev, u8 big, u8 bis) > > > > bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", big, bis); > > > > - d = kmalloc(sizeof(*d), GFP_KERNEL); > > + d = kzalloc(sizeof(*d), GFP_KERNEL); > > if (!d) > > return -ENOMEM; > > > > - memset(d, 0, sizeof(*d)); > > d->big = big; > > d->bis = bis; > > > > @@ -861,11 +860,10 @@ static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, u16 sync_handle) > > > > bt_dev_dbg(hdev, "big 0x%2.2x sync_handle 0x%4.4x", big, sync_handle); > > > > - d = kmalloc(sizeof(*d), GFP_KERNEL); > > + d = kzalloc(sizeof(*d), GFP_KERNEL); > > if (!d) > > return -ENOMEM; > > > > - memset(d, 0, sizeof(*d)); > > d->big = big; > > d->sync_handle = sync_handle; > > Reviewed-by: Paul Menzel <pmenzel@molgen.mpg.de> > > > Kind regards, > > Paul Thank you so much for your feedback! Should I amend the previous commit message and resend PATCH v3? regards, Kang Minchul
I just amended the message and sent patch v3. Again, thanks for the feedback. regards, Kang Minchul
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 7a59c4487050..287d313aa312 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -824,11 +824,10 @@ static int hci_le_terminate_big(struct hci_dev *hdev, u8 big, u8 bis) bt_dev_dbg(hdev, "big 0x%2.2x bis 0x%2.2x", big, bis); - d = kmalloc(sizeof(*d), GFP_KERNEL); + d = kzalloc(sizeof(*d), GFP_KERNEL); if (!d) return -ENOMEM; - memset(d, 0, sizeof(*d)); d->big = big; d->bis = bis; @@ -861,11 +860,10 @@ static int hci_le_big_terminate(struct hci_dev *hdev, u8 big, u16 sync_handle) bt_dev_dbg(hdev, "big 0x%2.2x sync_handle 0x%4.4x", big, sync_handle); - d = kmalloc(sizeof(*d), GFP_KERNEL); + d = kzalloc(sizeof(*d), GFP_KERNEL); if (!d) return -ENOMEM; - memset(d, 0, sizeof(*d)); d->big = big; d->sync_handle = sync_handle;