From ba9bb9af4406b1228b7a34509fdc9e3dba111be9 Mon Sep 17 00:00:00 2001
From: Utz-Uwe Haus <uhaus@cray.com>
Date: Mon, 31 May 2021 10:26:18 +0200
Subject: [PATCH] Fix counters in schema structure

they were using 'unsigned', not size_t or uint64_t; for sure the
printing was wrong, but other code should also profit.
---
 attributes/Makefile.am         |  4 ++--
 attributes/ecmwf-yaml.h        |  2 +-
 attributes/maestro-core-yaml.h |  2 +-
 attributes/maestro-schema.c    | 12 ++++++------
 include/maestro/attributes.h   |  4 ++--
 5 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/attributes/Makefile.am b/attributes/Makefile.am
index 92b792a2..c5b08a0b 100644
--- a/attributes/Makefile.am
+++ b/attributes/Makefile.am
@@ -78,6 +78,6 @@ uninstall-local:
 	-rmdir $(DESTDIR)$(datadir)/maestro
 
 maestro-core-yaml.h: maestro-core.yaml
-	xxd -i $< | sed -e 's/unsigned int/const unsigned int/' > $@
+	xxd -i $< | sed -e 's/unsigned int/const size_t/' > $@
 ecmwf-yaml.h: ecmwf.yaml
-	xxd -i $< | sed -e 's/unsigned int/const unsigned int/' > $@
+	xxd -i $< | sed -e 's/unsigned int/const size_t/' > $@
diff --git a/attributes/ecmwf-yaml.h b/attributes/ecmwf-yaml.h
index 08c42fe0..302ea7de 100644
--- a/attributes/ecmwf-yaml.h
+++ b/attributes/ecmwf-yaml.h
@@ -155,4 +155,4 @@ unsigned char ecmwf_yaml[] = {
   0x74, 0x65, 0x6f, 0x72, 0x6f, 0x6c, 0x6f, 0x67, 0x69, 0x63, 0x61, 0x6c,
   0x20, 0x71, 0x75, 0x61, 0x6e, 0x74, 0x69, 0x74, 0x79, 0x2e, 0x0a
 };
-const unsigned int ecmwf_yaml_len = 1859;
+const size_t ecmwf_yaml_len = 1859;
diff --git a/attributes/maestro-core-yaml.h b/attributes/maestro-core-yaml.h
index 0f03c674..daafd9ef 100644
--- a/attributes/maestro-core-yaml.h
+++ b/attributes/maestro-core-yaml.h
@@ -676,4 +676,4 @@ unsigned char maestro_core_yaml[] = {
   0x66, 0x20, 0x6d, 0x61, 0x65, 0x73, 0x74, 0x72, 0x6f, 0x2d, 0x63, 0x6f,
   0x72, 0x65, 0x2e, 0x79, 0x61, 0x6d, 0x6c, 0x29, 0x0a, 0x20, 0x0a
 };
-const unsigned int maestro_core_yaml_len = 8111;
+const size_t maestro_core_yaml_len = 8111;
diff --git a/attributes/maestro-schema.c b/attributes/maestro-schema.c
index ac87c0d3..7e16b81c 100644
--- a/attributes/maestro-schema.c
+++ b/attributes/maestro-schema.c
@@ -101,7 +101,7 @@
 #define NUM_BUILTIN_SCHEMATA 2
 const struct {
   unsigned char *schema;
-  unsigned int schema_size;
+  uint64_t       schema_size;
 } builtin_schema_texts[NUM_BUILTIN_SCHEMATA] =
 { /* be sure to keep the maestro core one first */
   [0] = { .schema = maestro_core_yaml, .schema_size = maestro_core_yaml_len},
@@ -109,10 +109,10 @@ const struct {
 };
 
 const unsigned char *MSTRO_SCHEMA_BUILTIN_YAML_CORE      = maestro_core_yaml;
-const unsigned int   MSTRO_SCHEMA_BUILTIN_YAML_CORE_LEN  = maestro_core_yaml_len;
+const size_t         MSTRO_SCHEMA_BUILTIN_YAML_CORE_LEN  = maestro_core_yaml_len;
 
 const unsigned char *MSTRO_SCHEMA_BUILTIN_YAML_ECMWF     = ecmwf_yaml;
-const unsigned int   MSTRO_SCHEMA_BUILTIN_YAML_ECMWF_LEN = ecmwf_yaml_len;
+const size_t         MSTRO_SCHEMA_BUILTIN_YAML_ECMWF_LEN = ecmwf_yaml_len;
 
 
 /* a placeholder variable that can be used to indicate an invalid pointer */
@@ -260,13 +260,13 @@ struct mstro_schema_ {
 #define NAMESPACE_PATTERN_EFLAGS 0
 
   struct mstro_schema_type_ *schema_types;             /**< list(include('maestro-user-type-def'), required=False) */
-  unsigned                  schema_types_count;       /**< number of entries in schema_types array */
+  size_t                     schema_types_count;       /**< number of entries in schema_types array */
 
   struct mstro_schema_type_val  *schema_type_vals;    /**< list(include('maestro-user-typespec'), required=False) */
-  unsigned                  schema_type_vals_count;   /**< number of entries in schema_type_vals array */
+  size_t                     schema_type_vals_count;   /**< number of entries in schema_type_vals array */
 
   struct mstro_schema_attribute_ *schema_attributes;   /**< list(include('maestro-attribute-def'), required=False) */
-  unsigned                  schema_attributes_count;  /**< number of entries in schema_attributes array */
+  size_t                     schema_attributes_count;  /**< number of entries in schema_attributes array */
 
   /* components filled at instantiation time */
   mstro_symtab              symtab;                   /**< symbol table for all legal attribute names in the schema */
diff --git a/include/maestro/attributes.h b/include/maestro/attributes.h
index 5a66bafe..73bf061d 100644
--- a/include/maestro/attributes.h
+++ b/include/maestro/attributes.h
@@ -391,10 +391,10 @@ typedef struct mstro_schema_ *mstro_schema;
 
 /** Built-in schemata: */
 extern const unsigned char *MSTRO_SCHEMA_BUILTIN_YAML_CORE;
-extern const unsigned int   MSTRO_SCHEMA_BUILTIN_YAML_CORE_LEN;
+extern const size_t         MSTRO_SCHEMA_BUILTIN_YAML_CORE_LEN;
 
 extern const unsigned char *MSTRO_SCHEMA_BUILTIN_YAML_ECMWF;
-extern const unsigned int   MSTRO_SCHEMA_BUILTIN_YAML_ECMWF_LEN;
+extern const size_t         MSTRO_SCHEMA_BUILTIN_YAML_ECMWF_LEN;
 
 /**@} (end of addtogroup MSTRO_Core) */
 
-- 
GitLab