Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 3 Jun 2024 12:38:50 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Jessica Clarke <jrtc27@freebsd.org>
Cc:        Warner Losh <imp@freebsd.org>,  "src-committers@freebsd.org" <src-committers@freebsd.org>,  "dev-commits-src-all@freebsd.org" <dev-commits-src-all@freebsd.org>,  "dev-commits-src-main@freebsd.org" <dev-commits-src-main@freebsd.org>
Subject:   Re: git: 5dda778db634 - main - Use correct function declaration for yyerror
Message-ID:  <CANCZdfo3ThjvtLOUAXrHjscmT4uo7kf=1f%2Bx%2Bzdnxbv1kUkTew@mail.gmail.com>
In-Reply-To: <7A3BE5B2-DE9C-4317-8AC6-9CDC398C7318@freebsd.org>
References:  <202406031814.453IEsLL048613@gitrepo.freebsd.org> <7A3BE5B2-DE9C-4317-8AC6-9CDC398C7318@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000b1cf4d061a00a59f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Mon, Jun 3, 2024 at 12:19=E2=80=AFPM Jessica Clarke <jrtc27@freebsd.org>=
 wrote:

> On 3 Jun 2024, at 19:14, Warner Losh <imp@FreeBSD.org> wrote:
> >
> > The branch main has been updated by imp:
> >
> > URL:
> https://cgit.FreeBSD.org/src/commit/?id=3D5dda778db63407214394c3cf63fb131=
2a4981024
> >
> > commit 5dda778db63407214394c3cf63fb1312a4981024
> > Author:     Dapeng Gao <dg612@cam.ac.uk>
> > AuthorDate: 2024-06-03 17:30:52 +0000
> > Commit:     Warner Losh <imp@FreeBSD.org>
> > CommitDate: 2024-06-03 18:14:10 +0000
> >
> >    Use correct function declaration for yyerror
> >
> >    According to the POSIX standard at
> >    https://pubs.opengroup.org/onlinepubs/9699919799/utilities/yacc.html
> >    `yyerror` should return `int`. Add unreachable since errx never
> returns.
> >
> >    Reviewed by:    imp, kib
> >    Differential Revision:  https://reviews.freebsd.org/D45447
> > ---
> > usr.sbin/config/config.y | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
> > index a5a9e1546c36..148959fbff2e 100644
> > --- a/usr.sbin/config/config.y
> > +++ b/usr.sbin/config/config.y
> > @@ -88,7 +88,7 @@ int maxusers;
> >
> > #define ns(s) strdup(s)
> > int include(const char *, int);
> > -void yyerror(const char *s);
> > +int yyerror(const char *s);
> > int yywrap(void);
> >
> > static void newdev(char *name);
> > @@ -299,11 +299,13 @@ NoDevice:
> >
> > %%
> >
> > -void
> > +int
> > yyerror(const char *s)
> > {
> >
> > errx(1, "%s:%d: %s", yyfile, yyline + 1, s);
> > + __unreachable();
> > + return (0);
> > }
>
> This should just be:
>
> int
> yyerror(const char *s)
> {
>         errx(1, "%s:%d: %s", yyfile, yyline + 1, s);
> }
>
> errx is __dead2. See bin/expr/expr.y for an example of this in-tree.
>

OK. Wasn't sure, but you're comments remove all doubt in my mind. will fix.

Warner

--000000000000b1cf4d061a00a59f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"></div><br><div class=3D"gmail_quote"><div=
 dir=3D"ltr" class=3D"gmail_attr">On Mon, Jun 3, 2024 at 12:19=E2=80=AFPM J=
essica Clarke &lt;<a href=3D"mailto:jrtc27@freebsd.org">jrtc27@freebsd.org<=
/a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0=
px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">O=
n 3 Jun 2024, at 19:14, Warner Losh &lt;imp@FreeBSD.org&gt; wrote:<br>
&gt; <br>
&gt; The branch main has been updated by imp:<br>
&gt; <br>
&gt; URL: <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3D5dda778db634=
07214394c3cf63fb1312a4981024" rel=3D"noreferrer" target=3D"_blank">https://=
cgit.FreeBSD.org/src/commit/?id=3D5dda778db63407214394c3cf63fb1312a4981024<=
/a><br>
&gt; <br>
&gt; commit 5dda778db63407214394c3cf63fb1312a4981024<br>
&gt; Author:=C2=A0 =C2=A0 =C2=A0Dapeng Gao &lt;<a href=3D"mailto:dg612@cam.=
ac.uk" target=3D"_blank">dg612@cam.ac.uk</a>&gt;<br>
&gt; AuthorDate: 2024-06-03 17:30:52 +0000<br>
&gt; Commit:=C2=A0 =C2=A0 =C2=A0Warner Losh &lt;imp@FreeBSD.org&gt;<br>
&gt; CommitDate: 2024-06-03 18:14:10 +0000<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 Use correct function declaration for yyerror<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 According to the POSIX standard at<br>
&gt;=C2=A0 =C2=A0 <a href=3D"https://pubs.opengroup.org/onlinepubs/96999197=
99/utilities/yacc.html" rel=3D"noreferrer" target=3D"_blank">https://pubs.o=
pengroup.org/onlinepubs/9699919799/utilities/yacc.html</a><br>
&gt;=C2=A0 =C2=A0 `yyerror` should return `int`. Add unreachable since errx=
 never returns.<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 Reviewed by:=C2=A0 =C2=A0 imp, kib<br>
&gt;=C2=A0 =C2=A0 Differential Revision:=C2=A0 <a href=3D"https://reviews.f=
reebsd.org/D45447" rel=3D"noreferrer" target=3D"_blank">https://reviews.fre=
ebsd.org/D45447</a><br>
&gt; ---<br>
&gt; usr.sbin/config/config.y | 6 ++++--<br>
&gt; 1 file changed, 4 insertions(+), 2 deletions(-)<br>
&gt; <br>
&gt; diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y<br>
&gt; index a5a9e1546c36..148959fbff2e 100644<br>
&gt; --- a/usr.sbin/config/config.y<br>
&gt; +++ b/usr.sbin/config/config.y<br>
&gt; @@ -88,7 +88,7 @@ int maxusers;<br>
&gt; <br>
&gt; #define ns(s) strdup(s)<br>
&gt; int include(const char *, int);<br>
&gt; -void yyerror(const char *s);<br>
&gt; +int yyerror(const char *s);<br>
&gt; int yywrap(void);<br>
&gt; <br>
&gt; static void newdev(char *name);<br>
&gt; @@ -299,11 +299,13 @@ NoDevice:<br>
&gt; <br>
&gt; %%<br>
&gt; <br>
&gt; -void<br>
&gt; +int<br>
&gt; yyerror(const char *s)<br>
&gt; {<br>
&gt; <br>
&gt; errx(1, &quot;%s:%d: %s&quot;, yyfile, yyline + 1, s);<br>
&gt; + __unreachable();<br>
&gt; + return (0);<br>
&gt; }<br>
<br>
This should just be:<br>
<br>
int<br>
yyerror(const char *s)<br>
{<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0 errx(1, &quot;%s:%d: %s&quot;, yyfile, yyline +=
 1, s);<br>
}<br>
<br>
errx is __dead2. See bin/expr/expr.y for an example of this in-tree.<br></b=
lockquote><div><br></div><div>OK. Wasn&#39;t sure, but you&#39;re comments =
remove all doubt in my mind. will fix.</div><div><br></div><div>Warner=C2=
=A0</div></div></div>

--000000000000b1cf4d061a00a59f--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfo3ThjvtLOUAXrHjscmT4uo7kf=1f%2Bx%2Bzdnxbv1kUkTew>