commit f78b244670f76569d46dd8292f292cd43555b82c
parent 71f475126bf329d0335f2fb2b1f60f64f52c7b24
Author: Chris Bracken <chris@bracken.jp>
Date: Fri, 13 Feb 2026 12:55:23 +0900
Delete unused estrlcat, checkfileerror
Diffstat:
2 files changed, 2 insertions(+), 23 deletions(-)
diff --git a/src/utils.c b/src/utils.c
@@ -77,14 +77,6 @@ size_t estrlcpy(char* dst, const char* src, size_t dsize) {
return len;
}
-size_t estrlcat(char* dst, const char* src, size_t dsize) {
- size_t len = strlcat(dst, src, dsize);
- if (len >= dsize) {
- errx(1, "string truncated: '%s'", src);
- }
- return len;
-}
-
FILE* efopen(const char* filename, const char* flags) {
FILE* fp = fopen(filename, flags);
if (!fp) {
@@ -93,14 +85,6 @@ FILE* efopen(const char* filename, const char* flags) {
return fp;
}
-void checkfileerror(FILE* fp, const char* name, char mode) {
- if (mode == 'r' && ferror(fp)) {
- errx(1, "read error: %s", name);
- } else if (mode == 'w' && (fflush(fp) || ferror(fp))) {
- errx(1, "write error: %s", name);
- }
-}
-
bool is_safe_repo_path(const char* path) {
if (path[0] == '/') {
return false;
diff --git a/src/utils.h b/src/utils.h
@@ -4,7 +4,8 @@
#include <stdbool.h>
#include <stdio.h>
-/* Concatenates path parts to "p1/p2". Returns a dynamically allocated string. Exits on failure. */
+/* Concatenates path parts to "p1/p2". Returns a dynamically allocated string.
+ * Exits on failure. */
char* path_concat(const char* p1, const char* p2);
/* Recursively creates the directories specified by path, like mkdir -p. */
@@ -19,15 +20,9 @@ char* estrdup(const char* s);
/* Behaves as strlcpy but exits on failure or truncation. */
size_t estrlcpy(char* dst, const char* src, size_t dsize);
-/* Behaves as strlcat but exits on failure or truncation. */
-size_t estrlcat(char* dst, const char* src, size_t dsize);
-
/* Opens the specified file. Terminates with error on failure. */
FILE* efopen(const char* filename, const char* flags);
-/* Exits with error if the specified FILE* has an error. */
-void checkfileerror(FILE* fp, const char* name, char mode);
-
/* Validates that a path is safe to use. Returns true if safe. */
bool is_safe_repo_path(const char* path);