Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <dan.j.williams@intel.com>
Tested-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/aF7pF4kej8VQapyR@kspp
Signed-off-by: Kees Cook <kees@kernel.org>

authored by

Gustavo A. R. Silva and committed by
Kees Cook
5e54510a 29bb79e9

+52 -67
+52 -67
drivers/acpi/nfit/intel.c
··· 55 55 { 56 56 struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); 57 57 unsigned long security_flags = 0; 58 - struct { 59 - struct nd_cmd_pkg pkg; 58 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 60 59 struct nd_intel_get_security_state cmd; 61 - } nd_cmd = { 60 + ) nd_cmd = { 62 61 .pkg = { 63 62 .nd_command = NVDIMM_INTEL_GET_SECURITY_STATE, 64 63 .nd_family = NVDIMM_FAMILY_INTEL, ··· 119 120 static int intel_security_freeze(struct nvdimm *nvdimm) 120 121 { 121 122 struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); 122 - struct { 123 - struct nd_cmd_pkg pkg; 123 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 124 124 struct nd_intel_freeze_lock cmd; 125 - } nd_cmd = { 125 + ) nd_cmd = { 126 126 .pkg = { 127 127 .nd_command = NVDIMM_INTEL_FREEZE_LOCK, 128 128 .nd_family = NVDIMM_FAMILY_INTEL, ··· 151 153 unsigned int cmd = ptype == NVDIMM_MASTER ? 152 154 NVDIMM_INTEL_SET_MASTER_PASSPHRASE : 153 155 NVDIMM_INTEL_SET_PASSPHRASE; 154 - struct { 155 - struct nd_cmd_pkg pkg; 156 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 156 157 struct nd_intel_set_passphrase cmd; 157 - } nd_cmd = { 158 + ) nd_cmd = { 158 159 .pkg = { 159 160 .nd_family = NVDIMM_FAMILY_INTEL, 160 161 .nd_size_in = ND_INTEL_PASSPHRASE_SIZE * 2, ··· 192 195 const struct nvdimm_key_data *key_data) 193 196 { 194 197 struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); 195 - struct { 196 - struct nd_cmd_pkg pkg; 198 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 197 199 struct nd_intel_unlock_unit cmd; 198 - } nd_cmd = { 200 + ) nd_cmd = { 199 201 .pkg = { 200 202 .nd_command = NVDIMM_INTEL_UNLOCK_UNIT, 201 203 .nd_family = NVDIMM_FAMILY_INTEL, ··· 230 234 { 231 235 int rc; 232 236 struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); 233 - struct { 234 - struct nd_cmd_pkg pkg; 237 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 235 238 struct nd_intel_disable_passphrase cmd; 236 - } nd_cmd = { 239 + ) nd_cmd = { 237 240 .pkg = { 238 241 .nd_command = NVDIMM_INTEL_DISABLE_PASSPHRASE, 239 242 .nd_family = NVDIMM_FAMILY_INTEL, ··· 272 277 struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); 273 278 unsigned int cmd = ptype == NVDIMM_MASTER ? 274 279 NVDIMM_INTEL_MASTER_SECURE_ERASE : NVDIMM_INTEL_SECURE_ERASE; 275 - struct { 276 - struct nd_cmd_pkg pkg; 280 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 277 281 struct nd_intel_secure_erase cmd; 278 - } nd_cmd = { 282 + ) nd_cmd = { 279 283 .pkg = { 280 284 .nd_family = NVDIMM_FAMILY_INTEL, 281 285 .nd_size_in = ND_INTEL_PASSPHRASE_SIZE, ··· 312 318 { 313 319 int rc; 314 320 struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); 315 - struct { 316 - struct nd_cmd_pkg pkg; 321 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 317 322 struct nd_intel_query_overwrite cmd; 318 - } nd_cmd = { 323 + ) nd_cmd = { 319 324 .pkg = { 320 325 .nd_command = NVDIMM_INTEL_QUERY_OVERWRITE, 321 326 .nd_family = NVDIMM_FAMILY_INTEL, ··· 347 354 { 348 355 int rc; 349 356 struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); 350 - struct { 351 - struct nd_cmd_pkg pkg; 357 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 352 358 struct nd_intel_overwrite cmd; 353 - } nd_cmd = { 359 + ) nd_cmd = { 354 360 .pkg = { 355 361 .nd_command = NVDIMM_INTEL_OVERWRITE, 356 362 .nd_family = NVDIMM_FAMILY_INTEL, ··· 399 407 static int intel_bus_fwa_businfo(struct nvdimm_bus_descriptor *nd_desc, 400 408 struct nd_intel_bus_fw_activate_businfo *info) 401 409 { 402 - struct { 403 - struct nd_cmd_pkg pkg; 410 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 404 411 struct nd_intel_bus_fw_activate_businfo cmd; 405 - } nd_cmd = { 412 + ) nd_cmd = { 406 413 .pkg = { 407 414 .nd_command = NVDIMM_BUS_INTEL_FW_ACTIVATE_BUSINFO, 408 415 .nd_family = NVDIMM_BUS_FAMILY_INTEL, ··· 509 518 static int intel_bus_fwa_activate(struct nvdimm_bus_descriptor *nd_desc) 510 519 { 511 520 struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); 512 - struct { 513 - struct nd_cmd_pkg pkg; 521 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 514 522 struct nd_intel_bus_fw_activate cmd; 515 - } nd_cmd = { 516 - .pkg = { 517 - .nd_command = NVDIMM_BUS_INTEL_FW_ACTIVATE, 518 - .nd_family = NVDIMM_BUS_FAMILY_INTEL, 519 - .nd_size_in = sizeof(nd_cmd.cmd.iodev_state), 520 - .nd_size_out = 521 - sizeof(struct nd_intel_bus_fw_activate), 522 - .nd_fw_size = 523 - sizeof(struct nd_intel_bus_fw_activate), 524 - }, 523 + ) nd_cmd; 524 + int rc; 525 + 526 + nd_cmd.pkg = (struct nd_cmd_pkg) { 527 + .nd_command = NVDIMM_BUS_INTEL_FW_ACTIVATE, 528 + .nd_family = NVDIMM_BUS_FAMILY_INTEL, 529 + .nd_size_in = sizeof(nd_cmd.cmd.iodev_state), 530 + .nd_size_out = 531 + sizeof(struct nd_intel_bus_fw_activate), 532 + .nd_fw_size = 533 + sizeof(struct nd_intel_bus_fw_activate), 534 + }; 535 + nd_cmd.cmd = (struct nd_intel_bus_fw_activate) { 525 536 /* 526 537 * Even though activate is run from a suspended context, 527 538 * for safety, still ask platform firmware to force 528 539 * quiesce devices by default. Let a module 529 540 * parameter override that policy. 530 541 */ 531 - .cmd = { 532 - .iodev_state = acpi_desc->fwa_noidle 533 - ? ND_INTEL_BUS_FWA_IODEV_OS_IDLE 534 - : ND_INTEL_BUS_FWA_IODEV_FORCE_IDLE, 535 - }, 542 + .iodev_state = acpi_desc->fwa_noidle 543 + ? ND_INTEL_BUS_FWA_IODEV_OS_IDLE 544 + : ND_INTEL_BUS_FWA_IODEV_FORCE_IDLE, 536 545 }; 537 - int rc; 538 - 539 546 switch (intel_bus_fwa_state(nd_desc)) { 540 547 case NVDIMM_FWA_ARMED: 541 548 case NVDIMM_FWA_ARM_OVERFLOW: ··· 571 582 static int intel_fwa_dimminfo(struct nvdimm *nvdimm, 572 583 struct nd_intel_fw_activate_dimminfo *info) 573 584 { 574 - struct { 575 - struct nd_cmd_pkg pkg; 585 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 576 586 struct nd_intel_fw_activate_dimminfo cmd; 577 - } nd_cmd = { 587 + ) nd_cmd = { 578 588 .pkg = { 579 589 .nd_command = NVDIMM_INTEL_FW_ACTIVATE_DIMMINFO, 580 590 .nd_family = NVDIMM_FAMILY_INTEL, ··· 676 688 { 677 689 struct nfit_mem *nfit_mem = nvdimm_provider_data(nvdimm); 678 690 struct acpi_nfit_desc *acpi_desc = nfit_mem->acpi_desc; 679 - struct { 680 - struct nd_cmd_pkg pkg; 691 + TRAILING_OVERLAP(struct nd_cmd_pkg, pkg, nd_payload, 681 692 struct nd_intel_fw_activate_arm cmd; 682 - } nd_cmd = { 683 - .pkg = { 684 - .nd_command = NVDIMM_INTEL_FW_ACTIVATE_ARM, 685 - .nd_family = NVDIMM_FAMILY_INTEL, 686 - .nd_size_in = sizeof(nd_cmd.cmd.activate_arm), 687 - .nd_size_out = 688 - sizeof(struct nd_intel_fw_activate_arm), 689 - .nd_fw_size = 690 - sizeof(struct nd_intel_fw_activate_arm), 691 - }, 692 - .cmd = { 693 - .activate_arm = arm == NVDIMM_FWA_ARM 694 - ? ND_INTEL_DIMM_FWA_ARM 695 - : ND_INTEL_DIMM_FWA_DISARM, 696 - }, 697 - }; 693 + ) nd_cmd; 698 694 int rc; 695 + 696 + nd_cmd.pkg = (struct nd_cmd_pkg) { 697 + .nd_command = NVDIMM_INTEL_FW_ACTIVATE_ARM, 698 + .nd_family = NVDIMM_FAMILY_INTEL, 699 + .nd_size_in = sizeof(nd_cmd.cmd.activate_arm), 700 + .nd_size_out = sizeof(struct nd_intel_fw_activate_arm), 701 + .nd_fw_size = sizeof(struct nd_intel_fw_activate_arm), 702 + }; 703 + nd_cmd.cmd = (struct nd_intel_fw_activate_arm) { 704 + .activate_arm = arm == NVDIMM_FWA_ARM ? 705 + ND_INTEL_DIMM_FWA_ARM : 706 + ND_INTEL_DIMM_FWA_DISARM, 707 + }; 699 708 700 709 switch (intel_fwa_state(nvdimm)) { 701 710 case NVDIMM_FWA_INVALID: