diff mbox series

[OpenWrt-Devel,ucert,02/13] Fix return code of write_file()

Message ID afc86f352bf7915f81e9d38949e91306542aadee.1589663193.git.mschiffer@universe-factory.net
State Accepted
Delegated to: Matthias Schiffer
Headers show
Series ucert fixes and cleanup | expand

Commit Message

Matthias Schiffer May 16, 2020, 9:13 p.m. UTC
write_file() returns 1/true on success; it should return 0/false when
opening the file fails.

To make it more obvious that is function returns true and not 0 on
success, also change its return type to bool.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
 ucert.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series


diff --git a/ucert.c b/ucert.c
index 2ea939947d72..7de4c12711e8 100644
--- a/ucert.c
+++ b/ucert.c
@@ -116,13 +116,13 @@  struct cert_object {
 /* write buffer to file */
-static int write_file(const char *filename, void *buf, size_t len, bool append) {
+static bool write_file(const char *filename, void *buf, size_t len, bool append) {
 	FILE *f;
 	size_t outlen;
 	f = fopen(filename, append?"a":"w");
 	if (!f)
-		return 1;
+		return false;
 	outlen = fwrite(buf, 1, len, f);