summaryrefslogtreecommitdiff
path: root/banned.h
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2020-12-01 13:11:37 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-12-01 14:37:27 -0800
commit1fbfdf556f2abc708183caca53ae4e2881b46ae2 (patch)
tree722feecb837c8e7d03a7299ad75c6b6e6e1146d9 /banned.h
parentNinth batch (diff)
downloadtgif-1fbfdf556f2abc708183caca53ae4e2881b46ae2.tar.xz
banned.h: mark non-reentrant gmtime, etc as banned
The traditional gmtime(), localtime(), ctime(), and asctime() functions return pointers to shared storage. This means they're not thread-safe, and they also run the risk of somebody holding onto the result across multiple calls (where each call invalidates the previous result). All callers should be using their reentrant counterparts. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'banned.h')
-rw-r--r--banned.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/banned.h b/banned.h
index 60a18d4403..ed11300bb2 100644
--- a/banned.h
+++ b/banned.h
@@ -29,4 +29,13 @@
#define vsprintf(buf,fmt,arg) BANNED(vsprintf)
#endif
+#undef gmtime
+#define gmtime(t) BANNED(gmtime)
+#undef localtime
+#define localtime(t) BANNED(localtime)
+#undef ctime
+#define ctime(t) BANNED(ctime)
+#undef asctime
+#define asctime(t) BANNED(asctime)
+
#endif /* BANNED_H */