Skip to content
This repository
Browse code

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...
commit 07b849f1710bd4f09f1d442d67a4d85314397258 1 parent 80c176c
Chris Johnsen authored

Showing 1 changed file with 6 additions and 3 deletions. Show diff stats Hide diff stats

  1. +6 3 test.c
9 test.c
@@ -187,14 +187,17 @@ static void show_msg(const char *opt) {
187 187 msg("%s", opt);
188 188 }
189 189
190   -typedef void (*cmd_func)(const char *opt);
  190 +typedef void cmd_func(const char *opt);
191 191 struct cmd {
192   - cmd_func func;
  192 + cmd_func * const func;
193 193 const char * const str;
194 194 const char * const desc;
195 195 };
196 196
197   -static void help(const char *);
  197 +static cmd_func
  198 + show_msg, show_pid, do_sleep, do_daemon, detach_from_console,
  199 + do_system, move_to_user, session_create, help;
  200 +
198 201 static struct cmd all_cmds[] = {
199 202 { show_msg, "msg", "=<text> print text to stderr" },
200 203 { show_pid, "pid", "=<text> print pid and text to stderr" },

0 comments on commit 07b849f

Please sign in to comment.
Something went wrong with that request. Please try again.