emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some issues with the tree-sitter branch


From: Yuan Fu
Subject: Re: Some issues with the tree-sitter branch
Date: Sun, 16 Oct 2022 21:53:06 -0700


> On Oct 16, 2022, at 6:32 AM, Eli Zaretskii <eliz@gnu.org> wrote:
> 
> I noticed several minor issues with the branch while reading the code:
> 
> . Several places assign EMACS_INT values to uint32_t variables with
>   an explicit range check (and error signal in case of overflow).

I think you meant the lack of a range check? Like mentioned here:

+  /* FIXME: We should signal an error below if START_BYTE
+     etc. overflow the 32-bit unsigned data type.  */

I added buffer size check at parser creation time, and used casts to uint32_t 
liberally, assuming the values never overflows and, so we don’t need to handle 
the error at a million places. But I should have added checks in ts_after_chang 
and other places where buffer size could change. I’ll add checks in 
ts_after_change and other places, and if the argumetns overflows uint32, it 
will set a flag (say, buffer_too_large) in the parser object, and next time any 
lisp function tries to use that parser, an buffer-too-large error will be 
signaled. WDYT?

> . Several functions produce Lisp_Object results by reference, and
>   callers pass to them pointers to Lisp_Object variables.  Our style
>   prefers returning a Lisp_Object value through the return value,
>   like this:
> 
>      Lisp_Object some_var = some_func (...);
> 
>   When a function produces a single value, I think the above is
>   preferable.

Got it.

> . There's a call to malloc in Ftreesit_parser_set_included_ranges
>   which doesn't check the return value of malloc, and doesn't signal
>   memory-full error when malloc fails (that function should perhaps
>   use SAFE_ALLOCA).

I’ll fix that.

> 
> In addition, the style of treesit.c (indentation etc.) is not exactly
> ours (but this can be fixed later).
> 
> Thank you for your work on this important feature.

Thank you!

I see that you fixed them, I’ll keep those in mind in the future. That’s a lot 
of lines you need to change, sorry about that :-(

Yuan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]