lkml.org 
[lkml]   [2022]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectIs 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
\
 
 \ /
  Last update: 2022-07-15 00:01    [W:0.597 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site