aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/build.c b/build.c
index f0b497e..4efcede 100644
--- a/build.c
+++ b/build.c
@@ -38,14 +38,13 @@ main(int argc, char *argv[])
struct stat sb, ssb;
/* Allocate memory. */
- for (i = 0; i < MAXCMDS; i++) {
- cmd[i] = malloc(MAXCMD*sizeof(char));
- if (!cmd[i]) err(1, "malloc");
- }
- dep = malloc(MAXDEP*sizeof(char));
- if (!dep) err(1, "malloc");
- tgt = malloc(MAXTGT*sizeof(char));
- if (!tgt) err(1, "malloc");
+ for (i = 0; i < MAXCMDS; i++)
+ if (!(cmd[i] = malloc(MAXCMD)))
+ err(1, "malloc");
+ if (!(dep = malloc(MAXDEP)))
+ err(1, "malloc");
+ if (!(tgt = malloc(MAXTGT)))
+ err(1, "malloc");
tgt[0] = dep[0] = 0;
@@ -73,8 +72,8 @@ main(int argc, char *argv[])
/* Process dependencies and commands in each file. */
for (i = icmd = 0; i < argc; i++, icmd = 0) {
- fp = fopen(argv[i], "r");
- if (!fp) err(1, "fopen");
+ if (!(fp = fopen(argv[i], "r")))
+ err(1, "fopen");
/* Read line by line, at most twenty. */
for (j = 0; j < 20 && fgets(buf, MAXBUF, fp); j++) {