summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremie Courreges-Anglas <jca@cvs.openbsd.org>2020-05-08 14:30:43 +0000
committerJeremie Courreges-Anglas <jca@cvs.openbsd.org>2020-05-08 14:30:43 +0000
commitc2631e1914db7e17e3c67dfc4dd0227f31087e5e (patch)
tree2ba2940b83d657158bc226d4e2dfaca4a7b70524
parent237631da0a703c316385f75f2601afc51a73a735 (diff)
Use proper function pointer type instead of void *
Mixing up function and void pointers isn't defined by POSIX or the C standard. POSIX only specifies that casting the result of dlsym(3) to an appropriate function pointer works. Avoid all this by using a typedef. from Michael Forney, ok tb@
-rw-r--r--bin/ksh/emacs.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/bin/ksh/emacs.c b/bin/ksh/emacs.c
index aa2cceb657d..694c402ff6b 100644
--- a/bin/ksh/emacs.c
+++ b/bin/ksh/emacs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: emacs.c,v 1.86 2019/04/03 14:55:12 jca Exp $ */
+/* $OpenBSD: emacs.c,v 1.87 2020/05/08 14:30:42 jca Exp $ */
/*
* Emacs-like command line editing and history
@@ -41,8 +41,10 @@ static Area aedit;
#define KEOL 1 /* ^M, ^J */
#define KINTR 2 /* ^G, ^C */
+typedef int (*kb_func)(int);
+
struct x_ftab {
- int (*xf_func)(int c);
+ kb_func xf_func;
const char *xf_name;
short xf_flags;
};
@@ -861,7 +863,7 @@ x_eot_del(int c)
return (x_del_char(c));
}
-static void *
+static kb_func
kb_find_hist_func(char c)
{
struct kb_entry *k;
@@ -1315,7 +1317,7 @@ kb_del(struct kb_entry *k)
}
static struct kb_entry *
-kb_add_string(void *func, void *args, char *str)
+kb_add_string(kb_func func, void *args, char *str)
{
unsigned int ele, count;
struct kb_entry *k;
@@ -1350,7 +1352,7 @@ kb_add_string(void *func, void *args, char *str)
}
static struct kb_entry *
-kb_add(void *func, ...)
+kb_add(kb_func func, ...)
{
va_list ap;
unsigned char ch;