Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid comparison function #140

Closed
yugr opened this issue Jan 12, 2016 · 2 comments
Closed

Invalid comparison function #140

yugr opened this issue Jan 12, 2016 · 2 comments

Comments

@yugr
Copy link

yugr commented Jan 12, 2016

bs_cmp (from options.c) is passed to qsort to compare bssplit structures. But it does not satisfy qsort symmetry requirement i.e.
bs_cmp(a, b) != - bs_cmp(b, a)
This triggers UB at runtime and may cause qsort to fail to sort the array.

The fix should be as simple as replacing the current code with

  return (int)bsp1->perc - (int)->bsp2->perc;
@yugr
Copy link
Author

yugr commented Jan 12, 2016

The problem was found when running Phoronix under SortChecker tool (https://github.com/yugr/sortcheck).

@axboe
Copy link
Owner

axboe commented Jan 12, 2016

Indeed, should return int difference. Fix committed.

@axboe axboe closed this as completed Jan 12, 2016
janekmi pushed a commit to janekmi/fio that referenced this issue Jan 19, 2021
…t-cleanup

rpma: common: server_data, server_init & server_cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants