Skip to content

Commit

Permalink
time64: declare tm_zone as const char* unconditionally
Browse files Browse the repository at this point in the history
We only ever assign from `struct tm` to `struct TM`, not the other way
around, so making this const regardless of what `struct tm` has should
be safe.
  • Loading branch information
ilmari committed Jul 18, 2020
1 parent 89fbdd0 commit 926c3ce
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
2 changes: 1 addition & 1 deletion time64.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ struct TM *Perl_gmtime64_r (const Time64_T *in_time, struct TM *p)
p->tm_isdst = 0;

#ifdef HAS_TM_TM_ZONE
p->tm_zone = (char *)"UTC";
p->tm_zone = "UTC";
#endif

v_tm_sec = (int)Perl_fmod(time, 60.0);
Expand Down
10 changes: 1 addition & 9 deletions time64.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,7 @@ struct TM64 {
#endif

#ifdef HAS_TM_TM_ZONE
/* If glibc is defined or we are on QNX, use const.
* Otherwise, if we are on android, use const but
* not with g++.
*/
# if defined(__GLIBC__) || (defined(__ANDROID__) && !defined(__cplusplus)) \
|| defined(__QNX__) || defined(__CYGWIN__)
const
# endif
char *tm_zone;
const char *tm_zone;
#endif
};

Expand Down

0 comments on commit 926c3ce

Please sign in to comment.