Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp119506imw; Thu, 14 Jul 2022 22:29:51 -0700 (PDT) X-Google-Smtp-Source: AGRyM1unBLFJR7K8+lKmlP7oLxT/qc1YStYqjXD9VyXedw/l03ZwQ00te/JrZ58Ysvny6Nm6Zq90 X-Received: by 2002:a63:1f18:0:b0:414:f515:dc93 with SMTP id f24-20020a631f18000000b00414f515dc93mr10584660pgf.443.1657862991145; Thu, 14 Jul 2022 22:29:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657862991; cv=none; d=google.com; s=arc-20160816; b=nKNAY/xZN3ekj7HzLzgaY+YiD/btFGv8gC3Lo1JOGVLdEXehnv9GTwQkAHI9w5WSTx P8xTdDGT8CFNVQrD2Ke9GMYRM8/RTldz4/+Y4U+5rq5LW5+tUuNq3XsJXalG5jGDJAzB wzXdDQh79jWGD0ed0AOJ3tnBHXuzdEzAB0c7vKegampxeQWbsxTPZuIpLIeGXS2xAIvH tgYi13Jw+go36bjXJBcJf137uLIS4lWXjfXFzk2t/lxHTuqu1fJ4fy7trdxwYghcfHlG hpzceeAJIZCpwHH58ytoCDSirr74kRzmAgI8ucBxT8upM7OEWKH0dVSZiENUcRQgQ2r3 ef7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=zO43hikXt0XV2hT6fYiuYzmsqvmr44gi7YAHVOdw6qY=; b=Jf3at7et/1lYED6S2APKxqND3zQ0lijfqAHpCtDHwtwcFfLM45IjQZsd8FMkZTV5q6 7ItJju2uHQXwAxYxIfi21DR+XtlcLZPrqRVmgvwltflqbtnkCHgQR0i7fmlUuCfPieID SQ/W5lRjQKDfiAFVQl1Xbi9bMPd4TTlIMD5nuUXmfPk0SgP4dsm7UIQZJaaL4gTboAlb K3HiPKm2+zQ1LakGWWAbKoWF4AoEWwgl6TyGe8AgPcHc/D8/4eecDdeZPJCTgPAhKKC0 T2ga8YpAg6o6/3B40ejcZMMLaw27hurfv0eXpmfJ0ErrY4pQCnZvXADmiKSkgYz03WoO dpDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@inria.fr header.s=dc header.b=Ujpob+ad; 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=NONE dis=NONE) header.from=inria.fr Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oa3-20020a17090b1bc300b001ef826b9223si5060877pjb.153.2022.07.14.22.29.36; Thu, 14 Jul 2022 22:29:51 -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=@inria.fr header.s=dc header.b=Ujpob+ad; 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=NONE dis=NONE) header.from=inria.fr Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229617AbiGOFU2 (ORCPT + 99 others); Fri, 15 Jul 2022 01:20:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229492AbiGOFUY (ORCPT ); Fri, 15 Jul 2022 01:20:24 -0400 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05BF3796A3; Thu, 14 Jul 2022 22:20:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=zO43hikXt0XV2hT6fYiuYzmsqvmr44gi7YAHVOdw6qY=; b=Ujpob+adTWG6OU7Rjosi+l0EP6AZRUFKPAvJG9QJnPKKLflW7e5U8Lve xsfqeF/zLzruSSAYdlKuG84punOx5Jw8zDC9lPwdzpOWjwn5gNTc9l4fX JFKbwj9GVh3hxIQAaXjqFXx5TiXlcQS5BiOGoS/4AyV3LK9+VP/GaMnHO Q=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=julia.lawall@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="5.92,272,1650924000"; d="scan'208";a="19373232" Received: from 150.122.68.85.rev.sfr.net (HELO hadrien) ([85.68.122.150]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jul 2022 07:20:21 +0200 Date: Fri, 15 Jul 2022 07:20:19 +0200 (CEST) From: Julia Lawall X-X-Sender: jll@hadrien To: Steve French cc: LKML , kernel-janitors , Yu Zhe Subject: Re: Is casting a void ptr to something else considered bad kernel coding style In-Reply-To: Message-ID: References: User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org On Thu, 14 Jul 2022, Steve French wrote: > For examples like this where a pointer which is (void *) is cast to > something else, is this considered bad coding style in kernel C > programming? > > It may be that leaving the (unnecessary) cast in, although it is not > required for C, makes the code clearer in some cases. > > Any opinions on changes to remove casts of void pointers for kernel > code (which I have recently seen suggested)? > > for example: > > --- a/fs/cifs/smb2pdu.c > +++ b/fs/cifs/smb2pdu.c > @@ -354,7 +354,7 @@ fill_small_buf(__le16 smb2_command, struct cifs_tcon *tcon, > void *buf, > unsigned int *total_len) > { > - struct smb2_pdu *spdu = (struct smb2_pdu *)buf; > + struct smb2_pdu *spdu = buf; There would seem to be not much point to this (the original cast), since the type is immediately explicit in the variable declaration. It would also make for tiresome editing if the type should change, and it reduces readability by adding a lot of characters that don't give useful information. julia