[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New warning
From: |
Eli Zaretskii |
Subject: |
Re: New warning |
Date: |
Tue, 06 Jun 2023 19:14:11 +0300 |
> From: Eshel Yaron <me@eshelyaron.com>
> Cc: emacs-devel@gnu.org
> Date: Tue, 06 Jun 2023 18:59:14 +0300
>
> Po Lu <luangruo@yahoo.com> writes:
>
> > Since a previous commit, I get:
> >
> > ../../emacs/src/window.c: In function ‘window_wants_header_line’:
> > ../../emacs/src/window.c:5546:19: warning: potential null pointer
> > dereference [-Wnull-dereference]
> > 5546 | || !null_header_line_format (BVAR (XBUFFER
> > (WINDOW_BUFFER (w)),
> > |
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 5547 |
> > header_line_format), f))
> > |
> > ~~~~~~~~~~~~~~~~~~~~~~~
> >
> > Would someone please look into this?
> > Thanks.
>
> Hmm, clang doesn't emit this warning (and I didn't try compiling with
> gcc before submitting that patch, sorry about that).
>
> The following seems to silence this warning with gcc 13.1, but I'm not
> sure I fully understand why/when WINDOW_BUFFER might return NULL, so I'm
> not sure it's the right thing to do... Any insights?
WINDOW_BUFFER returns a Lisp object, so using !WINDOW_BUFFER is wrong
(and will cause compilation errors with some configure options). You
want to use either BUFFERP (WINDOW_BUFFER (w)) or
NILP (WINDOW_BUFFER (w)).
In which case this is AFAIU a bogus warning, since we already test
WINDOW_LEAF_P. So I'm not sure what exactly did GCC see there (my
version of GCC doesn't emit any warnings there). And I don't know how
to ask GCC which part triggered the warning.