On Sun, Jul 12, 2020 at 09:10:57AM +0200, Otto Moerbeek wrote:
> On Sun, Jul 12, 2020 at 09:57:02AM +0430, Ali Farzanrad wrote:
>
> > Hi @tech,
> >
> > I was comparing jsmn.c in acme-client with jsmn.c in FreeBSD [1].
> > I found a switch without a default case which is an undefined behavior:
> >
> > @@ -69,6 +69,8 @@
> > case '\t' : case '\r' : case '\n' : case ' ' :
> > case ',' : case ']' : case '}' :
> > goto found;
> > + default:
> > + break;
> > }
> > if (js[parser->pos] < 32 || js[parser->pos] >= 127) {
> > parser->pos = start;
> >
> > I have patched that undefined behavior + some style fix.
>
> It is bad practise to intermix style changes with bug fixes.
> Please post the fix seperately.
It's also not undefined behaviour.
ISO/IEC 9899:1999 6.8.4.2:
If no converted case constant expression matches and there is no
default label, no part of the switch body is executed.
Not having a default case might be considered bad style in itself
though.
>
> -Otto
>
--
I'm not entirely sure you are real.