Commit ba691d0
committed
Refactor comparison function to be branch-free
Refactored the 'cmp' function to use (a > b) - (a < b), making it
branch-free and reducing the risk of side-channel attacks caused by
branching.
Updated the function signature to match "qsort's" expected type,
eliminating the need for an explicit cast.
Change-Id: I296aa12a57e5b89abc39e6467183c8520c2d12481 parent 746c187 commit ba691d0
1 file changed
+5
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
| 71 | + | |
71 | 72 | | |
72 | | - | |
73 | | - | |
74 | | - | |
| 73 | + | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
86 | | - | |
| 85 | + | |
87 | 86 | | |
88 | 87 | | |
89 | 88 | | |
| |||
0 commit comments