summaryrefslogtreecommitdiffstats
path: root/parse.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2017-02-07 23:01:13 -0500
committerTavian Barnes <tavianator@tavianator.com>2017-02-07 23:47:43 -0500
commit3c70db383ca48857c3bf7ed6f607c8c87fa366d9 (patch)
tree6c293bdb44f15324403f8a71688ba6038c75838f /parse.c
parentaba099bbca9d73215affd49895a391e7eded0a4a (diff)
downloadbfs-3c70db383ca48857c3bf7ed6f607c8c87fa366d9.tar.xz
Add some missing perror() calls
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/parse.c b/parse.c
index b2a4cc3..2224405 100644
--- a/parse.c
+++ b/parse.c
@@ -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;
}