[dm-devel] [PATCH 10/35] multipathd: add prototype for cli_handler functions
mwilck at suse.com
mwilck at suse.com
Fri Sep 10 11:40:55 UTC 2021
From: Martin Wilck <mwilck at suse.com>
Use a typedef instead of spelling out the function type everywhere.
Signed-off-by: Martin Wilck <mwilck at suse.com>
---
multipathd/cli.c | 6 +++---
multipathd/cli.h | 10 ++++++----
2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/multipathd/cli.c b/multipathd/cli.c
index 4d6c37c..5213813 100644
--- a/multipathd/cli.c
+++ b/multipathd/cli.c
@@ -65,7 +65,7 @@ out:
}
int
-add_handler (uint64_t fp, int (*fn)(void *, char **, int *, void *))
+add_handler (uint64_t fp, cli_handler *fn)
{
struct handler * h;
@@ -100,7 +100,7 @@ find_handler (uint64_t fp)
}
int
-set_handler_callback (uint64_t fp, int (*fn)(void *, char **, int *, void *))
+set_handler_callback (uint64_t fp, cli_handler *fn)
{
struct handler * h = find_handler(fp);
@@ -112,7 +112,7 @@ set_handler_callback (uint64_t fp, int (*fn)(void *, char **, int *, void *))
}
int
-set_unlocked_handler_callback (uint64_t fp,int (*fn)(void *, char **, int *, void *))
+set_unlocked_handler_callback (uint64_t fp, cli_handler *fn)
{
struct handler * h = find_handler(fp);
diff --git a/multipathd/cli.h b/multipathd/cli.h
index 1e8948a..3dac1b4 100644
--- a/multipathd/cli.h
+++ b/multipathd/cli.h
@@ -124,16 +124,18 @@ struct key {
int has_param;
};
+typedef int (cli_handler)(void *keywords, char **reply, int *len, void *data);
+
struct handler {
uint64_t fingerprint;
int locked;
- int (*fn)(void *, char **, int *, void *);
+ cli_handler *fn;
};
int alloc_handlers (void);
-int add_handler (uint64_t fp, int (*fn)(void *, char **, int *, void *));
-int set_handler_callback (uint64_t fp, int (*fn)(void *, char **, int *, void *));
-int set_unlocked_handler_callback (uint64_t fp, int (*fn)(void *, char **, int *, void *));
+int add_handler (uint64_t fp, cli_handler *fn);
+int set_handler_callback (uint64_t fp, cli_handler *fn);
+int set_unlocked_handler_callback (uint64_t fp, cli_handler *fn);
int parse_cmd (char * cmd, char ** reply, int * len, void *, int);
int load_keys (void);
char * get_keyparam (vector v, uint64_t code);
--
2.33.0
More information about the dm-devel
mailing list