Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1009781imw; Thu, 14 Jul 2022 15:25:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1srDxZnqHy8Nkpb2tXydrur94O9sZUGjxZ7tefLQho7DNQtiNIQd5qzDbj9AHaKTFNR1Wjg X-Received: by 2002:a05:6402:501d:b0:437:e000:a898 with SMTP id p29-20020a056402501d00b00437e000a898mr15470000eda.265.1657837508204; Thu, 14 Jul 2022 15:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657837508; cv=none; d=google.com; s=arc-20160816; b=1ExlfD/Sq7i2i8m5V+dEExWE4s+fUZvpVHz7Rb5I+f4U3LWwfzdWbE1GqqYqo9+seT T7A+iChDzLYdYxyW1SPwOh+it2yhlTSpVDVNZQJTvM9XymiB4xVhoCijxvH1C+q0QX91 vxemKPu1+WW1uFEHVIjtnTEW+la2asq53ecIbZcnr/hj25Yewk1/XtvsqxqJBKjlbo7Q Iq0M0x6gV6o6dCP0lCUnkAnseG8poaWiHxhGzkZIR0SZ1I8jqXOOYO65D7LAecj5WAkk cFJaCtyNqc6TRHTqkstUn+uEgJ957yHnFh3xQko9bvUhfUDxoJnH+tQAQPuw4KPEib2G YEGA== 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:mime-version :dkim-signature; bh=uqejFrrJQVrbf4+FczBPWjgqVBbsgKFGlzQ/n7XaL+o=; b=bviLVy39A1Arhy6gYZXzh+RzcOyK6IFysNYH4L+S1potjh+jDcitRuQEaK8xy+GDnz AXyVmwI3JhKWj80J8OnbPIENI3cR245TwTcpeGE2nXMz699ALOpLZzJQaAjbH8qW0cnA x3SdgF8P/Ud1abfZN0naTo92rdWu0sBo7T6vNF2Vx0PKbWyk/PkC5QUZ51BMoAEIABNU v9nuTSNTDf5tggrfSjWdJRv1IAHExnm4X3MMTNJElaoIMXT3uAVoek60TuOTMnEXAF3i 1MlYi3BgFzuidnx+y3CpSxMPR3bsHyO8hl6bQsd8ZH/WJXHCWh0nsi8OsSIq3fLvX7rD zhag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=NTBavKrn; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ee50-20020a056402293200b0043a78a87d80si3198689edb.252.2022.07.14.15.24.39; Thu, 14 Jul 2022 15:25:08 -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=NTBavKrn; 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 S240971AbiGNWAd (ORCPT + 99 others); Thu, 14 Jul 2022 18:00:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232682AbiGNWAb (ORCPT ); Thu, 14 Jul 2022 18:00:31 -0400 Received: from mail-vs1-xe2b.google.com (mail-vs1-xe2b.google.com [IPv6:2607:f8b0:4864:20::e2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E29C16717F; Thu, 14 Jul 2022 15:00:30 -0700 (PDT) Received: by mail-vs1-xe2b.google.com with SMTP id w188so2563842vsb.6; Thu, 14 Jul 2022 15:00:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to:cc; bh=uqejFrrJQVrbf4+FczBPWjgqVBbsgKFGlzQ/n7XaL+o=; b=NTBavKrnx6m3woTqnQo5hRe7P2v2aO74raMvzzh7stWSrpiCJ83EzlympvdjZm8d/m 3yznsW9R8LWrRn50menrhA24+Wp9/PmFw3rzkpiNLQmM04N7s55REOQ6C6bgPMcaaQkj v61IlqBR7Ekiu/Izu2oFBr0BMuQFwc8ao86eUCLQ549VjrdwfMolX5CI8jDz+ylXKwd3 eD6vBjYQngGX93RmUY7y/jjam/wpBsZNyU9DiD3WRQ0O+/HcJjpuuz1wJa1rq81qoB+/ x26m9Q3sgSTv6/4o6OGXGyjx9fxW+LWd/0X/c0UcREZjqvJPGrRMrukqv3s9/E5ihLIY HBOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=uqejFrrJQVrbf4+FczBPWjgqVBbsgKFGlzQ/n7XaL+o=; b=zkdvX0bzo02b5NqF7kLQQchqposFHcywSQ1nggyKGVbvKQtigvx6ftXmvWzFczqny0 FH7Jwl8824jaNFu3dVQt+7QOhnVHIVwJgRI0TXoKtqnkBVmuZaQUIzhb3fRaoLZtFZiD CHES62QO5WbitKudM4rTGzkWzFlAc9iHHe2VBJtQcnzlIQxnsVIF+llxARnqPHn3ICTr QoiR2OYcED1E6r0P+9DlMqAzSH7cu9XqimNnMtA6J8ETA4GEPFbojxNt3x/PCfvkvgC+ ZcblvZMw0iyprQTNHnyNI8kRi1pCotOeZv0w5hRYR1wkksyZoGcz+vnLSwd4QOcvgp8E BQVQ== X-Gm-Message-State: AJIora8IEKv0s9kL8mrXa7GYYf+qZ9MrQg/A1jZoe0R9u2KD1IpglcCy 667ROZI+cW6X63RvrJTNTRjahYwKDwzzHLsVdN7Vnl9GTAS1+Q== X-Received: by 2002:a67:6d86:0:b0:357:3d99:ec77 with SMTP id i128-20020a676d86000000b003573d99ec77mr4596119vsc.6.1657836029630; Thu, 14 Jul 2022 15:00:29 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Thu, 14 Jul 2022 17:00:19 -0500 Message-ID: Subject: Is casting a void ptr to something else considered bad kernel coding style To: LKML , kernel-janitors Cc: Yu Zhe 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,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 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; -- Thanks, Steve