diff mbox series

[v2,13/18] storage: Use void * instead of unsigned char *

Message ID 20240202225405.993792-13-denkenz@gmail.com (mailing list archive)
State Accepted
Commit 75998e0898bc02d0297f02060dc5fee2882e7c6f
Headers show
Series [v2,01/18] umlrunner: Also mount /var/lib as tmpfs | expand

Commit Message

Denis Kenzior Feb. 2, 2024, 10:53 p.m. UTC
This allows passing both binary and string data to write_file() and
read_file()
---
 src/storage.c | 6 ++----
 src/storage.h | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/src/storage.c b/src/storage.c
index 1b761c4ce57a..5b12c69ba6dd 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -82,8 +82,7 @@  int create_dirs(const char *filename)
 	return 0;
 }
 
-ssize_t read_file(unsigned char *buffer, size_t len,
-			const char *path_fmt, ...)
+ssize_t read_file(void *buffer, size_t len, const char *path_fmt, ...)
 {
 	va_list ap;
 	char *path;
@@ -118,8 +117,7 @@  ssize_t read_file(unsigned char *buffer, size_t len,
  * file with a temporary name and when closed, it is renamed to the
  * specified name (@path_fmt+args).
  */
-ssize_t write_file(const unsigned char *buffer, size_t len,
-			const char *path_fmt, ...)
+ssize_t write_file(const void *buffer, size_t len, const char *path_fmt, ...)
 {
 	va_list ap;
 	char *tmp_path, *path;
diff --git a/src/storage.h b/src/storage.h
index 46efd2d1a208..135674c6f517 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -24,12 +24,10 @@ 
 
 int create_dirs(const char *filename);
 
-ssize_t read_file(unsigned char *buffer, size_t len,
-			const char *path_fmt, ...)
+ssize_t read_file(void *buffer, size_t len, const char *path_fmt, ...)
 	__attribute__((format(printf, 3, 4)));
 
-ssize_t write_file(const unsigned char *buffer, size_t len,
-			const char *path_fmt, ...)
+ssize_t write_file(const void *buffer, size_t len, const char *path_fmt, ...)
 	__attribute__((format(printf, 3, 4)));
 
 char *storage_get_file_path(const char *imsi, const char *store);