From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61634C07E9B for ; Sat, 10 Jul 2021 20:02:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 37DDD6128C for ; Sat, 10 Jul 2021 20:02:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231740AbhGJUFZ (ORCPT ); Sat, 10 Jul 2021 16:05:25 -0400 Received: from smtprelay0127.hostedemail.com ([216.40.44.127]:33510 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229515AbhGJUFZ (ORCPT ); Sat, 10 Jul 2021 16:05:25 -0400 Received: from omf08.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 06BE1182CED2A; Sat, 10 Jul 2021 20:02:39 +0000 (UTC) Received: from [HIDDEN] (Authenticated sender: joe@perches.com) by omf08.hostedemail.com (Postfix) with ESMTPA id 2B7C51A29F9; Sat, 10 Jul 2021 20:02:38 +0000 (UTC) Message-ID: Subject: Re: cocci script to convert linux-kernel allocs with BITS_TO_LONGS to bitmap_alloc From: Joe Perches To: Julia Lawall Cc: cocci , LKML , kernel-janitors@vger.kernel.org Date: Sat, 10 Jul 2021 13:02:36 -0700 In-Reply-To: References: <08b89608cfb1280624d1a89ead6547069f9a4c31.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.40.0-1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Stat-Signature: acaiyyzxzs3uxyr8edc374hez41ejw4g X-Rspamd-Server: rspamout01 X-Rspamd-Queue-Id: 2B7C51A29F9 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Session-ID: U2FsdGVkX1+IOF/X85f5HAaZl7mOKJZ2SwAmuy46KrU= X-HE-Tag: 1625947358-191922 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2021-07-10 at 21:50 +0200, Julia Lawall wrote: > On Fri, 9 Jul 2021, Joe Perches wrote: > > > Here is a cocci script to convert various types of bitmap allocations > > that use BITS_TO_LONGS to the more typical bitmap_alloc functions. > > > > Perhaps something like it could be added to scripts/coccinelle. > > The diff produced by the script is also below. > > > > $ cat bitmap_allocs.cocci > > // typical uses of bitmap allocations [] > > @@ > > expression val; > > expression e1; > > expression e2; > > @@ > > > > - val = kcalloc(BITS_TO_LONGS(e1), sizeof(*val), e2) > > + val = bitmap_zalloc(e1, e2) > > Is there something that guarantees that val has a type that has a size that > is the same as a long? no, but afaict, all do.