From aa8513ba843f24758230156957e06896ebefbb7e Mon Sep 17 00:00:00 2001 From: Miles Alan Date: Sun, 5 Jul 2020 22:47:42 -0500 Subject: [PATCH] Use direct open/write/close instead of stdlib calls for device IO --- programs/sxmo_screenlock.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/programs/sxmo_screenlock.c b/programs/sxmo_screenlock.c index f24e469..ebbe72e 100644 --- a/programs/sxmo_screenlock.c +++ b/programs/sxmo_screenlock.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -31,11 +32,11 @@ static char * powerstatefile = "/sys/power/state"; void writefile(char *filepath, char *str) { - FILE *f; - f = fopen(filepath, "w"); - if (f) { - fprintf(f, "%s\n", str); - fclose(f); + int f; + f = open(filepath, O_WRONLY); + if (f != NULL) { + write(f, str, strlen(str)); + close(f); } else { fprintf(stderr, "Couldn't open filepath <%s>\n", filepath); }