diff options
| author | 2020-05-14 19:22:07 +0200 | |
|---|---|---|
| committer | 2020-05-14 19:22:07 +0200 | |
| commit | bbde6a4ac4c1cd0abad294b7533d01ab5b230880 (patch) | |
| tree | 7625fb17d501afcafff6c288a13b3c15eff1b425 /src | |
| parent | 84b71c90bf7b0f904c516188a6fe170b3eb0cfb4 (diff) | |
| download | libplist-bbde6a4ac4c1cd0abad294b7533d01ab5b230880.tar.gz libplist-bbde6a4ac4c1cd0abad294b7533d01ab5b230880.tar.bz2 | |
time64: Silence compiler warnings about shadowed variable declarations
Diffstat (limited to 'src')
| -rw-r--r-- | src/time64.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/time64.c b/src/time64.c index 2ed8562..f1cffd4 100644 --- a/src/time64.c +++ b/src/time64.c | |||
| @@ -346,11 +346,11 @@ static Year cycle_offset(Year year) | |||
| 346 | */ | 346 | */ |
| 347 | static int safe_year(const Year year) | 347 | static int safe_year(const Year year) |
| 348 | { | 348 | { |
| 349 | int safe_year= (int)year; | 349 | int _safe_year = (int)year; |
| 350 | Year year_cycle; | 350 | Year year_cycle; |
| 351 | 351 | ||
| 352 | if( year >= MIN_SAFE_YEAR && year <= MAX_SAFE_YEAR ) { | 352 | if( year >= MIN_SAFE_YEAR && year <= MAX_SAFE_YEAR ) { |
| 353 | return safe_year; | 353 | return _safe_year; |
| 354 | } | 354 | } |
| 355 | 355 | ||
| 356 | year_cycle = year + cycle_offset(year); | 356 | year_cycle = year + cycle_offset(year); |
| @@ -374,18 +374,18 @@ static int safe_year(const Year year) | |||
| 374 | assert( year_cycle >= 0 ); | 374 | assert( year_cycle >= 0 ); |
| 375 | assert( year_cycle < SOLAR_CYCLE_LENGTH ); | 375 | assert( year_cycle < SOLAR_CYCLE_LENGTH ); |
| 376 | if( year < MIN_SAFE_YEAR ) | 376 | if( year < MIN_SAFE_YEAR ) |
| 377 | safe_year = safe_years_low[year_cycle]; | 377 | _safe_year = safe_years_low[year_cycle]; |
| 378 | else if( year > MAX_SAFE_YEAR ) | 378 | else if( year > MAX_SAFE_YEAR ) |
| 379 | safe_year = safe_years_high[year_cycle]; | 379 | _safe_year = safe_years_high[year_cycle]; |
| 380 | else | 380 | else |
| 381 | assert(0); | 381 | assert(0); |
| 382 | 382 | ||
| 383 | TIME64_TRACE3("# year: %lld, year_cycle: %lld, safe_year: %d\n", | 383 | TIME64_TRACE3("# year: %lld, year_cycle: %lld, safe_year: %d\n", |
| 384 | year, year_cycle, safe_year); | 384 | year, year_cycle, _safe_year); |
| 385 | 385 | ||
| 386 | assert(safe_year <= MAX_SAFE_YEAR && safe_year >= MIN_SAFE_YEAR); | 386 | assert(_safe_year <= MAX_SAFE_YEAR && _safe_year >= MIN_SAFE_YEAR); |
| 387 | 387 | ||
| 388 | return safe_year; | 388 | return _safe_year; |
| 389 | } | 389 | } |
| 390 | 390 | ||
| 391 | 391 | ||
| @@ -519,17 +519,17 @@ static Time64_T seconds_between_years(Year left_year, Year right_year) { | |||
| 519 | Time64_T mktime64(struct TM *input_date) { | 519 | Time64_T mktime64(struct TM *input_date) { |
| 520 | struct tm safe_date; | 520 | struct tm safe_date; |
| 521 | struct TM date; | 521 | struct TM date; |
| 522 | Time64_T time; | 522 | Time64_T timev; |
| 523 | Year year = input_date->tm_year + 1900; | 523 | Year year = input_date->tm_year + 1900; |
| 524 | 524 | ||
| 525 | if( date_in_safe_range(input_date, &SYSTEM_MKTIME_MIN, &SYSTEM_MKTIME_MAX) ) | 525 | if( date_in_safe_range(input_date, &SYSTEM_MKTIME_MIN, &SYSTEM_MKTIME_MAX) ) |
| 526 | { | 526 | { |
| 527 | copy_TM64_to_tm(input_date, &safe_date); | 527 | copy_TM64_to_tm(input_date, &safe_date); |
| 528 | time = (Time64_T)mktime(&safe_date); | 528 | timev = (Time64_T)mktime(&safe_date); |
| 529 | 529 | ||
| 530 | /* Correct the possibly out of bound input date */ | 530 | /* Correct the possibly out of bound input date */ |
| 531 | copy_tm_to_TM64(&safe_date, input_date); | 531 | copy_tm_to_TM64(&safe_date, input_date); |
| 532 | return time; | 532 | return timev; |
| 533 | } | 533 | } |
| 534 | 534 | ||
| 535 | /* Have to make the year safe in date else it won't fit in safe_date */ | 535 | /* Have to make the year safe in date else it won't fit in safe_date */ |
| @@ -537,14 +537,14 @@ Time64_T mktime64(struct TM *input_date) { | |||
| 537 | date.tm_year = safe_year(year) - 1900; | 537 | date.tm_year = safe_year(year) - 1900; |
| 538 | copy_TM64_to_tm(&date, &safe_date); | 538 | copy_TM64_to_tm(&date, &safe_date); |
| 539 | 539 | ||
| 540 | time = (Time64_T)mktime(&safe_date); | 540 | timev = (Time64_T)mktime(&safe_date); |
| 541 | 541 | ||
| 542 | /* Correct the user's possibly out of bound input date */ | 542 | /* Correct the user's possibly out of bound input date */ |
| 543 | copy_tm_to_TM64(&safe_date, input_date); | 543 | copy_tm_to_TM64(&safe_date, input_date); |
| 544 | 544 | ||
| 545 | time += seconds_between_years(year, (Year)(safe_date.tm_year + 1900)); | 545 | timev += seconds_between_years(year, (Year)(safe_date.tm_year + 1900)); |
| 546 | 546 | ||
| 547 | return time; | 547 | return timev; |
| 548 | } | 548 | } |
| 549 | 549 | ||
| 550 | 550 | ||
| @@ -560,7 +560,7 @@ struct TM *gmtime64_r (const Time64_T *in_time, struct TM *p) | |||
| 560 | Time64_T v_tm_tday; | 560 | Time64_T v_tm_tday; |
| 561 | int leap; | 561 | int leap; |
| 562 | Time64_T m; | 562 | Time64_T m; |
| 563 | Time64_T time = *in_time; | 563 | Time64_T timev = *in_time; |
| 564 | Year year = 70; | 564 | Year year = 70; |
| 565 | int cycles = 0; | 565 | int cycles = 0; |
| 566 | 566 | ||
| @@ -587,13 +587,13 @@ struct TM *gmtime64_r (const Time64_T *in_time, struct TM *p) | |||
| 587 | p->tm_zone = (char*)"UTC"; | 587 | p->tm_zone = (char*)"UTC"; |
| 588 | #endif | 588 | #endif |
| 589 | 589 | ||
| 590 | v_tm_sec = (int)(time % 60); | 590 | v_tm_sec = (int)(timev % 60); |
| 591 | time /= 60; | 591 | timev /= 60; |
| 592 | v_tm_min = (int)(time % 60); | 592 | v_tm_min = (int)(timev % 60); |
| 593 | time /= 60; | 593 | timev /= 60; |
| 594 | v_tm_hour = (int)(time % 24); | 594 | v_tm_hour = (int)(timev % 24); |
| 595 | time /= 24; | 595 | timev /= 24; |
| 596 | v_tm_tday = time; | 596 | v_tm_tday = timev; |
| 597 | 597 | ||
| 598 | WRAP (v_tm_sec, v_tm_min, 60); | 598 | WRAP (v_tm_sec, v_tm_min, 60); |
| 599 | WRAP (v_tm_min, v_tm_hour, 60); | 599 | WRAP (v_tm_min, v_tm_hour, 60); |
| @@ -681,7 +681,7 @@ struct TM *gmtime64_r (const Time64_T *in_time, struct TM *p) | |||
| 681 | } | 681 | } |
| 682 | 682 | ||
| 683 | 683 | ||
| 684 | struct TM *localtime64_r (const Time64_T *time, struct TM *local_tm) | 684 | struct TM *localtime64_r (const Time64_T *timev, struct TM *local_tm) |
| 685 | { | 685 | { |
| 686 | time_t safe_time; | 686 | time_t safe_time; |
| 687 | struct tm safe_date; | 687 | struct tm safe_date; |
| @@ -692,10 +692,10 @@ struct TM *localtime64_r (const Time64_T *time, struct TM *local_tm) | |||
| 692 | assert(local_tm != NULL); | 692 | assert(local_tm != NULL); |
| 693 | 693 | ||
| 694 | /* Use the system localtime() if time_t is small enough */ | 694 | /* Use the system localtime() if time_t is small enough */ |
| 695 | if( SHOULD_USE_SYSTEM_LOCALTIME(*time) ) { | 695 | if( SHOULD_USE_SYSTEM_LOCALTIME(*timev) ) { |
| 696 | safe_time = (time_t)*time; | 696 | safe_time = (time_t)*timev; |
| 697 | 697 | ||
| 698 | TIME64_TRACE1("Using system localtime for %lld\n", *time); | 698 | TIME64_TRACE1("Using system localtime for %lld\n", *timev); |
| 699 | 699 | ||
| 700 | LOCALTIME_R(&safe_time, &safe_date); | 700 | LOCALTIME_R(&safe_time, &safe_date); |
| 701 | 701 | ||
| @@ -705,8 +705,8 @@ struct TM *localtime64_r (const Time64_T *time, struct TM *local_tm) | |||
| 705 | return local_tm; | 705 | return local_tm; |
| 706 | } | 706 | } |
| 707 | 707 | ||
| 708 | if( gmtime64_r(time, &gm_tm) == NULL ) { | 708 | if( gmtime64_r(timev, &gm_tm) == NULL ) { |
| 709 | TIME64_TRACE1("gmtime64_r returned null for %lld\n", *time); | 709 | TIME64_TRACE1("gmtime64_r returned null for %lld\n", *timev); |
| 710 | return NULL; | 710 | return NULL; |
| 711 | } | 711 | } |
| 712 | 712 | ||
| @@ -803,10 +803,10 @@ char *asctime64_r( const struct TM* date, char *result ) { | |||
| 803 | } | 803 | } |
| 804 | 804 | ||
| 805 | 805 | ||
| 806 | char *ctime64_r( const Time64_T* time, char* result ) { | 806 | char *ctime64_r( const Time64_T* timev, char* result ) { |
| 807 | struct TM date; | 807 | struct TM date; |
| 808 | 808 | ||
| 809 | if (!localtime64_r( time, &date )) | 809 | if (!localtime64_r( timev, &date )) |
| 810 | return NULL; | 810 | return NULL; |
| 811 | 811 | ||
| 812 | return asctime64_r( &date, result ); | 812 | return asctime64_r( &date, result ); |
