contrib/plugins/execlog.c: warning: passing argument 2 of ‘g_ptr_array_add’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] Description of problem: Hit some warning messages when compiling upstream qemu Steps to reproduce: 1. Clone repo and compile it 1.1 git clone https://gitlab.com/qemu-project/qemu.git 1.2 mkdir build 1.3 cd build/ 1.4 ../configure --target-list=x86_64-softmmu --enable-debug-info 1.5 make 2. It will print the following warning messages: ``` [2767/2767] Linking target tests/qtest/netdev-socket /root/qemu/contrib/plugins/execlog.c: In function ‘registers_init’: /root/qemu/contrib/plugins/execlog.c:339:63: warning: passing argument 2 of ‘g_ptr_array_add’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 339 | g_ptr_array_add(all_reg_names, reg->name); | ~~~^~~~~~ In file included from /usr/include/glib-2.0/glib.h:31, from /root/qemu/contrib/plugins/execlog.c:9: /usr/include/glib-2.0/glib/garray.h:192:62: note: expected ‘gpointer’ {aka ‘void *’} but argument is of type ‘const char *’ 192 | gpointer data); | ~~~~~~~~~~~~~~~~~~^~~~ ``` Additional information: 1. After Eugenio Perez Martin (eperezma@redhat.com) debug, we found this problem introduced by this commit: ``` commit af6e4e0a22c18a7cc97650caec56ed99c9899dd7 Author: Alex Bennée Date: Tue Feb 27 14:43:32 2024 +0000 contrib/plugins: extend execlog to track register changes ``` 2. The latest commit in my env: ``` commit db596ae19040574e41d086e78469014191d7d7fc (origin/staging, origin/master, origin/HEAD) Merge: 7d4e29ef80 7558300c53 Author: Peter Maydell Date: Tue Mar 5 13:54:54 2024 +0000 Merge tag 'pull-target-arm-20240305' of https://git.linaro.org/people/pmaydell/qemu-arm into staging target-arm queue: * raspi: Implement Broadcom Serial Controller (BSC) for BCM2835 boards * hw/char/pl011: Add support for loopback * STM32L4x5: Implement RCC clock control device * target/arm: Do memory type alignment checks * atomic.h: Reword confusing comment for qatomic_cmpxchg * qemu-options.hx: Don't claim "-serial" has limit of 4 serial ports ```