| .. | .. |
|---|
| 32 | 32 | * the structure version (product ID, see appldata_base.c) needs to be changed |
|---|
| 33 | 33 | * as well and all documentation and z/VM applications using it must be |
|---|
| 34 | 34 | * updated. |
|---|
| 35 | | - * |
|---|
| 36 | | - * The record layout is documented in the Linux for zSeries Device Drivers |
|---|
| 37 | | - * book: |
|---|
| 38 | | - * http://oss.software.ibm.com/developerworks/opensource/linux390/index.shtml |
|---|
| 39 | 35 | */ |
|---|
| 40 | 36 | struct appldata_os_per_cpu { |
|---|
| 41 | 37 | u32 per_cpu_user; /* timer ticks spent in user mode */ |
|---|
| .. | .. |
|---|
| 75 | 71 | (waiting for I/O) */ |
|---|
| 76 | 72 | |
|---|
| 77 | 73 | /* per cpu data */ |
|---|
| 78 | | - struct appldata_os_per_cpu os_cpu[0]; |
|---|
| 74 | + struct appldata_os_per_cpu os_cpu[]; |
|---|
| 79 | 75 | } __attribute__((packed)); |
|---|
| 80 | 76 | |
|---|
| 81 | 77 | static struct appldata_os_data *appldata_os_data; |
|---|
| .. | .. |
|---|
| 133 | 129 | |
|---|
| 134 | 130 | os_data->nr_cpus = j; |
|---|
| 135 | 131 | |
|---|
| 136 | | - new_size = sizeof(struct appldata_os_data) + |
|---|
| 137 | | - (os_data->nr_cpus * sizeof(struct appldata_os_per_cpu)); |
|---|
| 132 | + new_size = struct_size(os_data, os_cpu, os_data->nr_cpus); |
|---|
| 138 | 133 | if (ops.size != new_size) { |
|---|
| 139 | 134 | if (ops.active) { |
|---|
| 140 | 135 | rc = appldata_diag(APPLDATA_RECORD_OS_ID, |
|---|
| .. | .. |
|---|
| 169 | 164 | { |
|---|
| 170 | 165 | int rc, max_size; |
|---|
| 171 | 166 | |
|---|
| 172 | | - max_size = sizeof(struct appldata_os_data) + |
|---|
| 173 | | - (num_possible_cpus() * sizeof(struct appldata_os_per_cpu)); |
|---|
| 167 | + max_size = struct_size(appldata_os_data, os_cpu, num_possible_cpus()); |
|---|
| 174 | 168 | if (max_size > APPLDATA_MAX_REC_SIZE) { |
|---|
| 175 | 169 | pr_err("Maximum OS record size %i exceeds the maximum " |
|---|
| 176 | 170 | "record size %i\n", max_size, APPLDATA_MAX_REC_SIZE); |
|---|