Commit 1d969d8
committed
pmbus: fix scaling possible bug
The scaling logic can be incorrect. When exp5 >= 0, the condition (1 << (-exp5))
attempts a left shift with a negative value, which is undefined behavior.
The logic should be inverted: when exp5 is negative, use (1 << (-exp5)),
and when positive, use division.
The simplest option is to use math.h's ldexp(). It seems it does not
require libm.1 parent 442669a commit 1d969d8
1 file changed
+5
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
97 | 98 | | |
98 | 99 | | |
99 | 100 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 101 | + | |
| 102 | + | |
103 | 103 | | |
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
107 | | - | |
108 | | - | |
| 107 | + | |
| 108 | + | |
109 | 109 | | |
110 | 110 | | |
111 | 111 | | |
| |||
0 commit comments