diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-02-07 23:01:13 -0500 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-02-07 23:47:43 -0500 |
commit | 3c70db383ca48857c3bf7ed6f607c8c87fa366d9 (patch) | |
tree | 6c293bdb44f15324403f8a71688ba6038c75838f /parse.c | |
parent | aba099bbca9d73215affd49895a391e7eded0a4a (diff) | |
download | bfs-3c70db383ca48857c3bf7ed6f607c8c87fa366d9.tar.xz |
Add some missing perror() calls
Diffstat (limited to 'parse.c')
-rw-r--r-- | parse.c | 32 |
1 files changed, 18 insertions, 14 deletions
@@ -91,21 +91,24 @@ static void free_expr(struct expr *expr) { */ static struct expr *new_expr(eval_fn *eval, bool pure, size_t argc, char **argv) { struct expr *expr = malloc(sizeof(struct expr)); - if (expr) { - expr->eval = eval; - expr->lhs = NULL; - expr->rhs = NULL; - expr->pure = pure; - expr->evaluations = 0; - expr->successes = 0; - expr->elapsed.tv_sec = 0; - expr->elapsed.tv_nsec = 0; - expr->argc = argc; - expr->argv = argv; - expr->file = NULL; - expr->regex = NULL; - expr->printf = NULL; + if (!expr) { + perror("malloc()"); + return NULL; } + + expr->eval = eval; + expr->lhs = NULL; + expr->rhs = NULL; + expr->pure = pure; + expr->evaluations = 0; + expr->successes = 0; + expr->elapsed.tv_sec = 0; + expr->elapsed.tv_nsec = 0; + expr->argc = argc; + expr->argv = argv; + expr->file = NULL; + expr->regex = NULL; + expr->printf = NULL; return expr; } @@ -2471,6 +2474,7 @@ static int parse_gettime(struct timespec *ts) { struct cmdline *parse_cmdline(int argc, char *argv[]) { struct cmdline *cmdline = malloc(sizeof(struct cmdline)); if (!cmdline) { + perror("malloc()"); goto fail; } |