From 11132fc21fb01ed63c621d852bc081a914d4f021 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Tue, 1 Sep 2020 11:19:10 +0300 Subject: [PATCH] Simplify logic to work around gcc (10.2.1) false positive warning When built with -fsanitize=address, gcc complains that source_date_epoch could be used uninitialized. This really cannot be so as override_date is only ever set if source_date_epoch is set. However we can simplify code by removing override_date variable out of the picture, we can just as well initialize source_date_epoch and consider non-zero value as being enabled instead. --- build/files.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/build/files.c b/build/files.c index 62489c07c6..212f199c5f 100644 --- a/build/files.c +++ b/build/files.c @@ -994,8 +994,7 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc) uint32_t defaultalgo = PGPHASHALGO_MD5, digestalgo; rpm_loff_t totalFileSize = 0; Header h = pkg->header; /* just a shortcut */ - int override_date = 0; - time_t source_date_epoch; + time_t source_date_epoch = 0; char *srcdate = getenv("SOURCE_DATE_EPOCH"); /* Limit the maximum date to SOURCE_DATE_EPOCH if defined @@ -1010,7 +1009,6 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc) rpmlog(RPMLOG_ERR, _("unable to parse %s=%s\n"), "SOURCE_DATE_EPOCH", srcdate); exit(28); } - override_date = 1; } /* @@ -1151,7 +1149,7 @@ static void genCpioListAndHeader(FileList fl, Package pkg, int isSrc) } } - if (override_date && flp->fl_mtime > source_date_epoch) { + if (source_date_epoch && flp->fl_mtime > source_date_epoch) { flp->fl_mtime = source_date_epoch; } /*