常常發現有些人對於funcion的return value都不太理會,所以後來我就在function上面加上warn_unused_result這個attribute,當programmer沒有使用這個function的return value時,就會跳出warning,嚴格一點再加上-Werror就可以讓這些warning變成error。
GCC VERSION:4.5之原文
The warn_unused_result attribute causes a warning to be emitted if a caller of the function with this attribute does not use its return value. This is useful for functions where not checking the result is either a security problem or always a bug, such as realloc.