Skip to content

Address scan-build warning of tmp->tm_mon again #1206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/libbson/src/bson/bson-timegm.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ timesub (const int64_t *const timep,
register int64_t idays; /* unsigned would be so 2003 */
register int_fast64_t rem;
int64_t y;
register const int *ip;
register const int (*ip)[MONSPERYEAR];
register int_fast64_t corr;
register int64_t hit;
register int64_t i;
Expand Down Expand Up @@ -438,11 +438,10 @@ timesub (const int64_t *const timep,
** representation. This uses "... ??:59:60" et seq.
*/
tmp->tm_sec = (int64_t) (rem % SECSPERMIN) + hit;
ip = mon_lengths[isleap (y)];
ip = mon_lengths + (isleap (y) ? 1 : 0);
tmp->tm_mon = 0;
BSON_ASSERT (tmp->tm_mon < MONSPERYEAR);
while (idays >= ip[tmp->tm_mon]) {
idays -= ip[tmp->tm_mon++];
while (idays >= (*ip)[tmp->tm_mon]) {
idays -= (*ip)[tmp->tm_mon++];
BSON_ASSERT (tmp->tm_mon < MONSPERYEAR);
}
tmp->tm_mday = (int64_t) (idays + 1);
Expand Down