lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH2r5msuc3-1V+dh5NdwnE6uBoN+7_cf=m6kwrFrTnwArND0LQ@mail.gmail.com>
Date:   Thu, 14 Jul 2022 17:00:19 -0500
From:   Steve French <smfrench@...il.com>
To:     LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors <kernel-janitors@...r.kernel.org>
Cc:     Yu Zhe <yuzhe@...china.com>
Subject: Is casting a void ptr to something else considered bad kernel coding style

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ