Skip to content

Commit

Permalink
Simplify logic to work around gcc (10.2.1) false positive warning
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pmatilai committed Sep 1, 2020
1 parent 5196c38 commit 11132fc
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions build/files.c
Expand Up @@ -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
Expand All @@ -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;
}

/*
Expand Down Expand Up @@ -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;
}
/*
Expand Down

0 comments on commit 11132fc

Please sign in to comment.