unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* New unwind-protect byte-compiler warning
@ 2023-03-30  8:01 Mattias Engdegård
  2023-03-30 10:08 ` Emanuel Berg
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Mattias Engdegård @ 2023-03-30  8:01 UTC (permalink / raw)
  To: emacs-devel

On master, the byte-compiler now warns about `unwind-protect` forms lacking actual unwinding code, which is very often a mistake. An Emacs build currently yields about 30 warnings of this kind.

I'm mostly going to wait for those with good knowledge about the code causing each warning to deal with it. Tell me if I can be of further help. There's no strong urgency.

This will eventually leave some warnings claimed by no-one for me to take on, which will be done in a conservative way, maybe after a week.




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

* Re: New unwind-protect byte-compiler warning
  2023-03-30  8:01 New unwind-protect byte-compiler warning Mattias Engdegård
@ 2023-03-30 10:08 ` Emanuel Berg
  2023-04-01 22:56 ` Basil L. Contovounesios
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 10+ messages in thread
From: Emanuel Berg @ 2023-03-30 10:08 UTC (permalink / raw)
  To: emacs-devel

Mattias Engdegård wrote:

> On master, the byte-compiler now warns about
> `unwind-protect` forms lacking actual unwinding code, which
> is very often a mistake. An Emacs build currently yields
> about 30 warnings of this kind.

Yep, noticed that but it should also be said that when you
native compile stuff there are tons of warnings, seemingly
everywhere, and not just that one, but sure, that one is there
all the time, almost.

-- 
underground experts united
https://dataswamp.org/~incal




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

* Re: New unwind-protect byte-compiler warning
  2023-03-30  8:01 New unwind-protect byte-compiler warning Mattias Engdegård
  2023-03-30 10:08 ` Emanuel Berg
@ 2023-04-01 22:56 ` Basil L. Contovounesios
  2023-04-04 10:32 ` Robert Pluim
  2023-04-07 17:40 ` Mattias Engdegård
  3 siblings, 0 replies; 10+ messages in thread
From: Basil L. Contovounesios @ 2023-04-01 22:56 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel

Mattias Engdegård [2023-03-30 10:01 +0200] wrote:

> On master, the byte-compiler now warns about `unwind-protect` forms lacking
> actual unwinding code, which is very often a mistake. An Emacs build currently
> yields about 30 warnings of this kind.
>
> I'm mostly going to wait for those with good knowledge about the code causing
> each warning to deal with it. Tell me if I can be of further help. There's no
> strong urgency.
>
> This will eventually leave some warnings claimed by no-one for me to take on,
> which will be done in a conservative way, maybe after a week.

The patch in https://bugs.gnu.org/62599#5 tries to address the warning
in ibuf-ext.el.

Thanks,

-- 
Basil



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

* Re: New unwind-protect byte-compiler warning
  2023-03-30  8:01 New unwind-protect byte-compiler warning Mattias Engdegård
  2023-03-30 10:08 ` Emanuel Berg
  2023-04-01 22:56 ` Basil L. Contovounesios
@ 2023-04-04 10:32 ` Robert Pluim
  2023-04-04 11:20   ` Mattias Engdegård
                     ` (2 more replies)
  2023-04-07 17:40 ` Mattias Engdegård
  3 siblings, 3 replies; 10+ messages in thread
From: Robert Pluim @ 2023-04-04 10:32 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel, Juri Linkov

>>>>> On Thu, 30 Mar 2023 10:01:42 +0200, Mattias Engdegård <mattias.engdegard@gmail.com> said:

    Mattias> On master, the byte-compiler now warns about `unwind-protect` forms lacking actual unwinding code, which is very often a mistake. An Emacs build currently yields about 30 warnings of this kind.
    Mattias> I'm mostly going to wait for those with good knowledge about the code causing each warning to deal with it. Tell me if I can be of further help. There's no strong urgency.

    Mattias> This will eventually leave some warnings claimed by no-one for me to take on, which will be done in a conservative way, maybe after a week.

This one:

    In mouse-wheel-global-text-scale:
    mwheel.el:450:6: Warning: ‘unwind-protect’ without unwind forms

is because weʼre protecting against errors from
`global-text-scale-adjust', but unlike `text-scale-{in,de}crease',
that doesnʼt signal an error when you reach the scale limit.

Juri, we can add an unwind form of `t', or switch it to
`condition-case', whichever you prefer (Iʼm assuming perhaps
pessimistically that `global-text-scale-adjust' might signal in
future).

Robert
-- 



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

* Re: New unwind-protect byte-compiler warning
  2023-04-04 10:32 ` Robert Pluim
@ 2023-04-04 11:20   ` Mattias Engdegård
  2023-04-04 12:26     ` Robert Pluim
  2023-04-04 12:32   ` Gregory Heytings
  2023-04-04 16:10   ` Juri Linkov
  2 siblings, 1 reply; 10+ messages in thread
From: Mattias Engdegård @ 2023-04-04 11:20 UTC (permalink / raw)
  To: Robert Pluim; +Cc: emacs-devel, Juri Linkov

4 apr. 2023 kl. 12.32 skrev Robert Pluim <rpluim@gmail.com>:

>    In mouse-wheel-global-text-scale:
>    mwheel.el:450:6: Warning: ‘unwind-protect’ without unwind forms
> 
> is because weʼre protecting against errors from
> `global-text-scale-adjust', but unlike `text-scale-{in,de}crease',
> that doesnʼt signal an error when you reach the scale limit.
> 
> Juri, we can add an unwind form of `t'

Note that `unwind-protect` does not itself "protect against errors". An error signalled by the protected form will still be signalled after execution of the unwind forms. An unwind form of `t` makes no more sense than none at all; the value is just thrown away.

Evidently there are a few cases of

   (unwind-protect FORM CONSTANT)

in the Emacs tree (and GNU ELPA); it probably makes sense to warn about them as well since they often arise from a misunderstanding of what `unwind-protect` does.




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

* Re: New unwind-protect byte-compiler warning
  2023-04-04 11:20   ` Mattias Engdegård
@ 2023-04-04 12:26     ` Robert Pluim
  0 siblings, 0 replies; 10+ messages in thread
From: Robert Pluim @ 2023-04-04 12:26 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel, Juri Linkov

>>>>> On Tue, 4 Apr 2023 13:20:59 +0200, Mattias Engdegård <mattias.engdegard@gmail.com> said:

    Mattias> 4 apr. 2023 kl. 12.32 skrev Robert Pluim <rpluim@gmail.com>:
    >> In mouse-wheel-global-text-scale:
    >> mwheel.el:450:6: Warning: ‘unwind-protect’ without unwind forms
    >> 
    >> is because weʼre protecting against errors from
    >> `global-text-scale-adjust', but unlike `text-scale-{in,de}crease',
    >> that doesnʼt signal an error when you reach the scale limit.
    >> 
    >> Juri, we can add an unwind form of `t'

    Mattias> Note that `unwind-protect` does not itself "protect
    Mattias> against errors". An error signalled by the protected form
    Mattias> will still be signalled after execution of the unwind
    Mattias> forms. An unwind form of `t` makes no more sense than
    Mattias> none at all; the value is just thrown away.

Of course. Perhaps `ignore-errors' is what is needed here instead.

    Mattias> Evidently there are a few cases of

    Mattias>    (unwind-protect FORM CONSTANT)

    Mattias> in the Emacs tree (and GNU ELPA); it probably makes sense
    Mattias> to warn about them as well since they often arise from a
    Mattias> misunderstanding of what `unwind-protect` does.

More warnings? Why not 😺

Robert
-- 



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

* Re: New unwind-protect byte-compiler warning
  2023-04-04 10:32 ` Robert Pluim
  2023-04-04 11:20   ` Mattias Engdegård
@ 2023-04-04 12:32   ` Gregory Heytings
  2023-04-04 16:10   ` Juri Linkov
  2 siblings, 0 replies; 10+ messages in thread
From: Gregory Heytings @ 2023-04-04 12:32 UTC (permalink / raw)
  To: Robert Pluim; +Cc: Mattias Engdegård, emacs-devel, Juri Linkov

[-- Attachment #1: Type: text/plain, Size: 674 bytes --]


>
> This one:
>
>    In mouse-wheel-global-text-scale:
>    mwheel.el:450:6: Warning: ‘unwind-protect’ without unwind forms
>
> is because weʼre protecting against errors from 
> `global-text-scale-adjust', but unlike `text-scale-{in,de}crease', that 
> doesnʼt signal an error when you reach the scale limit.
>
> Juri, we can add an unwind form of `t', or switch it to 
> `condition-case', whichever you prefer (Iʼm assuming perhaps 
> pessimistically that `global-text-scale-adjust' might signal in future).
>

The byte-compiler warning is correct, this is a copy-paste error in 
e0488f89d1, the unwind-protect is unnecessary and can be removed.

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

* Re: New unwind-protect byte-compiler warning
  2023-04-04 10:32 ` Robert Pluim
  2023-04-04 11:20   ` Mattias Engdegård
  2023-04-04 12:32   ` Gregory Heytings
@ 2023-04-04 16:10   ` Juri Linkov
  2 siblings, 0 replies; 10+ messages in thread
From: Juri Linkov @ 2023-04-04 16:10 UTC (permalink / raw)
  To: Robert Pluim; +Cc: emacs-devel

> This one:
>
>     In mouse-wheel-global-text-scale:
>     mwheel.el:450:6: Warning: ‘unwind-protect’ without unwind forms
>
> is because weʼre protecting against errors from
> `global-text-scale-adjust', but unlike `text-scale-{in,de}crease',
> that doesnʼt signal an error when you reach the scale limit.
>
> Juri, we can add an unwind form of `t', or switch it to
> `condition-case', whichever you prefer (Iʼm assuming perhaps
> pessimistically that `global-text-scale-adjust' might signal in
> future).

Sorry, I don't recognize this function.  And indeed, in the
commit 1c3c8b6d58c9 I just moved it down.



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

* Re: New unwind-protect byte-compiler warning
  2023-03-30  8:01 New unwind-protect byte-compiler warning Mattias Engdegård
                   ` (2 preceding siblings ...)
  2023-04-04 10:32 ` Robert Pluim
@ 2023-04-07 17:40 ` Mattias Engdegård
  2023-04-09 14:20   ` Michael Albinus
  3 siblings, 1 reply; 10+ messages in thread
From: Mattias Engdegård @ 2023-04-07 17:40 UTC (permalink / raw)
  To: emacs-devel; +Cc: Michael Albinus

30 mars 2023 kl. 10.01 skrev Mattias Engdegård <mattias.engdegard@gmail.com>:

> This will eventually leave some warnings claimed by no-one for me to take on, which will be done in a conservative way, maybe after a week.

This has now been done. Two warnings remain but Basil has promising patches for them in the bug tracker.

Also thanks to Michael who fixed a few tramp-related warnings. Michael, here's a bonus for you uncovered by an experimental compiler change (that I didn't end up applying):

> (defun tramp-sshfs-handle-insert-file-contents
>   (filename &optional visit beg end replace)
>   "Like `insert-file-contents' for Tramp files."
>   (setq filename (expand-file-name filename))
>   (let (signal-hook-function result)
>     (unwind-protect
>         (setq result
> 	      (insert-file-contents
> 	       (tramp-fuse-local-file-name filename) visit beg end replace))
>       (when visit (setq buffer-file-name filename))
>       (cons filename (cdr result)))))

The last unwind form seems to expect its value to be used, but it is really discarded. Perhaps it's just a misplaced bracket?




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

* Re: New unwind-protect byte-compiler warning
  2023-04-07 17:40 ` Mattias Engdegård
@ 2023-04-09 14:20   ` Michael Albinus
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Albinus @ 2023-04-09 14:20 UTC (permalink / raw)
  To: Mattias Engdegård; +Cc: emacs-devel

Mattias Engdegård <mattias.engdegard@gmail.com> writes:

Hi Mattias,

> Also thanks to Michael who fixed a few tramp-related warnings. Michael, here's a bonus for you uncovered by an experimental compiler change (that I didn't end up applying):
>
>> (defun tramp-sshfs-handle-insert-file-contents
>>   (filename &optional visit beg end replace)
>>   "Like `insert-file-contents' for Tramp files."
>>   (setq filename (expand-file-name filename))
>>   (let (signal-hook-function result)
>>     (unwind-protect
>>         (setq result
>> 	      (insert-file-contents
>> 	       (tramp-fuse-local-file-name filename) visit beg end replace))
>>       (when visit (setq buffer-file-name filename))
>>       (cons filename (cdr result)))))
>
> The last unwind form seems to expect its value to be used, but it is really discarded. Perhaps it's just a misplaced bracket?

Yes, that's an error, uncovered yet. Thanks!

I've fixed this in master.

Best regards, Michael.



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

end of thread, other threads:[~2023-04-09 14:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30  8:01 New unwind-protect byte-compiler warning Mattias Engdegård
2023-03-30 10:08 ` Emanuel Berg
2023-04-01 22:56 ` Basil L. Contovounesios
2023-04-04 10:32 ` Robert Pluim
2023-04-04 11:20   ` Mattias Engdegård
2023-04-04 12:26     ` Robert Pluim
2023-04-04 12:32   ` Gregory Heytings
2023-04-04 16:10   ` Juri Linkov
2023-04-07 17:40 ` Mattias Engdegård
2023-04-09 14:20   ` Michael Albinus

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).