]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
cal: use size_t to calculate width [lgtm scan]
authorKarel Zak <kzak@redhat.com>
Fri, 3 Jul 2020 11:17:51 +0000 (13:17 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 3 Jul 2020 11:17:51 +0000 (13:17 +0200)
We use size_t for width. This patch makes it consistent for
years_width too.

Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/cal.c

index d2d68162a071ded27f56ec22226499b8ebd552a6..0834be2bd58b159f273ea7984ea45d9f56b376c3 100644 (file)
@@ -1057,10 +1057,10 @@ static void monthly(const struct cal_control *ctl)
 static void yearly(const struct cal_control *ctl)
 {
        char out[FMT_ST_CHARS];
-       int year_width;
+       size_t year_width;
 
-       year_width = ctl->months_in_row * (ctl->week_width) +
-               (ctl->months_in_row - 1) * ctl->gutter_width;
+       year_width = (size_t) ctl->months_in_row * ctl->week_width
+                    + ((size_t) ctl->months_in_row - 1) * ctl->gutter_width;
 
        if (ctl->header_year) {
                snprintf(out, sizeof(out), "%04d", ctl->req.year);