From fa5356373377a5792e260468b04c8344f0e3448e Mon Sep 17 00:00:00 2001 From: Kurtis Rader Date: Tue, 3 May 2016 12:31:07 -0700 Subject: restyle sanity & screen module to match project style Reduces lint errors from 163 to 112 (-31%). Line count from 1866 to 1493 (-20%). Another step in resolving issue #2902. --- src/sanity.cpp | 51 ++++++++++++++++----------------------------------- 1 file changed, 16 insertions(+), 35 deletions(-) (limited to 'src/sanity.cpp') diff --git a/src/sanity.cpp b/src/sanity.cpp index 43480126..d6da40f4 100644 --- a/src/sanity.cpp +++ b/src/sanity.cpp @@ -1,60 +1,41 @@ -/** \file sanity.c - Functions for performing sanity checks on the program state -*/ +// Functions for performing sanity checks on the program state. #include -#include "fallback.h" // IWYU pragma: keep #include "common.h" -#include "sanity.h" -#include "proc.h" +#include "fallback.h" // IWYU pragma: keep #include "history.h" -#include "reader.h" #include "kill.h" +#include "proc.h" +#include "reader.h" +#include "sanity.h" -/** - Status from earlier sanity checks -*/ +/// Status from earlier sanity checks. static int insane; -void sanity_lose() -{ +void sanity_lose() { debug(0, _(L"Errors detected, shutting down. Break on sanity_lose() to debug.")); insane = 1; } -int sanity_check() -{ - if (!insane) - if (get_is_interactive()) - history_sanity_check(); +int sanity_check() { if (!insane) - reader_sanity_check(); - if (!insane) - kill_sanity_check(); - if (!insane) - proc_sanity_check(); + if (get_is_interactive()) history_sanity_check(); + if (!insane) reader_sanity_check(); + if (!insane) kill_sanity_check(); + if (!insane) proc_sanity_check(); return insane; } -void validate_pointer(const void *ptr, const wchar_t *err, int null_ok) -{ - - /* - Test if the pointer data crosses a segment boundary. - */ - - if ((0x00000003l & (intptr_t)ptr) != 0) - { +void validate_pointer(const void *ptr, const wchar_t *err, int null_ok) { + // Test if the pointer data crosses a segment boundary. + if ((0x00000003l & (intptr_t)ptr) != 0) { debug(0, _(L"The pointer '%ls' is invalid"), err); sanity_lose(); } - if ((!null_ok) && (ptr==0)) - { + if ((!null_ok) && (ptr == 0)) { debug(0, _(L"The pointer '%ls' is null"), err); sanity_lose(); } } - - -- cgit v1.2.3