Browse files

test: const-ize (struct cmd).func

cmd_func is also redefined as the function type itself instead of
a pointer to a function; we can now use it to declare the functions.
  • Loading branch information...
1 parent 80c176c commit 07b849f1710bd4f09f1d442d67a4d85314397258 @ChrisJohnsen committed Mar 29, 2011
Showing with 6 additions and 3 deletions.
  1. +6 −3 test.c
View
9 test.c
@@ -187,14 +187,17 @@ static void show_msg(const char *opt) {
msg("%s", opt);
}
-typedef void (*cmd_func)(const char *opt);
+typedef void cmd_func(const char *opt);
struct cmd {
- cmd_func func;
+ cmd_func * const func;
const char * const str;
const char * const desc;
};
-static void help(const char *);
+static cmd_func
+ show_msg, show_pid, do_sleep, do_daemon, detach_from_console,
+ do_system, move_to_user, session_create, help;
+
static struct cmd all_cmds[] = {
{ show_msg, "msg", "=<text> print text to stderr" },
{ show_pid, "pid", "=<text> print pid and text to stderr" },

0 comments on commit 07b849f

Please sign in to comment.