summaryrefslogtreecommitdiff
path: root/.config/wmii-hg/rbar_clock.c
diff options
context:
space:
mode:
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;
}
}
}