diff options
author | unknown <kostja@bodhi.local> | 2006-07-09 13:03:51 +0400 |
---|---|---|
committer | unknown <kostja@bodhi.local> | 2006-07-09 13:03:51 +0400 |
commit | 46079624e2b40b7882aceece3a9a8d1f20dc547a (patch) | |
tree | 498c5c03965d4596ff78cc1ca86b1b3fd80c729c /sql | |
parent | cad24c097ebc348c1dcb1dd888a0fb89a3844cde (diff) | |
download | mariadb-git-46079624e2b40b7882aceece3a9a8d1f20dc547a.tar.gz |
Fix compiler warnings in sql_udf.h: ISO C++ forbids casting
between pointer to function and pointer to object.
sql/item_func.cc:
Use typedef names instead of hard-coded types for udf init/deinit
functions.
sql/sql_udf.cc:
Use typedef names for udf function types.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_func.cc | 7 | ||||
-rw-r--r-- | sql/sql_udf.cc | 10 | ||||
-rw-r--r-- | sql/sql_udf.h | 31 |
3 files changed, 25 insertions, 23 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 5227e771194..1d906b300b6 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2510,8 +2510,7 @@ void udf_handler::cleanup() { if (u_d->func_deinit != NULL) { - void (*deinit)(UDF_INIT *) = (void (*)(UDF_INIT*)) - u_d->func_deinit; + Udf_func_deinit deinit= u_d->func_deinit; (*deinit)(&initid); } free_udf(u_d); @@ -2656,9 +2655,7 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func, } } thd->net.last_error[0]=0; - my_bool (*init)(UDF_INIT *, UDF_ARGS *, char *)= - (my_bool (*)(UDF_INIT *, UDF_ARGS *, char *)) - u_d->func_init; + Udf_func_init init= u_d->func_init; if ((error=(uchar) init(&initid, &f_args, thd->net.last_error))) { my_error(ER_CANT_INITIALIZE_UDF, MYF(0), diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 95589a58b37..8f98bab5c04 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -83,7 +83,7 @@ static char *init_syms(udf_func *tmp, char *nm) { 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; end=strmov(nm,tmp->name.str); @@ -91,18 +91,18 @@ static char *init_syms(udf_func *tmp, char *nm) if (tmp->type == UDFTYPE_AGGREGATE) { (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; (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; } (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"); - 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 diff --git a/sql/sql_udf.h b/sql/sql_udf.h index d0729deecaa..21cf735f5ab 100644 --- a/sql/sql_udf.h +++ b/sql/sql_udf.h @@ -23,6 +23,15 @@ 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 { LEX_STRING name; @@ -30,11 +39,11 @@ typedef struct st_udf_func Item_udftype type; char *dl; void *dlhandle; - void *func; - void *func_init; - void *func_deinit; - void *func_clear; - void *func_add; + Udf_func_any func; + Udf_func_init func_init; + Udf_func_deinit func_deinit; + Udf_func_clear func_clear; + Udf_func_add func_add; ulong usage_count; } udf_func; @@ -76,8 +85,7 @@ class udf_handler :public Sql_alloc *null_value=1; return 0.0; } - double (*func)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)= - (double (*)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)) u_d->func; + Udf_func_double func= (Udf_func_double) u_d->func; double tmp=func(&initid, &f_args, &is_null, &error); if (is_null || error) { @@ -95,8 +103,7 @@ class udf_handler :public Sql_alloc *null_value=1; return LL(0); } - longlong (*func)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)= - (longlong (*)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)) u_d->func; + Udf_func_longlong func= (Udf_func_longlong) u_d->func; longlong tmp=func(&initid, &f_args, &is_null, &error); if (is_null || error) { @@ -110,8 +117,7 @@ class udf_handler :public Sql_alloc void clear() { is_null= 0; - void (*func)(UDF_INIT *, uchar *, uchar *)= - (void (*)(UDF_INIT *, uchar *, uchar *)) u_d->func_clear; + Udf_func_clear func= u_d->func_clear; func(&initid, &is_null, &error); } void add(my_bool *null_value) @@ -121,8 +127,7 @@ class udf_handler :public Sql_alloc *null_value=1; return; } - void (*func)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)= - (void (*)(UDF_INIT *, UDF_ARGS *, uchar *, uchar *)) u_d->func_add; + Udf_func_add func= u_d->func_add; func(&initid, &f_args, &is_null, &error); *null_value= (my_bool) (is_null || error); } |