summaryrefslogtreecommitdiff
path: root/.config/wmii-hg/rbar_clock.c
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-03-21 12:07:20 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-03-21 14:16:25 -0400
commit7dba2cf97a1b01cc4d4c3c346603af439d1ee0f6 (patch)
treec4bafc96c03621ef808ed8613491dad872add907 /.config/wmii-hg/rbar_clock.c
parent0133058a5dd86f7f821fd3d571fd5cef9d2e8b46 (diff)
wmii: rbar_clock: clean up
Diffstat (limited to '.config/wmii-hg/rbar_clock.c')
-rw-r--r--.config/wmii-hg/rbar_clock.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/.config/wmii-hg/rbar_clock.c b/.config/wmii-hg/rbar_clock.c
index ab636c2..79ddff3 100644
--- a/.config/wmii-hg/rbar_clock.c
+++ b/.config/wmii-hg/rbar_clock.c
@@ -7,8 +7,13 @@
const char *cleanup_id;
+void strfree(char **strp) {
+ free(*strp);
+}
+
void cleanup(void) {
- rbar_remove(rbar_globescape(cleanup_id));
+ char __attribute__((__cleanup__(strfree))) *glob_id = rbar_globescape(cleanup_id);
+ rbar_remove(glob_id);
}
int update(const char *id) {
@@ -42,11 +47,9 @@ int update(const char *id) {
"label %a %F %T %Z(%z)", /* apparently %:::z" is supported by date(1gnu) but not strftime(3gnu) */
localtime(&now.tv_sec)) <= 0)
error(1, 0, "strftime wanted a really long string");
- int err = rbar_write(id, str);
- if (err != 0) {
- if (err == GLOB_NOMATCH)
- return 0;
- return 1;
+ if (!rbar_write(id, str)) {
+ error(0, errno, "all rbars have disappeared");
+ return 0;
}
}
}