aboutsummaryrefslogtreecommitdiffstats
path: root/src/mongoclock.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-09-12 03:42:24 +0200
committerMattias Andrée <maandree@operamail.com>2015-09-12 03:42:24 +0200
commitfee2317e973b25dc0e73603702dc686eb058b397 (patch)
tree4d9a6d50b74bc0be11a1b8a9543919c0eace3e85 /src/mongoclock.c
parentsignals will interrupt read on timer, so we do not have to wait for the timer to expire to exit (diff)
downloadmongoclock-2.tar.gz
mongoclock-2.tar.bz2
mongoclock-2.tar.xz
update makefile + update gitignore + fix warnings + remove old implementation + add deps2
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r--src/mongoclock.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/mongoclock.c b/src/mongoclock.c
index 8ff3676..9d822e5 100644
--- a/src/mongoclock.c
+++ b/src/mongoclock.c
@@ -219,7 +219,7 @@ int main(int argc, char* argv[])
const char** digits[9];
size_t x = 0, y = 0;
struct winsize winsize;
- int small = 0, fd;
+ int small = 0, fd = -1;
struct itimerspec itimerspec;
char _buf[8];
@@ -247,7 +247,7 @@ int main(int argc, char* argv[])
if (caught_sigwinch)
{
caught_sigwinch = 0;
- t (TEMP_FAILURE_RETRY(ioctl(STDOUT_FILENO, TIOCGWINSZ, &winsize)));
+ t (TEMP_FAILURE_RETRY(ioctl(STDOUT_FILENO, (unsigned long)TIOCGWINSZ, &winsize)));
y = winsize.ws_row;
x = winsize.ws_col;
if (y < DY) small = 2;
@@ -287,7 +287,7 @@ int main(int argc, char* argv[])
print_time(digits, y, x);
- if (read(fd, _buf, 8) < 0)
+ if (read(fd, _buf, (size_t)8) < 0)
if (errno != EINTR)
goto fail;
}
@@ -301,7 +301,8 @@ int main(int argc, char* argv[])
perror(*argv);
fprintf(stdout, "\033[?25h\n\033[?1049l");
fflush(stdout);
- TEMP_FAILURE_RETRY(close(fd));
+ if (fd >= 0)
+ TEMP_FAILURE_RETRY(close(fd));
return 1;
(void) argc;
}