From 761a559dbfed99e588d7f306c89331907b2d5a92 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 28 Feb 2023 14:27:47 +0800 Subject: vim-patch:8.2.2777: Vim9: blob operations not tested in all ways Problem: Vim9: blob operations not tested in all ways. Solution: Run tests with CheckLegacyAndVim9Success(). Make blob assign with index work. https://github.com/vim/vim/commit/51e933261b984db014e858d79387a826d2626fb6 Cherry-pick related changes from patches 8.2.{0633,0634}. N/A patches for version.c: vim-patch:8.2.2779: memory access error in remove() for blob Problem: Memory access error in remove() for blob. Solution: Adjust length for memmove(). https://github.com/vim/vim/commit/f7e92aae1581203306a340b4c0059cc74adea9d6 Co-authored-by: Bram Moolenaar --- src/nvim/eval/typval.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 3f59cd3547..4a2654f03e 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -372,7 +372,7 @@ static inline uint8_t tv_blob_get(const blob_T *const b, int idx) return ((uint8_t *)b->bv_ga.ga_data)[idx]; } -static inline void tv_blob_set(blob_T *b, int idx, uint8_t c) +static inline void tv_blob_set(blob_T *blob, int idx, uint8_t c) REAL_FATTR_ALWAYS_INLINE REAL_FATTR_NONNULL_ALL; /// Store the byte `c` at index `idx` in the blob. @@ -380,9 +380,9 @@ static inline void tv_blob_set(blob_T *b, int idx, uint8_t c) /// @param[in] b Blob to index. Cannot be NULL. /// @param[in] idx Index in a blob. Must be valid. /// @param[in] c Value to store. -static inline void tv_blob_set(blob_T *const b, int idx, uint8_t c) +static inline void tv_blob_set(blob_T *const blob, int idx, uint8_t c) { - ((uint8_t *)b->bv_ga.ga_data)[idx] = c; + ((uint8_t *)blob->bv_ga.ga_data)[idx] = c; } /// Initialize VimL object -- cgit From 5bad9afed2189f3716865da42c66133d1f6da218 Mon Sep 17 00:00:00 2001 From: ii14 Date: Thu, 16 Mar 2023 18:13:58 +0100 Subject: build: sanitizers for gcc GCC also supports sanitizers. GCC doesn't support -fsanitize-blacklist option though, so replace .asan-blacklist file with no_sanitize_address function attributes instead. --- src/nvim/eval/typval.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 4a2654f03e..84e4067f9d 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -518,13 +518,15 @@ static inline bool tv_get_float_chk(const typval_T *const tv, float_T *const ret static inline DictWatcher *tv_dict_watcher_node_data(QUEUE *q) REAL_FATTR_NONNULL_ALL REAL_FATTR_NONNULL_RET REAL_FATTR_PURE - REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE; + REAL_FATTR_WARN_UNUSED_RESULT REAL_FATTR_ALWAYS_INLINE + FUNC_ATTR_NO_SANITIZE_ADDRESS; /// Compute the `DictWatcher` address from a QUEUE node. /// /// This only exists for .asan-blacklist (ASAN doesn't handle QUEUE_DATA pointer /// arithmetic). static inline DictWatcher *tv_dict_watcher_node_data(QUEUE *q) + FUNC_ATTR_NO_SANITIZE_ADDRESS { return QUEUE_DATA(q, DictWatcher, node); } -- cgit From d745433817499c34ccf230469417fb0ea29b7ab9 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 8 May 2023 22:40:18 +0800 Subject: vim-patch:9.0.1522: some functions give two error messages Problem: Some functions give two error messages. Solution: Do not give a second error message. (closes vim/vim#12352) https://github.com/vim/vim/commit/e4098457ab9c94225b1b0e3c5e06b82b75587971 It seems that tv_get_bool() is actually not exactly the same as tv_get_number(), so change it to a function instead. Co-authored-by: Bram Moolenaar --- src/nvim/eval/typval.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 84e4067f9d..767fd706b3 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -567,8 +567,4 @@ EXTERN const size_t kTVTranslate INIT(= TV_TRANSLATE); # include "eval/typval.h.generated.h" #endif -#define tv_get_bool tv_get_number -#define tv_get_bool_chk tv_get_number_chk -#define tv_dict_get_bool tv_dict_get_number_def - #endif // NVIM_EVAL_TYPVAL_H -- cgit From c48f94d1f30056272ed030ad3f4529055ac07853 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sun, 28 May 2023 16:34:47 +0200 Subject: build: remove LOG_LIST_ACTIONS option and related code It has not been used for a long time and the likelihood of it still working is low. --- src/nvim/eval/typval.h | 74 -------------------------------------------------- 1 file changed, 74 deletions(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 767fd706b3..e7b2499346 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -18,74 +18,6 @@ #include "nvim/message.h" #include "nvim/types.h" -#ifdef LOG_LIST_ACTIONS -# include "nvim/memory.h" - -extern ListLog *list_log_first; ///< First list log chunk, NULL if missing -extern ListLog *list_log_last; ///< Last list log chunk - -static inline ListLog *list_log_alloc(const size_t size) - REAL_FATTR_ALWAYS_INLINE REAL_FATTR_WARN_UNUSED_RESULT; - -/// Allocate a new log chunk and update globals -/// -/// @param[in] size Number of entries in a new chunk. -/// -/// @return [allocated] Newly allocated chunk. -static inline ListLog *list_log_new(const size_t size) -{ - ListLog *ret = xmalloc(offsetof(ListLog, entries) - + size * sizeof(ret->entries[0])); - ret->size = 0; - ret->capacity = size; - ret->next = NULL; - if (list_log_first == NULL) { - list_log_first = ret; - } else { - list_log_last->next = ret; - } - list_log_last = ret; - return ret; -} - -static inline void list_log(const list_T *const l, const listitem_T *const li1, - const listitem_T *const li2, const char *const action) - REAL_FATTR_ALWAYS_INLINE; - -/// Add new entry to log -/// -/// If last chunk was filled it uses twice as much memory to allocate the next -/// chunk. -/// -/// @param[in] l List to which entry belongs. -/// @param[in] li1 List item 1. -/// @param[in] li2 List item 2, often used for integers and not list items. -/// @param[in] action Logged action. -static inline void list_log(const list_T *const l, const listitem_T *const li1, - const listitem_T *const li2, const char *const action) -{ - ListLog *tgt; - if (list_log_first == NULL) { - tgt = list_log_new(128); - } else if (list_log_last->size == list_log_last->capacity) { - tgt = list_log_new(list_log_last->capacity * 2); - } else { - tgt = list_log_last; - } - tgt->entries[tgt->size++] = (ListLogEntry) { - .l = (uintptr_t)l, - .li1 = (uintptr_t)li1, - .li2 = (uintptr_t)li2, - .len = (l == NULL ? 0 : l->lv_len), - .action = action, - }; -} -#else -# define list_log(...) -# define list_write_log(...) -# define list_free_log() -#endif - // In a hashtab item "hi_key" points to "di_key" in a dictitem. // This avoids adding a pointer to the hashtab item. @@ -174,7 +106,6 @@ static inline int tv_list_len(const list_T *l) /// @param[in] l List to check. static inline int tv_list_len(const list_T *const l) { - list_log(l, NULL, NULL, "len"); if (l == NULL) { return 0; } @@ -258,10 +189,8 @@ static inline listitem_T *tv_list_first(const list_T *l) static inline listitem_T *tv_list_first(const list_T *const l) { if (l == NULL) { - list_log(l, NULL, NULL, "first"); return NULL; } - list_log(l, l->lv_first, NULL, "first"); return l->lv_first; } @@ -276,10 +205,8 @@ static inline listitem_T *tv_list_last(const list_T *l) static inline listitem_T *tv_list_last(const list_T *const l) { if (l == NULL) { - list_log(l, NULL, NULL, "last"); return NULL; } - list_log(l, l->lv_last, NULL, "last"); return l->lv_last; } @@ -416,7 +343,6 @@ extern bool tv_in_free_unref_items; #define _TV_LIST_ITER_MOD(modifier, l, li, code) \ do { \ modifier list_T *const l_ = (l); \ - list_log(l_, NULL, NULL, "iter" #modifier); \ if (l_ != NULL) { \ for (modifier listitem_T *li = l_->lv_first; \ li != NULL; li = li->li_next) { \ -- cgit From 2f17ef1fc4b96cf1106fd95ba090d34a2e4b977b Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Thu, 22 Jun 2023 04:09:14 -0700 Subject: fix(messages): use "Vimscript" instead of "VimL" #24111 followup to #24109 fix #16150 --- src/nvim/eval/typval.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index e7b2499346..0b42a473cf 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -312,7 +312,7 @@ static inline void tv_blob_set(blob_T *const blob, int idx, uint8_t c) ((uint8_t *)blob->bv_ga.ga_data)[idx] = c; } -/// Initialize VimL object +/// Initialize Vimscript object /// /// Initializes to unlocked VAR_UNKNOWN object. /// @@ -424,7 +424,7 @@ static inline bool tv_get_float_chk(const typval_T *tv, float_T *ret_f) /// /// Raises an error if object is not number or floating-point. /// -/// @param[in] tv VimL object to get value from. +/// @param[in] tv Vimscript object to get value from. /// @param[out] ret_f Location where resulting float is stored. /// /// @return true in case of success, false if tv is not a number or float. -- cgit From 5f03a1eaabfc8de2b3a9c666fcd604763f41e152 Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 20 Oct 2023 15:10:33 +0200 Subject: build(lint): remove unnecessary clint.py rules Uncrustify is the source of truth where possible. Remove any redundant checks from clint.py. --- src/nvim/eval/typval.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 0b42a473cf..7a168ba183 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -485,8 +485,8 @@ static inline bool tv_is_func(const typval_T tv) #ifdef UNIT_TESTING // Do not use enum constants, see commit message. -EXTERN const size_t kTVCstring INIT(= TV_CSTRING); -EXTERN const size_t kTVTranslate INIT(= TV_TRANSLATE); +EXTERN const size_t kTVCstring INIT( = TV_CSTRING); +EXTERN const size_t kTVTranslate INIT( = TV_TRANSLATE); #endif #ifdef INCLUDE_GENERATED_DECLARATIONS -- cgit From acc646ad8fc3ef11fcc63b69f3d8484e4a91accd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 29 Sep 2023 14:58:48 +0200 Subject: refactor: the long goodbye long is 32 bits on windows, while it is 64 bits on other architectures. This makes the type suboptimal for a codebase meant to be cross-platform. Replace it with more appropriate integer types. --- src/nvim/eval/typval.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 7a168ba183..d2baabb424 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -235,7 +235,7 @@ static inline long tv_dict_len(const dict_T *d) static inline long tv_dict_len(const dict_T *const d) { if (d == NULL) { - return 0L; + return 0; } return (long)d->dv_hashtab.ht_used; } -- cgit From 4f8941c1a5f1ef6caa410feeb52e343db22763ce Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 12:23:42 +0100 Subject: refactor: replace manual header guards with #pragma once It is less error-prone than manually defining header guards. Pretty much all compilers support it even if it's not part of the C standard. --- src/nvim/eval/typval.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index d2baabb424..751b9646b3 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -1,5 +1,4 @@ -#ifndef NVIM_EVAL_TYPVAL_H -#define NVIM_EVAL_TYPVAL_H +#pragma once #include #include @@ -492,5 +491,3 @@ EXTERN const size_t kTVTranslate INIT( = TV_TRANSLATE); #ifdef INCLUDE_GENERATED_DECLARATIONS # include "eval/typval.h.generated.h" #endif - -#endif // NVIM_EVAL_TYPVAL_H -- cgit From 488038580934f301c1528a14548ec0cabd16c2cd Mon Sep 17 00:00:00 2001 From: dundargoc Date: Fri, 10 Nov 2023 14:06:04 +0100 Subject: build: adjust clang-tidy warning exclusion logic Enable all clang-tidy warnings by default instead of disabling them. This ensures that we don't miss useful warnings on each clang-tidy version upgrade. A drawback of this is that it will force us to either fix or adjust the warnings as soon as possible. --- src/nvim/eval/typval.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 751b9646b3..d39425a327 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -339,7 +339,7 @@ extern bool tv_in_free_unref_items; /// @param[in] l List to iterate over. /// @param li Name of the variable with current listitem_T entry. /// @param code Cycle body. -#define _TV_LIST_ITER_MOD(modifier, l, li, code) \ +#define TV_LIST_ITER_MOD(modifier, l, li, code) \ do { \ modifier list_T *const l_ = (l); \ if (l_ != NULL) { \ @@ -359,7 +359,7 @@ extern bool tv_in_free_unref_items; /// @param li Name of the variable with current listitem_T entry. /// @param code Cycle body. #define TV_LIST_ITER(l, li, code) \ - _TV_LIST_ITER_MOD( , l, li, code) // NOLINT(whitespace/parens) + TV_LIST_ITER_MOD( , l, li, code) // NOLINT(whitespace/parens) /// Iterate over a list /// @@ -370,7 +370,7 @@ extern bool tv_in_free_unref_items; /// @param li Name of the variable with current listitem_T entry. /// @param code Cycle body. #define TV_LIST_ITER_CONST(l, li, code) \ - _TV_LIST_ITER_MOD(const, l, li, code) + TV_LIST_ITER_MOD(const, l, li, code) // Below macros are macros to avoid duplicating code for functionally identical // const and non-const function variants. -- cgit From 6361806aa28edca55ad3316a58bc3e936df9c0eb Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 26 Nov 2023 22:58:52 +0800 Subject: refactor: move garray_T to garray_defs.h (#26227) --- src/nvim/eval/typval.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index d39425a327..b9f2f9b1b0 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -8,7 +8,7 @@ #include "nvim/eval/typval_defs.h" #include "nvim/func_attr.h" -#include "nvim/garray.h" +#include "nvim/garray_defs.h" #include "nvim/gettext.h" #include "nvim/hashtab.h" #include "nvim/lib/queue.h" -- cgit From 09541d514dd18bf86f673d3784d406236fcbdad8 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Mon, 27 Nov 2023 09:51:26 +0800 Subject: build(IWYU): replace public-to-public mappings with pragmas (#26237) --- src/nvim/eval/typval.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index b9f2f9b1b0..252dea2b64 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -6,7 +6,7 @@ #include #include -#include "nvim/eval/typval_defs.h" +#include "nvim/eval/typval_defs.h" // IWYU pragma: export #include "nvim/func_attr.h" #include "nvim/garray_defs.h" #include "nvim/gettext.h" -- cgit From 6c14ae6bfaf51415b555e9a6b85d1d280976358d Mon Sep 17 00:00:00 2001 From: dundargoc Date: Mon, 27 Nov 2023 20:27:32 +0100 Subject: refactor: rename types.h to types_defs.h --- src/nvim/eval/typval.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index 252dea2b64..b8466b6943 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -15,7 +15,7 @@ #include "nvim/macros.h" #include "nvim/mbyte_defs.h" #include "nvim/message.h" -#include "nvim/types.h" +#include "nvim/types_defs.h" // In a hashtab item "hi_key" points to "di_key" in a dictitem. // This avoids adding a pointer to the hashtab item. -- cgit From 79b6ff28ad1204fbb4199b9092f5c578d88cb28e Mon Sep 17 00:00:00 2001 From: dundargoc Date: Tue, 28 Nov 2023 20:31:00 +0100 Subject: refactor: fix headers with IWYU --- src/nvim/eval/typval.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/nvim/eval/typval.h') diff --git a/src/nvim/eval/typval.h b/src/nvim/eval/typval.h index b8466b6943..58f74a9796 100644 --- a/src/nvim/eval/typval.h +++ b/src/nvim/eval/typval.h @@ -12,7 +12,7 @@ #include "nvim/gettext.h" #include "nvim/hashtab.h" #include "nvim/lib/queue.h" -#include "nvim/macros.h" +#include "nvim/macros_defs.h" #include "nvim/mbyte_defs.h" #include "nvim/message.h" #include "nvim/types_defs.h" -- cgit