aboutsummaryrefslogtreecommitdiff
path: root/brightnessctl.c
diff options
context:
space:
mode:
authorGravatar Mykyta Holubakha <hilobakho@gmail.com>2016-04-07 18:01:00 +0300
committerGravatar Mykyta Holubakha <hilobakho@gmail.com>2016-04-07 18:01:00 +0300
commit7d39bfe82be6489760618a918955edcc7e0f1c27 (patch)
tree1a722a705533e634678699ffc2306dad08a78e9c /brightnessctl.c
parent7ac640201d757c723662fae7aa79021ba6b70bbf (diff)
Close file handles
Diffstat (limited to 'brightnessctl.c')
-rw-r--r--brightnessctl.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/brightnessctl.c b/brightnessctl.c
index 2a593df..664be04 100644
--- a/brightnessctl.c
+++ b/brightnessctl.c
@@ -391,11 +391,11 @@ int save_device_data(struct device *dev) {
}
if (!S_ISDIR(sb.st_mode))
goto fail;
- if (!(fp = fopen(d_path, "w"))) {
+ if (!(fp = fopen(d_path, "w")))
goto fail;
- }
if (fwrite(c, 1, s + 1, fp) < s + 1)
- goto fail;
+ errno = -1;
+ fclose(fp);
fail:
free(c_path);
free(d_path);
@@ -414,6 +414,7 @@ int restore_device_data(struct device *dev) {
if (!(fp = fopen(filename, "r")))
goto fail;
fread(buf, 15, 1, fp);
+ fclose(fp);
dev->curr_brightness = strtol(buf, &end, 10);
if (end == buf)
errno = -1;