Source: cfengine3
Version: 3.27.1-1
Severity: important
Tags: ftbfs

Dear Maintainer,

I have noticed that cfengine3 3.27.1-1 did not reach testing because of
missing amrhf and i386 builds. Looking at the logs I see

...
evalfunction.c: In function 'ClassFilterDataGetClassExprFromIndex':
evalfunction.c:8065:41: error: passing argument 2 of 'StringToUlong' from 
incompatible pointer type [-Wincompatible-pointer-types]
 8065 |     if (StringToUlong(class_expr_index, &index) != 0) {
      |                                         ^~~~~~
      |                                         |
      |                                         size_t * {aka unsigned int *}
In file included from ./var_expressions.h:32,
                 from ./scope.h:30,
                 from evalfunction.c:54:
./../libntech/libutils/string_lib.h:76:51: note: expected 'long unsigned int *' 
but argument is of type 'size_t *' {aka 'unsigned int *'}
   76 | int StringToUlong(const char *str, unsigned long *value_out) 
FUNC_WARN_UNUSED_RESULT;
      |                                    ~~~~~~~~~~~~~~~^~~~~~~~~
...

Seems that there is a mismatch between size_t and unsigned long in 32 bit
arches. I have played with changing index type in libpromises/evalfunction.c
(see attached diff) and package builds and passes tests similarly to the
original (in an amd64 box), although did not check the resulting package.

Also tried changing things to size_t inside libntech and also builds,
however, libntech is in a different (linked) upstream repo, so I am sending
only the diff that changes things only inside cfengine3.

Hope this helps,

-- 
Agustin
--- a/libpromises/evalfunction.c
+++ b/libpromises/evalfunction.c
@@ -8060,7 +8060,7 @@ static const char *ClassFilterDataGetCla
     JsonElement *json_array,
     const char *class_expr_index)
 {
-    size_t index;
+    unsigned long index;
     assert(SIZE_MAX >= ULONG_MAX); /* make sure returned value can fit in size_t */
     if (StringToUlong(class_expr_index, &index) != 0) {
         Log(LOG_LEVEL_VERBOSE,

Reply via email to