aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2021-05-31 12:56:49 -0700
committerBruce Hill <bruce@bruce-hill.com>2021-05-31 12:56:49 -0700
commita67a25704406456cbd1d84115892c9cb5187b06c (patch)
tree2e0eef9509d87b9a1c678dde6e78a49ba3e2788c
parentda6c8857d6bad131635a846e8177e7c00a4c224e (diff)
Fix compiler warning nits
-rw-r--r--files.c18
-rw-r--r--match.c2
-rw-r--r--print.c3
-rw-r--r--utils.c1
4 files changed, 13 insertions, 11 deletions
diff --git a/files.c b/files.c
index f706290..9eeec3d 100644
--- a/files.c
+++ b/files.c
@@ -98,14 +98,16 @@ file_t *load_file(file_t **files, const char *filename)
skip_mmap:
f->mmapped = false;
- size_t capacity = 1000;
- length = 0;
- f->memory = xcalloc(sizeof(char), capacity);
- ssize_t just_read;
- while ((just_read=read(fd, &f->memory[length], capacity - length)) > 0) {
- length += (size_t)just_read;
- if (length >= capacity)
- f->memory = xrealloc(f->memory, sizeof(char)*(capacity *= 2) + 1);
+ {
+ size_t capacity = 1000;
+ length = 0;
+ f->memory = xcalloc(sizeof(char), capacity);
+ ssize_t just_read;
+ while ((just_read=read(fd, &f->memory[length], capacity - length)) > 0) {
+ length += (size_t)just_read;
+ if (length >= capacity)
+ f->memory = xrealloc(f->memory, sizeof(char)*(capacity *= 2) + 1);
+ }
}
finished_loading:
diff --git a/match.c b/match.c
index bdf13df..f7ad3ad 100644
--- a/match.c
+++ b/match.c
@@ -472,7 +472,7 @@ static match_t *match(def_t *defs, file_t *f, const char *str, pat_t *pat, bool
return p ? new_match(pat, str, p->end, p) : NULL;
}
default: {
- errx(EXIT_FAILURE, "Unknown pattern type: %d", pat->type);
+ errx(EXIT_FAILURE, "Unknown pattern type: %u", pat->type);
return NULL;
}
}
diff --git a/print.c b/print.c
index 6dfef7b..40b6058 100644
--- a/print.c
+++ b/print.c
@@ -274,9 +274,8 @@ static void _print_match(FILE *out, printer_t *pr, match_t *m)
_print_match(out, pr, m->child);
return;
}
- size_t line_start = get_line_number(pr->file, m->start);
+ size_t line = get_line_number(pr->file, m->start);
size_t line_end = get_line_number(pr->file, m->end);
- size_t line = line_start;
if (pr->use_color && current_color != color_replace) {
fprintf(out, "%s", color_replace);
diff --git a/utils.c b/utils.c
index 997223c..fd13918 100644
--- a/utils.c
+++ b/utils.c
@@ -26,6 +26,7 @@ const char *after_spaces(const char *str)
while (*str && *str != '\n') ++str;
goto skip_whitespace;
}
+ default: break;
}
return str;
}