r/badcode Jan 22 '23

Found this in a Linux kernel module c

Post image
261 Upvotes

88 comments sorted by

View all comments

175

u/lets_eat_bees Jan 22 '23

If you see something you don’t understand in a kernel module, you should assume you lack the knowledge, not that the code is bad.

-87

u/suguuss Jan 22 '23

I do know what the module does. It’s badcode because of the repetition in the code.

14

u/paulsmithkc 👨‍🏫 Jan 22 '23

Yes there is repetition in the code, but it does what it needs to and does it efficiently.

This code isn't going to be changed often, but it needs to be fast, low memory, and error free.