unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* feature/tree-sitter 3069849bd4 4/4: * src/treesit.c (treesit_load_language): Fix uninitialized uses.
@ 2022-11-21  9:37 Yuan Fu
  2022-11-21 11:59 ` Po Lu
  0 siblings, 1 reply; 3+ messages in thread
From: Yuan Fu @ 2022-11-21  9:37 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

branch: feature/tree-sitter
commit 3069849bd4c1048a8f8c0467d26560fad939e791
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>

    * src/treesit.c (treesit_load_language): Fix uninitialized uses.
---
 src/treesit.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/treesit.c b/src/treesit.c
index 291698e4e4..599a9b883e 100644
--- a/src/treesit.c
+++ b/src/treesit.c
@@ -554,9 +554,11 @@ treesit_load_language (Lisp_Object language_symbol,
      when succeed, record the error message and try the next one when
      fail.  */
   dynlib_handle_ptr handle;
-  char const *error;
+  const char *error;
 
   tail = path_candidates;
+  error = NULL;
+  handle = NULL;
 
   FOR_EACH_TAIL (tail)
     {
@@ -568,6 +570,9 @@ treesit_load_language (Lisp_Object language_symbol,
        break;
     }
 
+  /* ??? */
+  eassume (handle != NULL);
+
   if (error != NULL)
     {
       *signal_symbol = Qtreesit_load_language_error;


Thanks for working on this. What does ??? mean? Why do we assume handle is not NULL?




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: feature/tree-sitter 3069849bd4 4/4: * src/treesit.c (treesit_load_language): Fix uninitialized uses.
  2022-11-21  9:37 feature/tree-sitter 3069849bd4 4/4: * src/treesit.c (treesit_load_language): Fix uninitialized uses Yuan Fu
@ 2022-11-21 11:59 ` Po Lu
  2022-11-23  1:52   ` Yuan Fu
  0 siblings, 1 reply; 3+ messages in thread
From: Po Lu @ 2022-11-21 11:59 UTC (permalink / raw)
  To: Yuan Fu; +Cc: emacs-devel

Yuan Fu <casouri@gmail.com> writes:

> branch: feature/tree-sitter
> commit 3069849bd4c1048a8f8c0467d26560fad939e791
> Author: Po Lu <luangruo@yahoo.com>
> Commit: Po Lu <luangruo@yahoo.com>
>
>     * src/treesit.c (treesit_load_language): Fix uninitialized uses.
> ---
>  src/treesit.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/src/treesit.c b/src/treesit.c
> index 291698e4e4..599a9b883e 100644
> --- a/src/treesit.c
> +++ b/src/treesit.c
> @@ -554,9 +554,11 @@ treesit_load_language (Lisp_Object language_symbol,
>       when succeed, record the error message and try the next one when
>       fail.  */
>    dynlib_handle_ptr handle;
> -  char const *error;
> +  const char *error;
>  
>    tail = path_candidates;
> +  error = NULL;
> +  handle = NULL;
>  
>    FOR_EACH_TAIL (tail)
>      {
> @@ -568,6 +570,9 @@ treesit_load_language (Lisp_Object language_symbol,
>         break;
>      }
>  
> +  /* ??? */
> +  eassume (handle != NULL);
> +
>    if (error != NULL)
>      {
>        *signal_symbol = Qtreesit_load_language_error;
>

> Thanks for working on this. What does ??? mean? Why do we assume
> handle is not NULL?

handle can only be set if tail is non-nil, but I do not think that is
always the case.

The code below seemed to call dynlib_sym (handle, c_name) without any
checks.  I was going to ask about it, but I forgot.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: feature/tree-sitter 3069849bd4 4/4: * src/treesit.c (treesit_load_language): Fix uninitialized uses.
  2022-11-21 11:59 ` Po Lu
@ 2022-11-23  1:52   ` Yuan Fu
  0 siblings, 0 replies; 3+ messages in thread
From: Yuan Fu @ 2022-11-23  1:52 UTC (permalink / raw)
  To: Po Lu; +Cc: emacs-devel

> 
>> Thanks for working on this. What does ??? mean? Why do we assume
>> handle is not NULL?
> 
> handle can only be set if tail is non-nil, but I do not think that is
> always the case.
> 
> The code below seemed to call dynlib_sym (handle, c_name) without any
> checks.  I was going to ask about it, but I forgot.

Cool! I made a tiny change to it.

Yuan



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-11-23  1:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21  9:37 feature/tree-sitter 3069849bd4 4/4: * src/treesit.c (treesit_load_language): Fix uninitialized uses Yuan Fu
2022-11-21 11:59 ` Po Lu
2022-11-23  1:52   ` Yuan Fu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).