Commit 2ab1e065 authored by kostja@bodhi.local's avatar kostja@bodhi.local

Fix compiler warnings in sql_udf.h: ISO C++ forbids casting

between pointer to function and pointer to object.
parent f1d949a8
...@@ -2510,8 +2510,7 @@ void udf_handler::cleanup() ...@@ -2510,8 +2510,7 @@ void udf_handler::cleanup()
{ {
if (u_d->func_deinit != NULL) if (u_d->func_deinit != NULL)
{ {
void (*deinit)(UDF_INIT *) = (void (*)(UDF_INIT*)) Udf_func_deinit deinit= u_d->func_deinit;
u_d->func_deinit;
(*deinit)(&initid); (*deinit)(&initid);
} }
free_udf(u_d); free_udf(u_d);
...@@ -2656,9 +2655,7 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func, ...@@ -2656,9 +2655,7 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func,
} }
} }
thd->net.last_error[0]=0; thd->net.last_error[0]=0;
my_bool (*init)(UDF_INIT *, UDF_ARGS *, char *)= Udf_func_init init= u_d->func_init;
(my_bool (*)(UDF_INIT *, UDF_ARGS *, char *))
u_d->func_init;
if ((error=(uchar) init(&initid, &f_args, thd->net.last_error))) if ((error=(uchar) init(&initid, &f_args, thd->net.last_error)))
{ {
my_error(ER_CANT_INITIALIZE_UDF, MYF(0), my_error(ER_CANT_INITIALIZE_UDF, MYF(0),
......
...@@ -83,7 +83,7 @@ static char *init_syms(udf_func *tmp, char *nm) ...@@ -83,7 +83,7 @@ static char *init_syms(udf_func *tmp, char *nm)
{ {
char *end; char *end;
if (!((tmp->func= dlsym(tmp->dlhandle, tmp->name.str)))) if (!((tmp->func= (Udf_func_any) dlsym(tmp->dlhandle, tmp->name.str))))
return tmp->name.str; return tmp->name.str;
end=strmov(nm,tmp->name.str); end=strmov(nm,tmp->name.str);
...@@ -91,18 +91,18 @@ static char *init_syms(udf_func *tmp, char *nm) ...@@ -91,18 +91,18 @@ static char *init_syms(udf_func *tmp, char *nm)
if (tmp->type == UDFTYPE_AGGREGATE) if (tmp->type == UDFTYPE_AGGREGATE)
{ {
(void)strmov(end, "_clear"); (void)strmov(end, "_clear");
if (!((tmp->func_clear= dlsym(tmp->dlhandle, nm)))) if (!((tmp->func_clear= (Udf_func_clear) dlsym(tmp->dlhandle, nm))))
return nm; return nm;
(void)strmov(end, "_add"); (void)strmov(end, "_add");
if (!((tmp->func_add= dlsym(tmp->dlhandle, nm)))) if (!((tmp->func_add= (Udf_func_add) dlsym(tmp->dlhandle, nm))))
return nm; return nm;
} }
(void) strmov(end,"_deinit"); (void) strmov(end,"_deinit");
tmp->func_deinit= dlsym(tmp->dlhandle, nm); tmp->func_deinit= (Udf_func_deinit) dlsym(tmp->dlhandle, nm);
(void) strmov(end,"_init"); (void) strmov(end,"_init");
tmp->func_init= dlsym(tmp->dlhandle, nm); tmp->func_init= (Udf_func_init) dlsym(tmp->dlhandle, nm);
/* /*
to prefent loading "udf" from, e.g. libc.so to prefent loading "udf" from, e.g. libc.so
......
...@@ -23,6 +23,15 @@ ...@@ -23,6 +23,15 @@
enum Item_udftype {UDFTYPE_FUNCTION=1,UDFTYPE_AGGREGATE}; enum Item_udftype {UDFTYPE_FUNCTION=1,UDFTYPE_AGGREGATE};
typedef void (*Udf_func_clear)(UDF_INIT *, uchar *, uchar *);
typedef void (*Udf_func_add)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *);
typedef void (*Udf_func_deinit)(UDF_INIT*);
typedef my_bool (*Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *);
typedef void (*Udf_func_any)();
typedef double (*Udf_func_double)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *);
typedef longlong (*Udf_func_longlong)(UDF_INIT *, UDF_ARGS *, uchar *,
uchar *);
typedef struct st_udf_func typedef struct st_udf_func
{ {
LEX_STRING name; LEX_STRING name;
...@@ -30,11 +39,11 @@ typedef struct st_udf_func ...@@ -30,11 +39,11 @@ typedef struct st_udf_func
Item_udftype type; Item_udftype type;
char *dl; char *dl;
void *dlhandle; void *dlhandle;
void *func; Udf_func_any func;
void *func_init; Udf_func_init func_init;
void *func_deinit; Udf_func_deinit func_deinit;
void *func_clear; Udf_func_clear func_clear;
void *func_add; Udf_func_add func_add;
ulong usage_count; ulong usage_count;
} udf_func; } udf_func;
...@@ -76,8 +85,7 @@ class udf_handler :public Sql_alloc ...@@ -76,8 +85,7 @@ class udf_handler :public Sql_alloc
*null_value=1; *null_value=1;
return 0.0; return 0.0;
} }
double (*func)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)= Udf_func_double func= (Udf_func_double) u_d->func;
(double (*)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)) u_d->func;
double tmp=func(&initid, &f_args, &is_null, &error); double tmp=func(&initid, &f_args, &is_null, &error);
if (is_null || error) if (is_null || error)
{ {
...@@ -95,8 +103,7 @@ class udf_handler :public Sql_alloc ...@@ -95,8 +103,7 @@ class udf_handler :public Sql_alloc
*null_value=1; *null_value=1;
return LL(0); return LL(0);
} }
longlong (*func)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)= Udf_func_longlong func= (Udf_func_longlong) u_d->func;
(longlong (*)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)) u_d->func;
longlong tmp=func(&initid, &f_args, &is_null, &error); longlong tmp=func(&initid, &f_args, &is_null, &error);
if (is_null || error) if (is_null || error)
{ {
...@@ -110,8 +117,7 @@ class udf_handler :public Sql_alloc ...@@ -110,8 +117,7 @@ class udf_handler :public Sql_alloc
void clear() void clear()
{ {
is_null= 0; is_null= 0;
void (*func)(UDF_INIT *, uchar *, uchar *)= Udf_func_clear func= u_d->func_clear;
(void (*)(UDF_INIT *, uchar *, uchar *)) u_d->func_clear;
func(&initid, &is_null, &error); func(&initid, &is_null, &error);
} }
void add(my_bool *null_value) void add(my_bool *null_value)
...@@ -121,8 +127,7 @@ class udf_handler :public Sql_alloc ...@@ -121,8 +127,7 @@ class udf_handler :public Sql_alloc
*null_value=1; *null_value=1;
return; return;
} }
void (*func)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)= Udf_func_add func= u_d->func_add;
(void (*)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)) u_d->func_add;
func(&initid, &f_args, &is_null, &error); func(&initid, &f_args, &is_null, &error);
*null_value= (my_bool) (is_null || error); *null_value= (my_bool) (is_null || error);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment