1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-02-10 17:57:25 +03:00

hyverv: hypervCreateEmbeddedParam: Rework items counting

It's not necessarily clear, why we need to create the hash table
as big as number of fields we want to store, but nevertheless,
the code can be written a bit better. The @count should be type
of size_t and could be used directly in the loop that counts the
fields.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
This commit is contained in:
Michal Privoznik 2020-10-19 12:08:46 +02:00
parent 7f238274bb
commit d8960bff71

View File

@ -317,10 +317,9 @@ virHashTablePtr
hypervCreateEmbeddedParam(hypervPrivate *priv, hypervWmiClassInfoListPtr info)
{
size_t i;
int count = 0;
size_t count;
g_autoptr(virHashTable) table = NULL;
XmlSerializerInfo *typeinfo = NULL;
XmlSerializerInfo *item = NULL;
hypervWmiClassInfoPtr classInfo = NULL;
/* Get the typeinfo out of the class info list */
@ -330,15 +329,15 @@ hypervCreateEmbeddedParam(hypervPrivate *priv, hypervWmiClassInfoListPtr info)
typeinfo = classInfo->serializerInfo;
/* loop through the items to find out how many fields there are */
for (i = 0; typeinfo[i].name != NULL; i++) {}
count = i;
for (count = 0; typeinfo[count].name != NULL; count++)
;
table = virHashCreate(count, NULL);
if (table == NULL)
return NULL;
for (i = 0; typeinfo[i].name != NULL; i++) {
item = &typeinfo[i];
XmlSerializerInfo *item = &typeinfo[i];
if (virHashAddEntry(table, item->name, NULL) < 0)
return NULL;