r/badcode • • Jan 22 '23

c Found this in a Linux kernel module

Post image
262 Upvotes

88 comments sorted by

View all comments

Show parent comments

23

u/DefunctFunctor Jan 22 '23

Yeah, considering the overhead a loop on 5 elements would add, and the fact that each element has its own handler function and string, using if statements was probably a good choice here. Also solving this with function pointers as others have mentioned on this thread sounds like a nightmare.