[PATCH] autobrightness: fix calloc argument order for GCC 15 compatibility

Ivan Hu ivan.hu at canonical.com
Fri May 23 03:58:56 UTC 2025


BugLink: https://bugs.launchpad.net/fwts/+bug/2110601

Fix a build failure with GCC 15 caused by incorrect argument order in calloc().
The first argument should be the number of elements, and the second the size of
each element.
With the wrong arguments, got the GCC 15 build fail below,
acpi/brightness/autobrightness.c: In function ‘auto_brightness_test2’:
acpi/brightness/autobrightness.c:134:49: error: ‘calloc’ sizes specified with ‘sizeof’ in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
  134 | brightness_fail = calloc(sizeof(bool), max_brightness + 1);
      | ^~~~
acpi/brightness/autobrightness.c:134:49: note: earlier argument should specify number of elements, later size of each element
cc1: all warnings being treated as errors

Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
---
 src/acpi/brightness/autobrightness.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/acpi/brightness/autobrightness.c b/src/acpi/brightness/autobrightness.c
index 6734db20..174936dd 100644
--- a/src/acpi/brightness/autobrightness.c
+++ b/src/acpi/brightness/autobrightness.c
@@ -131,7 +131,7 @@ static int auto_brightness_test2(fwts_framework *fw)
 			continue;
 		}
 
-		brightness_fail = calloc(sizeof(bool), max_brightness + 1);
+		brightness_fail = calloc(max_brightness + 1, sizeof(bool));
 		if (brightness_fail == NULL) {
 			fwts_log_error(fw, "Cannot allocate brightness table.");
 			continue;
-- 
2.34.1




More information about the fwts-devel mailing list