Skip to content

Commit aafcf1d

Browse files
committed
use LIBC_CRASH_ON_NULLPTR for localtime and localtime_r
1 parent a8f7457 commit aafcf1d

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

libc/src/time/localtime.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88

99
#include "src/time/localtime.h"
1010
#include "src/time/time_utils.h"
11+
#include "src/__support/macros/null_check.h"
1112

1213
namespace LIBC_NAMESPACE_DECL {
1314

1415
LLVM_LIBC_FUNCTION(struct tm *, localtime, (const time_t *timer)) {
15-
static struct tm tm_out;
16-
17-
if (timer == nullptr) {
18-
return nullptr;
19-
}
16+
LIBC_CRASH_ON_NULLPTR(timer);
2017

18+
static struct tm tm_out;
2119
return time_utils::localtime_internal(timer, &tm_out);
2220
}
2321

libc/src/time/localtime_r.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@
88

99
#include "src/time/localtime_r.h"
1010
#include "src/time/time_utils.h"
11+
#include "src/__support/macros/null_check.h"
1112

1213
namespace LIBC_NAMESPACE_DECL {
1314

1415
LLVM_LIBC_FUNCTION(struct tm *, localtime_r,
1516
(const time_t *timer, struct tm *buf)) {
16-
if (timer == nullptr) {
17-
return nullptr;
18-
}
17+
LIBC_CRASH_ON_NULLPTR(timer);
1918

2019
return time_utils::localtime_internal(timer, buf);
2120
}

0 commit comments

Comments
 (0)