spv-light-decoder: Avoid GCC 11.x warning in decode_spvlb_halign().
[pspp] / src / output / spv / spv-light-decoder.c
index fb0dd18d6aba1e8b8fc8db04641f5e29a8e5d615..f8c4f618b2edb0bb184af82940328e2512b67b6f 100644 (file)
@@ -170,6 +170,7 @@ decode_spvlb_halign (uint32_t in, enum table_halign *halignp)
       return NULL;
 
     default:
+      *halignp = 0;
       return xasprintf ("bad cell style halign %"PRIu32, in);
     }
 }
@@ -291,7 +292,7 @@ decode_spvlb_value (const struct pivot_table *table,
 {
   *outp = NULL;
 
-  struct pivot_value *out = xzalloc (sizeof *out);
+  struct pivot_value *out = XZALLOC (struct pivot_value);
   const struct spvlb_value_mod *vm;
 
   char *error;
@@ -393,17 +394,19 @@ decode_spvlb_value (const struct pivot_table *table,
     {
       if (vm->n_subscripts)
         {
-          out->n_subscripts = vm->n_subscripts;
-          out->subscripts = xnmalloc (vm->n_subscripts,
-                                      sizeof *out->subscripts);
+          struct pivot_value_ex *ex = pivot_value_ex_rw (out);
+          ex->n_subscripts = vm->n_subscripts;
+          ex->subscripts = xnmalloc (vm->n_subscripts, sizeof *ex->subscripts);
           for (size_t i = 0; i < vm->n_subscripts; i++)
-            out->subscripts[i] = to_utf8 (vm->subscripts[i], encoding);
+            ex->subscripts[i] = to_utf8 (vm->subscripts[i], encoding);
         }
 
       if (vm->n_refs)
         {
-          out->footnote_indexes = xnmalloc (vm->n_refs,
-                                            sizeof *out->footnote_indexes);
+          struct pivot_value_ex *ex = pivot_value_ex_rw (out);
+          ex->footnote_indexes = xnmalloc (vm->n_refs,
+                                           sizeof *ex->footnote_indexes);
+
           for (size_t i = 0; i < vm->n_refs; i++)
             {
               uint16_t idx = vm->refs[i];
@@ -414,18 +417,19 @@ decode_spvlb_value (const struct pivot_table *table,
                                     idx, table->n_footnotes);
                 }
 
-              out->footnote_indexes[out->n_footnotes++] = idx;
+              ex->footnote_indexes[ex->n_footnotes++] = idx;
             }
           pivot_value_sort_footnotes (out);
         }
 
       if (vm->style_pair)
         {
+          struct pivot_value_ex *ex = pivot_value_ex_rw (out);
           error = decode_spvlb_font_style (vm->style_pair->font_style,
-                                           encoding, &out->font_style);
+                                           encoding, &ex->font_style);
           if (!error)
             error = decode_spvlb_cell_style (vm->style_pair->cell_style,
-                                             &out->cell_style);
+                                             &ex->cell_style);
           if (error)
             {
               pivot_value_destroy (out);
@@ -537,7 +541,7 @@ decode_spvlb_categories (const struct pivot_table *table,
       if (error)
         return error;
 
-      struct pivot_category *out = xzalloc (sizeof *out);
+      struct pivot_category *out = XZALLOC (struct pivot_category);
       out->name = name;
       out->parent = parent;
       out->dimension = dimension;
@@ -626,7 +630,7 @@ decode_spvlb_dimension (const struct pivot_table *table,
   if (error)
     return error;
 
-  struct pivot_dimension *out = xzalloc (sizeof *out);
+  struct pivot_dimension *out = XZALLOC (struct pivot_dimension);
   out->level = UINT_MAX;
   out->top_index = idx;
   out->hide_all_labels = in->props->hide_all_labels;
@@ -835,7 +839,7 @@ decode_spvlb_table (const struct spvlb_table *in, struct pivot_table **outp)
                       in->header->version);
 
   char *error = NULL;
-  struct pivot_table *out = xzalloc (sizeof *out);
+  struct pivot_table *out = XZALLOC (struct pivot_table);
   out->ref_cnt = 1;
   hmap_init (&out->cells);
   out->look = pivot_table_look_new_builtin_default ();