diff options
author | Roland Dreier <rolandd@cisco.com> | 2010-05-26 16:15:06 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2010-05-26 16:15:06 -0400 |
commit | f27ec1d6db4aa3348ca7be896f1466599aecea3e (patch) | |
tree | aac2df369645a816fbfb81ee3e89ab52ad8d6423 /drivers/infiniband | |
parent | 7e3a1f4ab1a550dd6cf62a23aabedbad0d23e2d7 (diff) |
IB/qib: Don't rely on (undefined) order of function parameter evaluation
Some of the qib sysfs code passes a buffer pointer into
simple_read_from_buffer() but relies on a function call in another
parameter of the same call to initialize that pointer. Since the order
of evaluation of function parameters is undefined, this will break if
gcc chooses the wrong order.
Fix this by splitting the code into two separate function calls.
This was noticed because of warnings like the following on ppc:
drivers/infiniband/hw/qib/qib_fs.c: In function 'portcntrs_2_read':
drivers/infiniband/hw/qib/qib_fs.c:203: warning: 'counters' is used uninitialized in this function
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/qib/qib_fs.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c index 755470440ef1..edef8527eb34 100644 --- a/drivers/infiniband/hw/qib/qib_fs.c +++ b/drivers/infiniband/hw/qib/qib_fs.c | |||
@@ -144,10 +144,11 @@ static ssize_t dev_counters_read(struct file *file, char __user *buf, | |||
144 | size_t count, loff_t *ppos) | 144 | size_t count, loff_t *ppos) |
145 | { | 145 | { |
146 | u64 *counters; | 146 | u64 *counters; |
147 | size_t avail; | ||
147 | struct qib_devdata *dd = private2dd(file); | 148 | struct qib_devdata *dd = private2dd(file); |
148 | 149 | ||
149 | return simple_read_from_buffer(buf, count, ppos, counters, | 150 | avail = dd->f_read_cntrs(dd, *ppos, NULL, &counters); |
150 | dd->f_read_cntrs(dd, *ppos, NULL, &counters)); | 151 | return simple_read_from_buffer(buf, count, ppos, counters, avail); |
151 | } | 152 | } |
152 | 153 | ||
153 | /* read the per-device counters */ | 154 | /* read the per-device counters */ |
@@ -155,10 +156,11 @@ static ssize_t dev_names_read(struct file *file, char __user *buf, | |||
155 | size_t count, loff_t *ppos) | 156 | size_t count, loff_t *ppos) |
156 | { | 157 | { |
157 | char *names; | 158 | char *names; |
159 | size_t avail; | ||
158 | struct qib_devdata *dd = private2dd(file); | 160 | struct qib_devdata *dd = private2dd(file); |
159 | 161 | ||
160 | return simple_read_from_buffer(buf, count, ppos, names, | 162 | avail = dd->f_read_cntrs(dd, *ppos, &names, NULL); |
161 | dd->f_read_cntrs(dd, *ppos, &names, NULL)); | 163 | return simple_read_from_buffer(buf, count, ppos, names, avail); |
162 | } | 164 | } |
163 | 165 | ||
164 | static const struct file_operations cntr_ops[] = { | 166 | static const struct file_operations cntr_ops[] = { |
@@ -176,10 +178,11 @@ static ssize_t portnames_read(struct file *file, char __user *buf, | |||
176 | size_t count, loff_t *ppos) | 178 | size_t count, loff_t *ppos) |
177 | { | 179 | { |
178 | char *names; | 180 | char *names; |
181 | size_t avail; | ||
179 | struct qib_devdata *dd = private2dd(file); | 182 | struct qib_devdata *dd = private2dd(file); |
180 | 183 | ||
181 | return simple_read_from_buffer(buf, count, ppos, names, | 184 | avail = dd->f_read_portcntrs(dd, *ppos, 0, &names, NULL); |
182 | dd->f_read_portcntrs(dd, *ppos, 0, &names, NULL)); | 185 | return simple_read_from_buffer(buf, count, ppos, names, avail); |
183 | } | 186 | } |
184 | 187 | ||
185 | /* read the per-port counters for port 1 (pidx 0) */ | 188 | /* read the per-port counters for port 1 (pidx 0) */ |
@@ -187,10 +190,11 @@ static ssize_t portcntrs_1_read(struct file *file, char __user *buf, | |||
187 | size_t count, loff_t *ppos) | 190 | size_t count, loff_t *ppos) |
188 | { | 191 | { |
189 | u64 *counters; | 192 | u64 *counters; |
193 | size_t avail; | ||
190 | struct qib_devdata *dd = private2dd(file); | 194 | struct qib_devdata *dd = private2dd(file); |
191 | 195 | ||
192 | return simple_read_from_buffer(buf, count, ppos, counters, | 196 | avail = dd->f_read_portcntrs(dd, *ppos, 0, NULL, &counters); |
193 | dd->f_read_portcntrs(dd, *ppos, 0, NULL, &counters)); | 197 | return simple_read_from_buffer(buf, count, ppos, counters, avail); |
194 | } | 198 | } |
195 | 199 | ||
196 | /* read the per-port counters for port 2 (pidx 1) */ | 200 | /* read the per-port counters for port 2 (pidx 1) */ |
@@ -198,10 +202,11 @@ static ssize_t portcntrs_2_read(struct file *file, char __user *buf, | |||
198 | size_t count, loff_t *ppos) | 202 | size_t count, loff_t *ppos) |
199 | { | 203 | { |
200 | u64 *counters; | 204 | u64 *counters; |
205 | size_t avail; | ||
201 | struct qib_devdata *dd = private2dd(file); | 206 | struct qib_devdata *dd = private2dd(file); |
202 | 207 | ||
203 | return simple_read_from_buffer(buf, count, ppos, counters, | 208 | avail = dd->f_read_portcntrs(dd, *ppos, 1, NULL, &counters); |
204 | dd->f_read_portcntrs(dd, *ppos, 1, NULL, &counters)); | 209 | return simple_read_from_buffer(buf, count, ppos, counters, avail); |
205 | } | 210 | } |
206 | 211 | ||
207 | static const struct file_operations portcntr_ops[] = { | 212 | static const struct file_operations portcntr_ops[] = { |