From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Some issues with the tree-sitter branch Date: Sun, 16 Oct 2022 21:53:06 -0700 Message-ID: <6F240F48-E29C-4E75-B5D5-30C7CF7956C9@gmail.com> References: <83o7ub51yd.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8275"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Oct 17 06:54:08 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1okI8d-0001vL-I6 for ged-emacs-devel@m.gmane-mx.org; Mon, 17 Oct 2022 06:54:07 +0200 Original-Received: from localhost ([::1]:42700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1okI8c-0004bs-Bu for ged-emacs-devel@m.gmane-mx.org; Mon, 17 Oct 2022 00:54:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50752) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1okI7k-0003YV-8l for emacs-devel@gnu.org; Mon, 17 Oct 2022 00:53:12 -0400 Original-Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]:51092) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1okI7i-0002Qe-K5; Mon, 17 Oct 2022 00:53:11 -0400 Original-Received: by mail-pj1-x1032.google.com with SMTP id h12so9977163pjk.0; Sun, 16 Oct 2022 21:53:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=39w2xHMI/Nt2TjUvf1tVwjVbr45KACfyJPkz105Tnno=; b=iQWEm2oP7SlPUCkkzinXsnCcbHYq46r67bvAICSUSB0nv1Gi06vSl4GhpVbvWUqnOm fftj5kOj5NO+knKRgq1mNvE6ZbZ6QEvmWzALk2XpLJsDJFgN1Vp+nTTmlcRNSLv2wujs Q13YJJ13sJafKTeIGA+LhZEUano/Btm8h+/0HUO38IQLvgMzoUQsI8B32UIBbEEED5t9 fJXnZNgnsNbl/DoW535mTtlRuYCKYF17Hn+yqsFW+mkDzc/xqrfISt7BY5QXTpQjkU/J m0ViAjG2dVApMCsqcuRH4dAHl/L1QLmywNDQn86CpjHx/5sLD9qIXA1RDHENo2E44qZe ClpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=39w2xHMI/Nt2TjUvf1tVwjVbr45KACfyJPkz105Tnno=; b=kjPXk5tb9jrtAJm1VK5cQWv1YHmiCAzBYflMNPUtDDMx+CeR5vwTf8+PSgw2rzfpHT wzP8nKqvjugB8ZioJH2nnvcW6OishclFgu0oQ5iBNpthDzi3lhsT2xkLjsATJDey748u KE6vNoPjX7CelTTLNJwBcHO41LnUP2d4G+vrosayMEtyg7pEECuJ7o4bUxQDdlo8oKZZ oKI6Mm7FtIczoFyidAXHtEhr7+Yh+AJK4kvATNsWP8j9vX2vj6PXb0nrHCTJwuY4XNkn fd/p6g1Qf24ROeHLRFnfXJB/8J/WZ9Bv+agxVpVysAvkbXTgqaLkwitlDTa/BvGPFBRU D/hg== X-Gm-Message-State: ACrzQf36iQ2MqMuPxCpVjyA5sALdooxTwMQfD3wo6JjYLHDx94k6fLd2 AD1rwr+n8qpGAbaxnsVENjD/g3yVb+k= X-Google-Smtp-Source: AMsMyM6jYcQKvuflJ7lTaQyWAg5LNiW+GYRId8/KCEbXll/Qal/Mm81EgnQ3MObMfidKVbZFysDQGQ== X-Received: by 2002:a17:90b:3b8d:b0:20d:5829:8d97 with SMTP id pc13-20020a17090b3b8d00b0020d58298d97mr30747669pjb.105.1665982388359; Sun, 16 Oct 2022 21:53:08 -0700 (PDT) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id n123-20020a622781000000b0053b723a74f7sm6061698pfn.90.2022.10.16.21.53.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 16 Oct 2022 21:53:07 -0700 (PDT) In-Reply-To: <83o7ub51yd.fsf@gnu.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) Received-SPF: pass client-ip=2607:f8b0:4864:20::1032; envelope-from=casouri@gmail.com; helo=mail-pj1-x1032.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:297904 Archived-At: > On Oct 16, 2022, at 6:32 AM, Eli Zaretskii wrote: >=20 > I noticed several minor issues with the branch while reading the code: >=20 > . 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=E2=80=99t 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=E2=80=99ll 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: >=20 > Lisp_Object some_var =3D some_func (...); >=20 > 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=E2=80=99ll fix that. >=20 > In addition, the style of treesit.c (indentation etc.) is not exactly > ours (but this can be fixed later). >=20 > Thank you for your work on this important feature. Thank you! I see that you fixed them, I=E2=80=99ll keep those in mind in the = future. That=E2=80=99s a lot of lines you need to change, sorry about = that :-( Yuan