-Wint-conversion

Fedora is working on porting to modern C and as part of this effort, -Wint-conversion will becomes errors. And there are a few warnings such as this already:

have_const: checking for VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES in libvirt/libvirt.h... -------------------- no

LD_LIBRARY_PATH=.:/usr/lib64 "gcc -I/usr/include -I/usr/include/ruby/backward -I/usr/include -I.     -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64   -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  -fPIC  -m64  -c conftest.c"
conftest.c:8:16: warning: initialization of ‘int’ from ‘char *’ makes integer from pointer without a cast [-Wint-conversion]
    8 | static int t = VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES;
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/libvirt/libvirt.h:35,
                 from conftest.c:5:
conftest.c:8:16: error: initializer element is not computable at load time
    8 | static int t = VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES;
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
conftest.c:8:12: warning: ‘t’ defined but not used [-Wunused-variable]
    8 | static int t = VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES;
      |            ^
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include "ruby.h"
4: 
5: #include <libvirt/libvirt.h>
6: 
7: /*top*/
8: static int t = VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES;
/* end */

I am not sure if they are not problematic already, since the constant is not detected ...

Nevertheless, this is suggested fix from Fedora devel ML:

Looking at the Ruby MakeMakefile documention:

<https://docs.ruby-lang.org/en/master/MakeMakefile.html#method-i-have_const>

I think you need to supply a type for these constants and call
have_const like this:

  have_const(["VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES",
              "const char *"], ["libvirt/virterror.h"])

Does this help?  I'm not a Ruby programmer, so I'm not even sure if I
got the list syntax right …

Thanks,
Florian
Assignee Loading
Time tracking Loading