From 2aed955e94c232f28364a31e04d0343ba1c5d3f0 Mon Sep 17 00:00:00 2001 From: apio Date: Mon, 21 Nov 2022 17:38:08 +0100 Subject: [PATCH] Use const pointers when possible --- src/tar.c | 6 +++--- src/util.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tar.c b/src/tar.c index 74af097..62a5896 100644 --- a/src/tar.c +++ b/src/tar.c @@ -6,9 +6,9 @@ // all of these are defined in util.c int minitar_read_header(struct minitar*, struct tar_header*); -int minitar_validate_header(struct tar_header*); -void minitar_parse_tar_header(struct tar_header*, struct minitar_entry_metadata*); -struct minitar_entry* minitar_dup_entry(struct minitar_entry*); +int minitar_validate_header(const struct tar_header*); +void minitar_parse_tar_header(const struct tar_header*, struct minitar_entry_metadata*); +struct minitar_entry* minitar_dup_entry(const struct minitar_entry*); char* minitar_read_file_contents(struct minitar_entry_metadata*, struct minitar*); struct minitar* minitar_open(const char* pathname) diff --git a/src/util.c b/src/util.c index a821e21..a98acc7 100644 --- a/src/util.c +++ b/src/util.c @@ -18,7 +18,7 @@ noreturn void minitar_panic(const char* message) minitar_handle_panic(message); } -void minitar_parse_tar_header(struct tar_header* hdr, struct minitar_entry_metadata* metadata) +void minitar_parse_tar_header(const struct tar_header* hdr, struct minitar_entry_metadata* metadata) { if (!strlen(hdr->prefix)) { @@ -64,7 +64,7 @@ void minitar_parse_tar_header(struct tar_header* hdr, struct minitar_entry_metad strcpy(metadata->gname, hdr->gname); } -int minitar_validate_header(struct tar_header* hdr) +int minitar_validate_header(const struct tar_header* hdr) { if (hdr->typeflag != '\0' && hdr->typeflag != '0' && hdr->typeflag != '1' && hdr->typeflag != '2' && hdr->typeflag != '3' && hdr->typeflag != '4' && hdr->typeflag != '5' && hdr->typeflag != '6') @@ -81,7 +81,7 @@ int minitar_read_header(struct minitar* mp, struct tar_header* hdr) return 1; } -struct minitar_entry* minitar_dup_entry(struct minitar_entry* original) +struct minitar_entry* minitar_dup_entry(const struct minitar_entry* original) { struct minitar_entry* new = malloc(sizeof *original); if (!new) return NULL;