Skip to content

Commit 5e54510

Browse files
GustavoARSilvakees
authored andcommitted
acpi: nfit: intel: avoid multiple -Wflex-array-member-not-at-end warnings
-Wflex-array-member-not-at-end was introduced in GCC-14, and we are getting ready to enable it, globally. Use the new TRAILING_OVERLAP() helper to fix a dozen instances of the following type of warning: drivers/acpi/nfit/intel.c:692:35: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] Acked-by: Dan Williams <[email protected]> Tested-by: Dan Williams <[email protected]> Signed-off-by: Gustavo A. R. Silva <[email protected]> Link: https://lore.kernel.org/r/aF7pF4kej8VQapyR@kspp Signed-off-by: Kees Cook <[email protected]>
1 parent 29bb79e commit 5e54510

File tree

1 file changed

+52
-67
lines changed

1 file changed

+52
-67
lines changed

drivers/acpi/nfit/intel.c

Lines changed: 52 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,9 @@ static unsigned long intel_security_flags(struct nvdimm *nvdimm,
5555
{
5656
struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
5757
unsigned long security_flags = 0;
58-
struct {
59-
struct nd_cmd_pkg pkg;
58+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
6059
struct nd_intel_get_security_state cmd;
61-
} nd_cmd = {
60+
) nd_cmd = {
6261
.pkg = {
6362
.nd_command = NVDIMM_INTEL_GET_SECURITY_STATE,
6463
.nd_family = NVDIMM_FAMILY_INTEL,
@@ -120,10 +119,9 @@ static unsigned long intel_security_flags(struct nvdimm *nvdimm,
120119
static int intel_security_freeze(struct nvdimm *nvdimm)
121120
{
122121
struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
123-
struct {
124-
struct nd_cmd_pkg pkg;
122+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
125123
struct nd_intel_freeze_lock cmd;
126-
} nd_cmd = {
124+
) nd_cmd = {
127125
.pkg = {
128126
.nd_command = NVDIMM_INTEL_FREEZE_LOCK,
129127
.nd_family = NVDIMM_FAMILY_INTEL,
@@ -153,10 +151,9 @@ static int intel_security_change_key(struct nvdimm *nvdimm,
153151
unsigned int cmd = ptype == NVDIMM_MASTER ?
154152
NVDIMM_INTEL_SET_MASTER_PASSPHRASE :
155153
NVDIMM_INTEL_SET_PASSPHRASE;
156-
struct {
157-
struct nd_cmd_pkg pkg;
154+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
158155
struct nd_intel_set_passphrase cmd;
159-
} nd_cmd = {
156+
) nd_cmd = {
160157
.pkg = {
161158
.nd_family = NVDIMM_FAMILY_INTEL,
162159
.nd_size_in = ND_INTEL_PASSPHRASE_SIZE * 2,
@@ -195,10 +192,9 @@ static int __maybe_unused intel_security_unlock(struct nvdimm *nvdimm,
195192
const struct nvdimm_key_data *key_data)
196193
{
197194
struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
198-
struct {
199-
struct nd_cmd_pkg pkg;
195+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
200196
struct nd_intel_unlock_unit cmd;
201-
} nd_cmd = {
197+
) nd_cmd = {
202198
.pkg = {
203199
.nd_command = NVDIMM_INTEL_UNLOCK_UNIT,
204200
.nd_family = NVDIMM_FAMILY_INTEL,
@@ -234,10 +230,9 @@ static int intel_security_disable(struct nvdimm *nvdimm,
234230
{
235231
int rc;
236232
struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
237-
struct {
238-
struct nd_cmd_pkg pkg;
233+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
239234
struct nd_intel_disable_passphrase cmd;
240-
} nd_cmd = {
235+
) nd_cmd = {
241236
.pkg = {
242237
.nd_command = NVDIMM_INTEL_DISABLE_PASSPHRASE,
243238
.nd_family = NVDIMM_FAMILY_INTEL,
@@ -277,10 +272,9 @@ static int __maybe_unused intel_security_erase(struct nvdimm *nvdimm,
277272
struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
278273
unsigned int cmd = ptype == NVDIMM_MASTER ?
279274
NVDIMM_INTEL_MASTER_SECURE_ERASE : NVDIMM_INTEL_SECURE_ERASE;
280-
struct {
281-
struct nd_cmd_pkg pkg;
275+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
282276
struct nd_intel_secure_erase cmd;
283-
} nd_cmd = {
277+
) nd_cmd = {
284278
.pkg = {
285279
.nd_family = NVDIMM_FAMILY_INTEL,
286280
.nd_size_in = ND_INTEL_PASSPHRASE_SIZE,
@@ -318,10 +312,9 @@ static int __maybe_unused intel_security_query_overwrite(struct nvdimm *nvdimm)
318312
{
319313
int rc;
320314
struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
321-
struct {
322-
struct nd_cmd_pkg pkg;
315+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
323316
struct nd_intel_query_overwrite cmd;
324-
} nd_cmd = {
317+
) nd_cmd = {
325318
.pkg = {
326319
.nd_command = NVDIMM_INTEL_QUERY_OVERWRITE,
327320
.nd_family = NVDIMM_FAMILY_INTEL,
@@ -354,10 +347,9 @@ static int __maybe_unused intel_security_overwrite(struct nvdimm *nvdimm,
354347
{
355348
int rc;
356349
struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
357-
struct {
358-
struct nd_cmd_pkg pkg;
350+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
359351
struct nd_intel_overwrite cmd;
360-
} nd_cmd = {
352+
) nd_cmd = {
361353
.pkg = {
362354
.nd_command = NVDIMM_INTEL_OVERWRITE,
363355
.nd_family = NVDIMM_FAMILY_INTEL,
@@ -407,10 +399,9 @@ const struct nvdimm_security_ops *intel_security_ops = &__intel_security_ops;
407399
static int intel_bus_fwa_businfo(struct nvdimm_bus_descriptor *nd_desc,
408400
struct nd_intel_bus_fw_activate_businfo *info)
409401
{
410-
struct {
411-
struct nd_cmd_pkg pkg;
402+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
412403
struct nd_intel_bus_fw_activate_businfo cmd;
413-
} nd_cmd = {
404+
) nd_cmd = {
414405
.pkg = {
415406
.nd_command = NVDIMM_BUS_INTEL_FW_ACTIVATE_BUSINFO,
416407
.nd_family = NVDIMM_BUS_FAMILY_INTEL,
@@ -518,33 +509,31 @@ static enum nvdimm_fwa_capability intel_bus_fwa_capability(
518509
static int intel_bus_fwa_activate(struct nvdimm_bus_descriptor *nd_desc)
519510
{
520511
struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc);
521-
struct {
522-
struct nd_cmd_pkg pkg;
512+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
523513
struct nd_intel_bus_fw_activate cmd;
524-
} nd_cmd = {
525-
.pkg = {
526-
.nd_command = NVDIMM_BUS_INTEL_FW_ACTIVATE,
527-
.nd_family = NVDIMM_BUS_FAMILY_INTEL,
528-
.nd_size_in = sizeof(nd_cmd.cmd.iodev_state),
529-
.nd_size_out =
530-
sizeof(struct nd_intel_bus_fw_activate),
531-
.nd_fw_size =
532-
sizeof(struct nd_intel_bus_fw_activate),
533-
},
514+
) nd_cmd;
515+
int rc;
516+
517+
nd_cmd.pkg = (struct nd_cmd_pkg) {
518+
.nd_command = NVDIMM_BUS_INTEL_FW_ACTIVATE,
519+
.nd_family = NVDIMM_BUS_FAMILY_INTEL,
520+
.nd_size_in = sizeof(nd_cmd.cmd.iodev_state),
521+
.nd_size_out =
522+
sizeof(struct nd_intel_bus_fw_activate),
523+
.nd_fw_size =
524+
sizeof(struct nd_intel_bus_fw_activate),
525+
};
526+
nd_cmd.cmd = (struct nd_intel_bus_fw_activate) {
534527
/*
535528
* Even though activate is run from a suspended context,
536529
* for safety, still ask platform firmware to force
537530
* quiesce devices by default. Let a module
538531
* parameter override that policy.
539532
*/
540-
.cmd = {
541-
.iodev_state = acpi_desc->fwa_noidle
542-
? ND_INTEL_BUS_FWA_IODEV_OS_IDLE
543-
: ND_INTEL_BUS_FWA_IODEV_FORCE_IDLE,
544-
},
533+
.iodev_state = acpi_desc->fwa_noidle
534+
? ND_INTEL_BUS_FWA_IODEV_OS_IDLE
535+
: ND_INTEL_BUS_FWA_IODEV_FORCE_IDLE,
545536
};
546-
int rc;
547-
548537
switch (intel_bus_fwa_state(nd_desc)) {
549538
case NVDIMM_FWA_ARMED:
550539
case NVDIMM_FWA_ARM_OVERFLOW:
@@ -582,10 +571,9 @@ const struct nvdimm_bus_fw_ops *intel_bus_fw_ops = &__intel_bus_fw_ops;
582571
static int intel_fwa_dimminfo(struct nvdimm *nvdimm,
583572
struct nd_intel_fw_activate_dimminfo *info)
584573
{
585-
struct {
586-
struct nd_cmd_pkg pkg;
574+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
587575
struct nd_intel_fw_activate_dimminfo cmd;
588-
} nd_cmd = {
576+
) nd_cmd = {
589577
.pkg = {
590578
.nd_command = NVDIMM_INTEL_FW_ACTIVATE_DIMMINFO,
591579
.nd_family = NVDIMM_FAMILY_INTEL,
@@ -688,27 +676,24 @@ static int intel_fwa_arm(struct nvdimm *nvdimm, enum nvdimm_fwa_trigger arm)
688676
{
689677
struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm);
690678
struct acpi_nfit_desc *acpi_desc = nfit_mem->acpi_desc;
691-
struct {
692-
struct nd_cmd_pkg pkg;
679+
TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload,
693680
struct nd_intel_fw_activate_arm cmd;
694-
} nd_cmd = {
695-
.pkg = {
696-
.nd_command = NVDIMM_INTEL_FW_ACTIVATE_ARM,
697-
.nd_family = NVDIMM_FAMILY_INTEL,
698-
.nd_size_in = sizeof(nd_cmd.cmd.activate_arm),
699-
.nd_size_out =
700-
sizeof(struct nd_intel_fw_activate_arm),
701-
.nd_fw_size =
702-
sizeof(struct nd_intel_fw_activate_arm),
703-
},
704-
.cmd = {
705-
.activate_arm = arm == NVDIMM_FWA_ARM
706-
? ND_INTEL_DIMM_FWA_ARM
707-
: ND_INTEL_DIMM_FWA_DISARM,
708-
},
709-
};
681+
) nd_cmd;
710682
int rc;
711683

684+
nd_cmd.pkg = (struct nd_cmd_pkg) {
685+
.nd_command = NVDIMM_INTEL_FW_ACTIVATE_ARM,
686+
.nd_family = NVDIMM_FAMILY_INTEL,
687+
.nd_size_in = sizeof(nd_cmd.cmd.activate_arm),
688+
.nd_size_out = sizeof(struct nd_intel_fw_activate_arm),
689+
.nd_fw_size = sizeof(struct nd_intel_fw_activate_arm),
690+
};
691+
nd_cmd.cmd = (struct nd_intel_fw_activate_arm) {
692+
.activate_arm = arm == NVDIMM_FWA_ARM ?
693+
ND_INTEL_DIMM_FWA_ARM :
694+
ND_INTEL_DIMM_FWA_DISARM,
695+
};
696+
712697
switch (intel_fwa_state(nvdimm)) {
713698
case NVDIMM_FWA_INVALID:
714699
return -ENXIO;

0 commit comments

Comments
 (0)