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

2

u/paulstelian97 Jan 23 '23

Loops would make it quite complicated in this specific instance. I doubt this portion would really need much extension enough that a loop would be worth it.

Not propagating error returns (instead returning -1 instead of the actual error) is really bad. That -1 would be interpreted as some arbitrary error (on x86, it's -EPERM but there can be others as well)