diff --git a/src/parser.cpp b/src/parser.cpp index d44bdab18..bdbc0ac37 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -26,7 +26,6 @@ #include "parse_util.h" #include "proc.h" #include "reader.h" -#include "sanity.h" #include "signal.h" #include "wutil.h" // IWYU pragma: keep diff --git a/src/proc.cpp b/src/proc.cpp index 90e1a57c1..54c5b7df4 100644 --- a/src/proc.cpp +++ b/src/proc.cpp @@ -50,7 +50,6 @@ #include "parser.h" #include "proc.h" #include "reader.h" -#include "sanity.h" #include "signal.h" #include "wcstringutil.h" #include "wutil.h" // IWYU pragma: keep diff --git a/src/reader.cpp b/src/reader.cpp index c1b45672d..1714040d9 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -71,7 +71,6 @@ #include "parser.h" #include "proc.h" #include "reader.h" -#include "sanity.h" #include "screen.h" #include "signal.h" #include "termsize.h" diff --git a/src/sanity.cpp b/src/sanity.cpp deleted file mode 100644 index a87dd6c64..000000000 --- a/src/sanity.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Functions for performing sanity checks on the program state. -#include "config.h" // IWYU pragma: keep - -#include "sanity.h" - -#include - -#include "common.h" -#include "fallback.h" // IWYU pragma: keep -#include "flog.h" -#include "global_safety.h" -#include "history.h" -#include "kill.h" -#include "proc.h" -#include "reader.h" - -/// Status from earlier sanity checks. -static relaxed_atomic_bool_t insane{false}; - -void sanity_lose() { - FLOG(error, _(L"Errors detected, shutting down. Break on sanity_lose() to debug.")); - insane = true; -} - -void validate_pointer(const void *ptr, const wchar_t *err, int null_ok) { - // Test if the pointer data crosses a segment boundary. - if ((0x00000003L & reinterpret_cast(ptr)) != 0) { - FLOGF(error, _(L"The pointer '%ls' is invalid"), err); - sanity_lose(); - } - - if ((!null_ok) && (ptr == nullptr)) { - FLOGF(error, _(L"The pointer '%ls' is null"), err); - sanity_lose(); - } -} diff --git a/src/sanity.h b/src/sanity.h deleted file mode 100644 index e156dd28d..000000000 --- a/src/sanity.h +++ /dev/null @@ -1,15 +0,0 @@ -// Prototypes for functions for performing sanity checks on the program state. -#ifndef FISH_SANITY_H -#define FISH_SANITY_H - -/// Call this function to tell the program it is not in a sane state. -void sanity_lose(); - -/// Try and determine if ptr is a valid pointer. If not, loose sanity. -/// -/// \param ptr The pointer to validate -/// \param err A description of what the pointer refers to, for use in error messages -/// \param null_ok Whether the pointer is allowed to point to 0 -void validate_pointer(const void *ptr, const wchar_t *err, int null_ok); - -#endif