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 <<a href=3D"mailto:jrtc27@freebsd.org">jrtc27@freebsd.org<= /a>> 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 <imp@FreeBSD.org> wrote:<br> > <br> > The branch main has been updated by imp:<br> > <br> > 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> > <br> > commit 5dda778db63407214394c3cf63fb1312a4981024<br> > Author:=C2=A0 =C2=A0 =C2=A0Dapeng Gao <<a href=3D"mailto:dg612@cam.= ac.uk" target=3D"_blank">dg612@cam.ac.uk</a>><br> > AuthorDate: 2024-06-03 17:30:52 +0000<br> > Commit:=C2=A0 =C2=A0 =C2=A0Warner Losh <imp@FreeBSD.org><br> > CommitDate: 2024-06-03 18:14:10 +0000<br> > <br> >=C2=A0 =C2=A0 Use correct function declaration for yyerror<br> > <br> >=C2=A0 =C2=A0 According to the POSIX standard at<br> >=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> >=C2=A0 =C2=A0 `yyerror` should return `int`. Add unreachable since errx= never returns.<br> > <br> >=C2=A0 =C2=A0 Reviewed by:=C2=A0 =C2=A0 imp, kib<br> >=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> > ---<br> > usr.sbin/config/config.y | 6 ++++--<br> > 1 file changed, 4 insertions(+), 2 deletions(-)<br> > <br> > diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y<br> > index a5a9e1546c36..148959fbff2e 100644<br> > --- a/usr.sbin/config/config.y<br> > +++ b/usr.sbin/config/config.y<br> > @@ -88,7 +88,7 @@ int maxusers;<br> > <br> > #define ns(s) strdup(s)<br> > int include(const char *, int);<br> > -void yyerror(const char *s);<br> > +int yyerror(const char *s);<br> > int yywrap(void);<br> > <br> > static void newdev(char *name);<br> > @@ -299,11 +299,13 @@ NoDevice:<br> > <br> > %%<br> > <br> > -void<br> > +int<br> > yyerror(const char *s)<br> > {<br> > <br> > errx(1, "%s:%d: %s", yyfile, yyline + 1, s);<br> > + __unreachable();<br> > + return (0);<br> > }<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, "%s:%d: %s", 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't sure, but you'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>