From d62a17aedeb0eebdba98238874bb13d62c48dbf9 Mon Sep 17 00:00:00 2001 From: whitespace / reindent Date: Mon, 17 Jul 2017 14:03:14 +0200 Subject: *: reindent indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter --- tests/lib/test_heavy_thread.c | 157 ++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 83 deletions(-) (limited to 'tests/lib/test_heavy_thread.c') diff --git a/tests/lib/test_heavy_thread.c b/tests/lib/test_heavy_thread.c index 9e1d70adc1..9a75780060 100644 --- a/tests/lib/test_heavy_thread.c +++ b/tests/lib/test_heavy_thread.c @@ -40,65 +40,60 @@ extern struct thread_master *master; -enum -{ - ITERS_FIRST = 0, - ITERS_ERR = 100, - ITERS_LATER = 400, - ITERS_PRINT = 10, - ITERS_MAX = 1000, +enum { ITERS_FIRST = 0, + ITERS_ERR = 100, + ITERS_LATER = 400, + ITERS_PRINT = 10, + ITERS_MAX = 1000, }; struct work_state { - struct vty *vty; - char *str; - int i; + struct vty *vty; + char *str; + int i; }; -static void -slow_func (struct vty *vty, const char *str, const int i) +static void slow_func(struct vty *vty, const char *str, const int i) { - double x = 1; - int j; - - for (j = 0; j < 300; j++) - x += sin(x)*j; - - if ((i % ITERS_LATER) == 0) - printf ("%s: %d, temporary error, save this somehow and do it later..\n", - __func__, i); - - if ((i % ITERS_ERR) == 0) - printf ("%s: hard error\n", __func__); - - if ((i % ITERS_PRINT) == 0) - printf ("%s did %d, x = %g\n", str, i, x); + double x = 1; + int j; + + for (j = 0; j < 300; j++) + x += sin(x) * j; + + if ((i % ITERS_LATER) == 0) + printf("%s: %d, temporary error, save this somehow and do it later..\n", + __func__, i); + + if ((i % ITERS_ERR) == 0) + printf("%s: hard error\n", __func__); + + if ((i % ITERS_PRINT) == 0) + printf("%s did %d, x = %g\n", str, i, x); } -static int -clear_something (struct thread *thread) +static int clear_something(struct thread *thread) { - struct work_state *ws = THREAD_ARG(thread); - - /* this could be like iterating through 150k of route_table - * or worse, iterating through a list of peers, to bgp_stop them with - * each having 150k route tables to process... - */ - while (ws->i < ITERS_MAX) - { - slow_func(ws->vty, ws->str, ws->i); - ws->i++; - if (thread_should_yield(thread)) - { - thread_add_timer_msec (master, clear_something, ws, 0, NULL); - return 0; - } - } - - /* All done! */ - XFREE (MTYPE_TMP, ws->str); - XFREE (MTYPE_TMP, ws); - return 0; + struct work_state *ws = THREAD_ARG(thread); + + /* this could be like iterating through 150k of route_table + * or worse, iterating through a list of peers, to bgp_stop them with + * each having 150k route tables to process... + */ + while (ws->i < ITERS_MAX) { + slow_func(ws->vty, ws->str, ws->i); + ws->i++; + if (thread_should_yield(thread)) { + thread_add_timer_msec(master, clear_something, ws, 0, + NULL); + return 0; + } + } + + /* All done! */ + XFREE(MTYPE_TMP, ws->str); + XFREE(MTYPE_TMP, ws); + return 0; } DEFUN (clear_foo, @@ -107,40 +102,36 @@ DEFUN (clear_foo, "clear command\n" "arbitrary string\n") { - char *str; - struct work_state *ws; - - if (!argc) - { - vty_out (vty, "%% string argument required\n"); - return CMD_WARNING; - } - - str = argv_concat (argv, argc, 0); - - if ((ws = XMALLOC(MTYPE_TMP, sizeof(*ws))) == NULL) - { - zlog_err ("%s: unable to allocate work_state", __func__); - return CMD_WARNING; - } - - if (!(ws->str = XSTRDUP (MTYPE_TMP, str))) - { - zlog_err ("%s: unable to xstrdup", __func__); - XFREE (MTYPE_TMP, ws); - return CMD_WARNING; - } - - ws->vty = vty; - ws->i = ITERS_FIRST; - - thread_add_timer_msec (master, clear_something, ws, 0, NULL); - - return CMD_SUCCESS; + char *str; + struct work_state *ws; + + if (!argc) { + vty_out(vty, "%% string argument required\n"); + return CMD_WARNING; + } + + str = argv_concat(argv, argc, 0); + + if ((ws = XMALLOC(MTYPE_TMP, sizeof(*ws))) == NULL) { + zlog_err("%s: unable to allocate work_state", __func__); + return CMD_WARNING; + } + + if (!(ws->str = XSTRDUP(MTYPE_TMP, str))) { + zlog_err("%s: unable to xstrdup", __func__); + XFREE(MTYPE_TMP, ws); + return CMD_WARNING; + } + + ws->vty = vty; + ws->i = ITERS_FIRST; + + thread_add_timer_msec(master, clear_something, ws, 0, NULL); + + return CMD_SUCCESS; } -void -test_init() +void test_init() { - install_element (VIEW_NODE, &clear_foo_cmd); + install_element(VIEW_NODE, &clear_foo_cmd); } -- cgit v1.2.3