From 131437016632929f3a31f45bfe934b9b43235c71 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 Jun 2018 16:17:09 -0400 Subject: tests: Cleanup assumption that ALLOC could fail. Signed-off-by: Donald Sharp --- tests/lib/test_heavy_thread.c | 11 ++--------- tests/lib/test_heavy_wq.c | 17 +++-------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/tests/lib/test_heavy_thread.c b/tests/lib/test_heavy_thread.c index 075bcb6da..b3c6e4c2f 100644 --- a/tests/lib/test_heavy_thread.c +++ b/tests/lib/test_heavy_thread.c @@ -110,16 +110,9 @@ DEFUN (clear_foo, 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; - } + ws = XMALLOC(MTYPE_TMP, sizeof(*ws)); - if (!(ws->str = XSTRDUP(MTYPE_TMP, str))) { - zlog_err("%s: unable to xstrdup", __func__); - XFREE(MTYPE_TMP, ws); - return CMD_WARNING; - } + ws->str = XSTRDUP(MTYPE_TMP, str); ws->vty = vty; ws->i = ITERS_FIRST; diff --git a/tests/lib/test_heavy_wq.c b/tests/lib/test_heavy_wq.c index 0f474dc5d..00ddc836d 100644 --- a/tests/lib/test_heavy_wq.c +++ b/tests/lib/test_heavy_wq.c @@ -60,18 +60,10 @@ static void heavy_wq_add(struct vty *vty, const char *str, int i) { struct heavy_wq_node *hn; - if ((hn = XCALLOC(MTYPE_WQ_NODE, sizeof(struct heavy_wq_node))) - == NULL) { - zlog_err("%s: unable to allocate hn", __func__); - return; - } + hn = XCALLOC(MTYPE_WQ_NODE, sizeof(struct heavy_wq_node)); hn->i = i; - if (!(hn->str = XSTRDUP(MTYPE_WQ_NODE_STR, str))) { - zlog_err("%s: unable to xstrdup", __func__); - XFREE(MTYPE_WQ_NODE, hn); - return; - } + hn->str = XSTRDUP(MTYPE_WQ_NODE_STR, str); work_queue_add(heavy_wq, hn); @@ -149,10 +141,7 @@ DEFUN (clear_foo, static int heavy_wq_init() { - if (!(heavy_wq = work_queue_new(master, "heavy_work_queue"))) { - zlog_err("%s: could not get new work queue!", __func__); - return -1; - } + heavy_wq = work_queue_new(master, "heavy_work_queue"); heavy_wq->spec.workfunc = &slow_func; heavy_wq->spec.errorfunc = &slow_func_err; -- cgit v1.2.3