summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorFlorian Hofhammer <florian.hofhammer@fhofhammer.de>2026-01-19 14:18:12 +0100
committerPierrick Bouvier <pierrick.bouvier@linaro.org>2026-01-29 09:34:14 -0800
commitc22ea55b3be01b1798bc6b9cf1311d9a5e58c68b (patch)
treebc78bd0cb506620487dfba3ea2475085e37b6e27 /plugins
parent948ffdd79b78702239aace2d32d4f581913299b3 (diff)
downloadqemu-c22ea55b3be01b1798bc6b9cf1311d9a5e58c68b.tar.gz
qemu-c22ea55b3be01b1798bc6b9cf1311d9a5e58c68b.zip
plugins: return bool from register r/w API
The qemu_plugin_{read,write} register API previously was inconsistent with regard to its docstring (where a return value of both -1 and 0 would indicate an error) and to the memory read/write APIs, which already return a boolean value to indicate success or failure. Returning the number of bytes read or written is superfluous, as the GByteArray* passed to the API functions already encodes the length. See the linked thread for more details. This patch moves from returning an int (number of bytes read/written) to returning a bool from the register read/write API, bumps the plugin API version, and adjusts plugins and tests accordingly. Signed-off-by: Florian Hofhammer <florian.hofhammer@fhofhammer.de> Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Link: https://lore.kernel.org/qemu-devel/f877dd79-1285-4752-811e-f0d430ff27fe@fhofhammer.de Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Diffstat (limited to 'plugins')
-rw-r--r--plugins/api.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/plugins/api.c b/plugins/api.c
index 478d0c8889..04ca7da7f1 100644
--- a/plugins/api.c
+++ b/plugins/api.c
@@ -441,27 +441,28 @@ GArray *qemu_plugin_get_registers(void)
return create_register_handles(regs);
}
-int qemu_plugin_read_register(struct qemu_plugin_register *reg, GByteArray *buf)
+bool qemu_plugin_read_register(struct qemu_plugin_register *reg,
+ GByteArray *buf)
{
g_assert(current_cpu);
if (qemu_plugin_get_cb_flags() == QEMU_PLUGIN_CB_NO_REGS) {
- return -1;
+ return false;
}
- return gdb_read_register(current_cpu, buf, GPOINTER_TO_INT(reg) - 1);
+ return (gdb_read_register(current_cpu, buf, GPOINTER_TO_INT(reg) - 1) > 0);
}
-int qemu_plugin_write_register(struct qemu_plugin_register *reg,
- GByteArray *buf)
+bool qemu_plugin_write_register(struct qemu_plugin_register *reg,
+ GByteArray *buf)
{
g_assert(current_cpu);
if (buf->len == 0 || qemu_plugin_get_cb_flags() != QEMU_PLUGIN_CB_RW_REGS) {
- return -1;
+ return false;
}
- return gdb_write_register(current_cpu, buf->data, GPOINTER_TO_INT(reg) - 1);
+ return (gdb_write_register(current_cpu, buf->data, GPOINTER_TO_INT(reg) - 1) > 0);
}
bool qemu_plugin_read_memory_vaddr(uint64_t addr, GByteArray *data, size_t len)