Reputation: 75
In this specific example, the code would be down_interruptible(&semaphore)
. down_interruptible returns an integer. Should the function still run appropriately despite no assignment for the return value, or does the lack of assignment cause the statement to be skipped altogether?
Upvotes: 0
Views: 70
Reputation: 23793
You are free to ignore a returned value in C (although it is considered bad practice in some cases, e.g. when an error code is returned), the function call will still be made.
Generally speaking, compiler are not permitted to remove code having observable side effects. (So technically speaking, if your function does nothing, the compiler could omit the call)
Upvotes: 1
Reputation: 103
Yes, unless it doesn't make any difference and the compiler finds it handy to optimize the program and cancel the function's call.
Upvotes: 0