From f5dc8abea4e5356a2150c0ea9b026ba3007a1d98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 7 Apr 2020 21:47:00 +0200 Subject: [PATCH] Use explicit casts for conversions losing integer precision --- src/dir_import.c | 4 ++-- src/dir_scan.c | 2 +- src/util.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dir_import.c b/src/dir_import.c index a41b86c..b11a580 100644 --- a/src/dir_import.c +++ b/src/dir_import.c @@ -190,7 +190,7 @@ static int rstring_esc(char **dest, int *destlen) { C(rfill1); -#define ap(c) if(*destlen > 1) { *((*dest)++) = c; (*destlen)--; } +#define ap(c) if(*destlen > 1) { *((*dest)++) = (char)(c); (*destlen)--; } switch(*ctx->buf) { case '"': ap('"'); con(1); break; case '\\': ap('\\'); con(1); break; @@ -459,7 +459,7 @@ static int iteminfo(void) { } else if(strcmp(ctx->val, "mode") == 0) { /* mode */ C(rint64(&iv, UINT16_MAX)); ctx->buf_dir->flags |= FF_EXT; - ctx->buf_ext->mode = iv; + ctx->buf_ext->mode = (unsigned short)iv; } else if(strcmp(ctx->val, "mtime") == 0) { /* mtime */ C(rint64(&iv, UINT64_MAX)); ctx->buf_dir->flags |= FF_EXT; diff --git a/src/dir_scan.c b/src/dir_scan.c index 8706e9c..429dad2 100644 --- a/src/dir_scan.c +++ b/src/dir_scan.c @@ -74,7 +74,7 @@ static void stat_to_dir(struct stat *fs) { buf_dir->asize = fs->st_size; } - buf_ext->mode = fs->st_mode; + buf_ext->mode = (unsigned short)fs->st_mode; buf_ext->mtime = fs->st_mtime; buf_ext->uid = (int)fs->st_uid; buf_ext->gid = (int)fs->st_gid; diff --git a/src/util.c b/src/util.c index 24be0e7..e9f34f4 100644 --- a/src/util.c +++ b/src/util.c @@ -265,7 +265,7 @@ void uic_init() { use_default_colors(); for(i=0; i