Skip to content

Commit

Permalink
Fix timespec >= comparison operator.
Browse files Browse the repository at this point in the history
  • Loading branch information
dtzWill committed Mar 13, 2012
1 parent 40b2140 commit 14ed61b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/plugin/sdl/sdlcore_p.hpp
Expand Up @@ -39,7 +39,7 @@ inline bool operator>(const timespec &a, const timespec &b) {
return (b < a); return (b < a);
} }
inline bool operator>=(const timespec &a, const timespec &b) { inline bool operator>=(const timespec &a, const timespec &b) {
return (b >= a); return (b <= a);
} }


namespace SDL { namespace SDL {
Expand Down

2 comments on commit 14ed61b

@RyanHope
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you comment on why this was wrong

@dtzWill
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, should have done so originally, sorry!

As-is in master, it defines "a >= b" as "b >= a" which is both logically wrong and dangerously recursive.

The fix defines "a >= b" as "b <=a ", which is sound by itself, and re-uses the implementation of <=, as operator> uses the definition of <.

Please sign in to comment.