From aa0de01e5f9702afeb770b8b2b2d4c0d78cf5845 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sun, 6 Dec 2020 14:33:08 -0600 Subject: [PATCH] Fix some formatting and undefined behavior. --- src/core/ev.c | 18 +++++++++--------- src/core/marsh.c | 2 +- src/mainclient/shell.c | 30 +++++++++++++++--------------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/core/ev.c b/src/core/ev.c index e270d92c..8691c77b 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -775,15 +775,15 @@ void janet_loop1(void) { /* This is a deadline (for a fiber, not a function call) */ JanetFiberStatus s = janet_fiber_status(to.curr_fiber); int isFinished = s == (JANET_STATUS_DEAD || - s == JANET_STATUS_ERROR || - s == JANET_STATUS_USER0 || - s == JANET_STATUS_USER1 || - s == JANET_STATUS_USER2 || - s == JANET_STATUS_USER3 || - s == JANET_STATUS_USER4); - if (!isFinished) { - janet_cancel(to.fiber, janet_cstringv("deadline expired")); - } + s == JANET_STATUS_ERROR || + s == JANET_STATUS_USER0 || + s == JANET_STATUS_USER1 || + s == JANET_STATUS_USER2 || + s == JANET_STATUS_USER3 || + s == JANET_STATUS_USER4); + if (!isFinished) { + janet_cancel(to.fiber, janet_cstringv("deadline expired")); + } } else { /* This is a timeout (for a function call, not a whole fiber) */ if (to.fiber->sched_id == to.sched_id) { diff --git a/src/core/marsh.c b/src/core/marsh.c index 96767a53..598d3668 100644 --- a/src/core/marsh.c +++ b/src/core/marsh.c @@ -286,7 +286,7 @@ static void marshal_one_def(MarshalState *st, JanetFuncDef *def, int flags) { #define JANET_FIBER_FLAG_HASCHILD (1 << 29) #define JANET_FIBER_FLAG_HASENV (1 << 30) -#define JANET_STACKFRAME_HASENV (1 << 31) +#define JANET_STACKFRAME_HASENV (INT32_MIN) /* Marshal a fiber */ static void marshal_one_fiber(MarshalState *st, JanetFiber *fiber, int flags) { diff --git a/src/mainclient/shell.c b/src/mainclient/shell.c index 7282f270..53c73b6d 100644 --- a/src/mainclient/shell.c +++ b/src/mainclient/shell.c @@ -126,21 +126,21 @@ https://github.com/antirez/linenoise/blob/master/linenoise.c #define JANET_LINE_MAX 1024 #define JANET_MATCH_MAX 256 #define JANET_HISTORY_MAX 100 -JANET_THREAD_LOCAL static int gbl_israwmode = 0; -JANET_THREAD_LOCAL static const char *gbl_prompt = "> "; -JANET_THREAD_LOCAL static int gbl_plen = 2; -JANET_THREAD_LOCAL static char gbl_buf[JANET_LINE_MAX]; -JANET_THREAD_LOCAL static int gbl_len = 0; -JANET_THREAD_LOCAL static int gbl_pos = 0; -JANET_THREAD_LOCAL static int gbl_cols = 80; -JANET_THREAD_LOCAL static char *gbl_history[JANET_HISTORY_MAX]; -JANET_THREAD_LOCAL static int gbl_history_count = 0; -JANET_THREAD_LOCAL static int gbl_historyi = 0; -JANET_THREAD_LOCAL static int gbl_sigint_flag = 0; -JANET_THREAD_LOCAL static struct termios gbl_termios_start; -JANET_THREAD_LOCAL static JanetByteView gbl_matches[JANET_MATCH_MAX]; -JANET_THREAD_LOCAL static int gbl_match_count = 0; -JANET_THREAD_LOCAL static int gbl_lines_below = 0; +static JANET_THREAD_LOCAL int gbl_israwmode = 0; +static JANET_THREAD_LOCAL const char *gbl_prompt = "> "; +static JANET_THREAD_LOCAL int gbl_plen = 2; +static JANET_THREAD_LOCAL char gbl_buf[JANET_LINE_MAX]; +static JANET_THREAD_LOCAL int gbl_len = 0; +static JANET_THREAD_LOCAL int gbl_pos = 0; +static JANET_THREAD_LOCAL int gbl_cols = 80; +static JANET_THREAD_LOCAL char *gbl_history[JANET_HISTORY_MAX]; +static JANET_THREAD_LOCAL int gbl_history_count = 0; +static JANET_THREAD_LOCAL int gbl_historyi = 0; +static JANET_THREAD_LOCAL int gbl_sigint_flag = 0; +static JANET_THREAD_LOCAL struct termios gbl_termios_start; +static JANET_THREAD_LOCAL JanetByteView gbl_matches[JANET_MATCH_MAX]; +static JANET_THREAD_LOCAL int gbl_match_count = 0; +static JANET_THREAD_LOCAL int gbl_lines_below = 0; /* Unsupported terminal list from linenoise */ static const char *badterms[] = {