hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/s390/appldata/appldata_os.c
....@@ -32,10 +32,6 @@
3232 * the structure version (product ID, see appldata_base.c) needs to be changed
3333 * as well and all documentation and z/VM applications using it must be
3434 * 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
3935 */
4036 struct appldata_os_per_cpu {
4137 u32 per_cpu_user; /* timer ticks spent in user mode */
....@@ -75,7 +71,7 @@
7571 (waiting for I/O) */
7672
7773 /* per cpu data */
78
- struct appldata_os_per_cpu os_cpu[0];
74
+ struct appldata_os_per_cpu os_cpu[];
7975 } __attribute__((packed));
8076
8177 static struct appldata_os_data *appldata_os_data;
....@@ -133,8 +129,7 @@
133129
134130 os_data->nr_cpus = j;
135131
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);
138133 if (ops.size != new_size) {
139134 if (ops.active) {
140135 rc = appldata_diag(APPLDATA_RECORD_OS_ID,
....@@ -169,8 +164,7 @@
169164 {
170165 int rc, max_size;
171166
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());
174168 if (max_size > APPLDATA_MAX_REC_SIZE) {
175169 pr_err("Maximum OS record size %i exceeds the maximum "
176170 "record size %i\n", max_size, APPLDATA_MAX_REC_SIZE);