slang-users mailing list

[2021 Date Index] [2021 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

[slang-users] [Bug] SLFUTURE_CONST is missing in Slirp glue code


In the allocate_opaque function there are sget and sput parameters, which
are function pointers and they are missing SLFUTURE_CONST before the second
argument. Below I've added them in the places where they should be:

static unsigned int
allocate_opaque(char *name, FINALIZER fzer, INITIALIZER izer, SLtype
parent_id,
int (*sget)(SLtype, SLFUTURE_CONST char *), int (*sput)(SLtype,
SLFUTURE_CONST char *))
{
…

Above snippet comes from <module>_glue.c autogenerated code. I define the
ENABLE_SLFUTURE_CONST macro to resolve the warnings where a function
obtaining only char * (without const) "discards const qualifier" from a
string literal argument. All works fine, except that this macro triggers
another warning:

slang_api_functions_glue.c:345:63: warning: passing argument 2 of
‘SLclass_set_sget_function’ from incompatible pointer type
[-Wincompatible-pointer-types]
  345 |    if ( (sget != NULL && SLclass_set_sget_function(new_class, sget)
== -1) ||
      |                                                               ^~~~
      |                                                               |
      |                                                               int
(*)(SLtype,  char *) {aka int (*)(unsigned int,  char *)}
In file included from slang_api_functions_glue.c:16:
/usr/local/include/slang.h:778:62: note: expected ‘int (*)(SLtype,  const
char *)’ {aka ‘int (*)(unsigned int,  const char *)’} but argument is of
type ‘int (*)(SLtype,  char *)’ {aka ‘int (*)(unsigned int,  char *)’}
  778 | SL_EXTERN int SLclass_set_sget_function (SLang_Class_Type *, int
(*)(SLtype, SLFUTURE_CONST char *));
      |
 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Adding the SLFUTURE_CONST to the glue code resolves this warning. Please
update SLIRP with this omission.

Also, what can be a reason for the following warnings?

slang_api_functions_glue.c:237:12: warning: ‘SLang_push_opaque’ defined but
not used [-Wunused-function]
  237 | static int SLang_push_opaque(SLtype type, void *instance, unsigned
int owns_ref)
      |            ^~~~~~~~~~~~~~~~~
slang_api_functions_glue.c:82:13: warning: ‘SLang_free_opaque’ defined but
not used [-Wunused-function]
   82 | static void SLang_free_opaque (Slirp_Opaque *o)
      |             ^~~~~~~~~~~~~~~~~

They are the only ones generated after the SLFUTURE_CONST addition…
-- 
Sebastian Gniazdowski

[2021 date index] [2021 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]