From 3e5e62fe7b69c9e9792a317033d6ddf0c952dc3d Mon Sep 17 00:00:00 2001 From: Mia Herkt Date: Wed, 7 Dec 2022 22:30:30 +0100 Subject: [PATCH] 07: C: Fix some warnings --- 07/solution.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/07/solution.c b/07/solution.c index 323d35d..e7dff0d 100644 --- a/07/solution.c +++ b/07/solution.c @@ -55,19 +55,20 @@ int main(void) { char l[64]; entry *root = calloc(1, sizeof(entry)); root->isdir++; - entry *current; + entry *current = root; size_t S = 0, G = 0, required = 0; while (fgets(l, 64, stdin)) { l[strlen(l) - 1] = '\0'; if (l[0] == '$') { - if (l[2] == 'c') + if (l[2] == 'c') { if (l[5] == '/') current = root; else if (l[5] == '.') current = current->parent; else current = findent(current, 1, l + 5); + } } else if (l[0] == 'd') { if (!findent(current, 1, l + 4)) addent(current, 1, l + 4); @@ -89,11 +90,12 @@ int main(void) { current->n_entries--; current = (current->entries++)[0]; } else { - if (current->isdir) + if (current->isdir) { if (current->size < 100000) S += current->size; else if (current->size >= required && (current->size < G || !G)) G = current->size; + } current = current->parent; }