mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 19:32:19 +00:00
virPolkitCheckAuth: Avoid virStringListLength in loop condition
Don't re-calculate the string list length on every iteration. Convert the loop to NULL-terminated iteration. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
2f9b2c0cdd
commit
1114cf5e7e
@ -75,7 +75,7 @@ int virPolkitCheckAuth(const char *actionid,
|
||||
gboolean is_authorized;
|
||||
gboolean is_challenge;
|
||||
bool is_dismissed = false;
|
||||
size_t i;
|
||||
const char **next;
|
||||
|
||||
if (!(sysbus = virGDBusGetSystemBus()))
|
||||
return -1;
|
||||
@ -90,8 +90,15 @@ int virPolkitCheckAuth(const char *actionid,
|
||||
gprocess = g_variant_builder_end(&builder);
|
||||
|
||||
g_variant_builder_init(&builder, G_VARIANT_TYPE("a{ss}"));
|
||||
for (i = 0; i < virStringListLength(details); i += 2)
|
||||
g_variant_builder_add(&builder, "{ss}", details[i], details[i + 1]);
|
||||
|
||||
if (details) {
|
||||
for (next = details; *next; next++) {
|
||||
const char *detail1 = *(next++);
|
||||
const char *detail2 = *next;
|
||||
g_variant_builder_add(&builder, "{ss}", detail1, detail2);
|
||||
}
|
||||
}
|
||||
|
||||
gdetails = g_variant_builder_end(&builder);
|
||||
|
||||
message = g_variant_new("((s@a{sv})s@a{ss}us)",
|
||||
|
Loading…
x
Reference in New Issue
Block a user