summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--backlight.c13
-rw-r--r--dice.c2
2 files changed, 8 insertions, 7 deletions
diff --git a/backlight.c b/backlight.c
index 7d74599..5c529e9 100644
--- a/backlight.c
+++ b/backlight.c
@@ -9,7 +9,6 @@ static volatile sig_atomic_t caught_sigwinch = 1;
static volatile sig_atomic_t caught_sigio = 0;
static int info = 0;
-static char path[4096];
@@ -167,10 +166,11 @@ again:
static int
-show_backlights(int tfd, char **devs, size_t ndevs)
+show_backlights(char path[], int tfd, char **devs, size_t ndevs)
{
struct winsize winsize;
- char buf[256], c, prev_c = 0, *p, *colour, line[(sizeof("─") - 1) * 64 + 1];
+ char buf[256], c, prev_c = 0, *p, line[(sizeof("─") - 1) * 64 + 1];
+ const char *colour;
int width = 0, height = 0, left = 0, namelen = 0, first = 1, len, digits;
int rearm = 1, redraw = 0, reload = 1, i;
int have_max = 0, have_current = 0, vis_brightness_at;
@@ -310,7 +310,7 @@ show_backlights(int tfd, char **devs, size_t ndevs)
if (reload) {
reload = 0;
- namelen = strlen(devs[index]);
+ namelen = (int)strlen(devs[index]);
p = stpcpy(stpcpy(path, "/sys/class/backlight/"), devs[index]);
stpcpy(p, "/max_brightness");
have_max = readintfile(path, &max_brightness);
@@ -375,7 +375,7 @@ show_backlights(int tfd, char **devs, size_t ndevs)
printf("┘\033[K\n");
}
digits = max_brightness >= 10000 ? 2 : max_brightness >= 1000 ? 1 : 0;
- percent = 100. * (double)brightness / (double)max_brightness;
+ percent = (double)brightness * 100 / (double)max_brightness;
len = snprintf(NULL, 0, "%.*lf%% (%ju of %ju)", digits, percent, brightness, max_brightness);
printf("%*.s%.*lf%% (%ju of %ju)\033[K", (winsize.ws_col - len) / 2, "",
digits, percent, brightness, max_brightness);
@@ -392,6 +392,7 @@ show_backlights(int tfd, char **devs, size_t ndevs)
int
main(int argc, char *argv[])
{
+ char path[4096];
int old_sig = 0, old_flags = -1, tcset = 0, ret, tfd;
struct f_owner_ex old_owner, new_owner;
struct termios stty, saved_stty;
@@ -481,7 +482,7 @@ main(int argc, char *argv[])
fprintf(stdout, "\033[?1049h\033[?25l");
- ret = -show_backlights(tfd, devs, ndevs);
+ ret = -show_backlights(path, tfd, devs, ndevs);
fprintf(stdout, "\033[?25h\n\033[?1049l");
fflush(stdout);
diff --git a/dice.c b/dice.c
index 3403c59..556b297 100644
--- a/dice.c
+++ b/dice.c
@@ -89,7 +89,7 @@ parse_dice(const char *s, struct die **dicep, size_t *ndicep)
s++;
if (num < 1)
goto invalid;
- die->count = (size_t)num;
+ die->count = num;
if (!isdigit(*s) && *s != '-')
goto invalid;
errno = 0;