Ban a bunch of unsafe C functions from the codebase
List is taken from the git codebase
This commit is contained in:
parent
1ded78a98c
commit
62912a800a
42
kitty/banned.h
Normal file
42
kitty/banned.h
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Kovid Goyal <kovid at kovidgoyal.net>
|
||||
*
|
||||
* Distributed under terms of the GPL3 license.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
#define BANNED(func) sorry_##func##_is_a_banned_function
|
||||
|
||||
#undef strcpy
|
||||
#define strcpy(x,y) BANNED(strcpy)
|
||||
#undef strcat
|
||||
#define strcat(x,y) BANNED(strcat)
|
||||
#undef strncpy
|
||||
#define strncpy(x,y,n) BANNED(strncpy)
|
||||
#undef strncat
|
||||
#define strncat(x,y,n) BANNED(strncat)
|
||||
|
||||
#undef sprintf
|
||||
#undef vsprintf
|
||||
#ifdef HAVE_VARIADIC_MACROS
|
||||
#define sprintf(...) BANNED(sprintf)
|
||||
#define vsprintf(...) BANNED(vsprintf)
|
||||
#else
|
||||
#define sprintf(buf,fmt,arg) BANNED(sprintf)
|
||||
#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 ctime_r
|
||||
#define ctime_r(t, buf) BANNED(ctime_r)
|
||||
#undef asctime
|
||||
#define asctime(t) BANNED(asctime)
|
||||
#undef asctime_r
|
||||
#define asctime_r(t, buf) BANNED(asctime_r)
|
||||
@ -14,6 +14,7 @@
|
||||
#include <poll.h>
|
||||
#include <pthread.h>
|
||||
#include "glfw-wrapper.h"
|
||||
#include "banned.h"
|
||||
// Required minimum OpenGL version
|
||||
#define OPENGL_REQUIRED_VERSION_MAJOR 3
|
||||
#define OPENGL_REQUIRED_VERSION_MINOR 3
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user