A number of coding style cleanups for the netcat kernel module #11

Merged
merged 10 commits into from Apr 23, 2014

Conversation

Projects
None yet
3 participants
@gregkh
Contributor

gregkh commented Apr 23, 2014

Some basic whitespace and other formatting tweaks to get the netcat kernel module
to abide by the basic Linux kernel coding style rules.

gregkh added some commits Apr 23, 2014

netcat.c: fix up basic whitespace issues
Linux kernel code has a specific style, so fix up the basic whitespace
issues here.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
netcat: use /* instead of // for comments
This is C, not C++

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
netcat: statics are always initialized to 0
So there's no need to do it again.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
netcat: init/exit module functions should be explicit.
Don't rely on the 2.2 module init function naming, tell the world
exactly what the module init/exit functions are, and make them static.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
netcat: other minor coding style tweaks
Some more whitespace cleanups to make the checkpatch.pl tool happy.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
@blucia0a

This comment has been minimized.

Show comment
Hide comment
@blucia0a

blucia0a Apr 23, 2014

Member

Thanks! Will test later today and merge these style changes in.

Member

blucia0a commented Apr 23, 2014

Thanks! Will test later today and merge these style changes in.

gregkh added some commits Apr 23, 2014

netcat: fix up "raw" printk messages
Use the "proper" pr_*() calls instead, which adds the format string
correectly.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
netcat: use named initializer for the minor device
Also put the mode in the initializer, no need to specify it later on.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
netcat: a module can not control its own reference count
If it tries to do its own reference count, it is too late, the race
could have already happened.  That's why the kernel does it
automatically for you if you set the .owner field in the fops structure,
so do that instead.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
netcat: of course "success" is 0, this is Linux!
0 is "good", -SOMETHING is always bad, no need to use a define for 0.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
@gregkh

This comment has been minimized.

Show comment
Hide comment
@gregkh

gregkh Apr 23, 2014

Contributor

Thanks. I can add multi-user playback pretty easily on top of this patch series, no need for static variables :)

Contributor

gregkh commented Apr 23, 2014

Thanks. I can add multi-user playback pretty easily on top of this patch series, no need for static variables :)

netcat: move variables around to avoid forward declarations
No need for forward declarations, just move the code around a bit,
saving us a number of lines.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
@mark-bl

This comment has been minimized.

Show comment
Hide comment
@mark-bl

mark-bl Apr 23, 2014

Contributor

After this pull request is accepted I can say I and @gregkh contributed to the same project.
For me that's a win :)

Contributor

mark-bl commented Apr 23, 2014

After this pull request is accepted I can say I and @gregkh contributed to the same project.
For me that's a win :)

blucia0a added a commit that referenced this pull request Apr 23, 2014

Merge pull request #11 from gregkh/codingstyle
A number of coding style cleanups for the netcat kernel module

@blucia0a blucia0a merged commit 0acca1a into usrbinnc:master Apr 23, 2014

@blucia0a

This comment has been minimized.

Show comment
Hide comment
@blucia0a

blucia0a Apr 23, 2014

Member

Thanks a lot, Greg! I would love to see how to enable multi-user playback. I haven't done much kernel hacking before, so just getting the original version built was a fun exercise.

Member

blucia0a commented Apr 23, 2014

Thanks a lot, Greg! I would love to see how to enable multi-user playback. I haven't done much kernel hacking before, so just getting the original version built was a fun exercise.

@gregkh

This comment has been minimized.

Show comment
Hide comment
@gregkh

gregkh Apr 23, 2014

Contributor

Ok, I'll work on it this afternoon, should make the code a bit simpler.

And for a "first time kernel module", it's a very nice job.

Contributor

gregkh commented Apr 23, 2014

Ok, I'll work on it this afternoon, should make the code a bit simpler.

And for a "first time kernel module", it's a very nice job.

@blucia0a

This comment has been minimized.

Show comment
Hide comment
@blucia0a

blucia0a Apr 23, 2014

Member

Thanks a lot! Glad to have your contributions to make our album release better!

Member

blucia0a commented Apr 23, 2014

Thanks a lot! Glad to have your contributions to make our album release better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment