From ba08e487cb445663fb8d27db42654265614ae75f Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Sat, 25 Jul 2020 13:34:40 -0500 Subject: [PATCH] Disable PRF by default. Since it is not any better by default without initializing the key, we disable it by default. It can be turned on with JANET_PRF in janetconf.h. --- meson.build | 2 +- meson_options.txt | 2 +- src/conf/janetconf.h | 2 +- src/core/net.c | 3 ++- src/core/util.c | 2 +- src/include/janet.h | 2 +- test/suite4.janet | 4 +++- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index b2518693..78276551 100644 --- a/meson.build +++ b/meson.build @@ -63,7 +63,7 @@ conf.set('JANET_NO_NET', not get_option('net')) conf.set('JANET_REDUCED_OS', get_option('reduced_os')) conf.set('JANET_NO_TYPED_ARRAY', not get_option('typed_array')) conf.set('JANET_NO_INT_TYPES', not get_option('int_types')) -conf.set('JANET_NO_PRF', not get_option('prf')) +conf.set('JANET_PRF', get_option('prf')) conf.set('JANET_RECURSION_GUARD', get_option('recursion_guard')) conf.set('JANET_MAX_PROTO_DEPTH', get_option('max_proto_depth')) conf.set('JANET_MAX_MACRO_EXPAND', get_option('max_macro_expand')) diff --git a/meson_options.txt b/meson_options.txt index bfc8925f..eb068126 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -10,7 +10,7 @@ option('assembler', type : 'boolean', value : true) option('peg', type : 'boolean', value : true) option('typed_array', type : 'boolean', value : true) option('int_types', type : 'boolean', value : true) -option('prf', type : 'boolean', value : true) +option('prf', type : 'boolean', value : false) option('net', type : 'boolean', value : true) option('processes', type : 'boolean', value : true) option('umask', type : 'boolean', value : true) diff --git a/src/conf/janetconf.h b/src/conf/janetconf.h index 39a79f50..0f97e9d8 100644 --- a/src/conf/janetconf.h +++ b/src/conf/janetconf.h @@ -57,7 +57,7 @@ /* #define JANET_NO_UMASK */ /* Other settings */ -/* #define JANET_NO_PRF */ +/* #define JANET_PRF */ /* #define JANET_NO_UTC_MKTIME */ /* #define JANET_OUT_OF_MEMORY do { printf("janet out of memory\n"); exit(1); } while (0) */ /* #define JANET_EXIT(msg) do { printf("C assert failed executing janet: %s\n", msg); exit(1); } while (0) */ diff --git a/src/core/net.c b/src/core/net.c index 6d9ab81d..29a49883 100644 --- a/src/core/net.c +++ b/src/core/net.c @@ -566,7 +566,8 @@ static Janet cfun_net_server(int32_t argc, Janet *argv) { } /* Put sfd on our loop */ - JanetLoopFD lfd = {0}; + JanetLoopFD lfd; + memset(&lfd, 0, sizeof(lfd)); lfd.stream = make_stream(sfd, 0); lfd.event_type = JLE_READ_ACCEPT; lfd.data.read_accept.handler = fun; diff --git a/src/core/util.c b/src/core/util.c index d4af5667..31855c8f 100644 --- a/src/core/util.c +++ b/src/core/util.c @@ -97,7 +97,7 @@ const char *const janet_status_names[16] = { "alive" }; -#ifdef JANET_NO_PRF +#ifndef JANET_PRF int32_t janet_string_calchash(const uint8_t *str, int32_t len) { const uint8_t *end = str + len; diff --git a/src/include/janet.h b/src/include/janet.h index 05fd8a0f..72202b18 100644 --- a/src/include/janet.h +++ b/src/include/janet.h @@ -1381,7 +1381,7 @@ JANET_API int janet_verify(JanetFuncDef *def); JANET_API JanetBuffer *janet_pretty(JanetBuffer *buffer, int depth, int flags, Janet x); /* Misc */ -#ifndef JANET_NO_PRF +#ifdef JANET_PRF #define JANET_HASH_KEY_SIZE 16 JANET_API void janet_init_hash_key(uint8_t key[JANET_HASH_KEY_SIZE]); #endif diff --git a/test/suite4.janet b/test/suite4.janet index 3b20de96..5a046f52 100644 --- a/test/suite4.janet +++ b/test/suite4.janet @@ -48,7 +48,9 @@ (defn check-image "Run a marshaling test using the make-image and load-image functions." [x msg] - (assert-no-error msg (load-image (make-image x)))) + (def im (make-image x)) + (printf "\nimage-hash: %d" (-> im string hash)) + (assert-no-error msg (load-image im))) (check-image (fn [] (fn [] 1)) "marshal nested functions") (check-image (fiber/new (fn [] (fn [] 1))) "marshal nested functions in fiber")