intel: decoder: move field name copy
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 2 Aug 2017 21:32:25 +0000 (22:32 +0100)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Wed, 1 Nov 2017 13:19:20 +0000 (13:19 +0000)
This should be inside the function that actually decodes fields.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Scott D Phillips <scott.d.phillips@intel.com>
src/intel/common/gen_decoder.c

index bd3e139404c34a0b5d01a4009d679a9e1fa4b368..4ef285667d8e39ff215167e614a8c600cb6b2202 100644 (file)
@@ -823,7 +823,7 @@ iter_advance_field(struct gen_field_iterator *iter)
 
    iter->field = iter->field->next;
    if (iter->field->name)
-       strncpy(iter->name, iter->field->name, sizeof(iter->name));
+      strncpy(iter->name, iter->field->name, sizeof(iter->name));
    else
       memset(iter->name, 0, sizeof(iter->name));
 
@@ -848,7 +848,12 @@ gen_field_iterator_next(struct gen_field_iterator *iter)
    if (!iter_advance_field(iter))
       return false;
 
-   if ((iter->end - iter->start) > 32)
+   if (iter->field->name)
+      strncpy(iter->name, iter->field->name, sizeof(iter->name));
+   else
+      memset(iter->name, 0, sizeof(iter->name));
+
+   if ((iter->field->end - iter->field->start) > 32)
       v.qw = ((uint64_t) iter->p[iter->dword+1] << 32) | iter->p[iter->dword];
    else
       v.qw = iter->p[iter->dword];