diff options
| author | 2025-12-22 08:58:43 +0100 | |
|---|---|---|
| committer | 2025-12-22 08:58:43 +0100 | |
| commit | 6bb6fb79350945951b26864d2a8c433053bbca0d (patch) | |
| tree | b92f9ea88f5d6aae2b798d6035ce1d066e1ed917 /c | |
| parent | 6fc94fd3f7edad42e77426153f9933376b621142 (diff) | |
c: Fix some dumb uses of initialized stuff
Can't figure out what's wrong with the change to struct expr from 9721d6ba40
but it makes valgrind complain and causes miscompilation of the compiler
itself..
Diffstat (limited to 'c')
| -rw-r--r-- | c/c.h | 12 | ||||
| -rw-r--r-- | c/lex.c | 10 |
2 files changed, 12 insertions, 10 deletions
@@ -25,18 +25,16 @@ enum exprkind { struct expr { uchar t; uchar qual; + ushort narg; /* ECALL */ union type ty; struct span span; union { struct { struct expr *sub; /* child(ren) */ - union { - struct exgetfld { - ushort off; - uchar bitsiz, bitoff; - } fld; /* EGETF */ - ushort narg; /* ECALL */ - }; + struct exgetfld { + ushort off; + uchar bitsiz, bitoff; + } fld; /* EGETF */ }; uvlong u; vlong i; double f; /* ENUMLIT */ struct { @@ -545,11 +545,12 @@ Begin: --lx->chrbuf0; if (lx->chrbuf0 + MAXLITLEN >= countof(lx->chrbuf)) fillchrbuf(lx); - uchar *p = &lx->chrbuf[lx->chrbuf0]; int n = 1; + uchar *p = &lx->chrbuf[lx->chrbuf0]; for (; isppnum(p[n-1], p[n]); ++n) { - if (n >= MAXLITLEN) TooLong: { + if (n >= MAXLITLEN) { lx->chridx = lx->chridxbuf[lx->chrbuf0+n-1]; + TooLong: fatal(&(struct span) {{ idx, lx->chridx - idx, lx->fileid }}, "token is too long"); } @@ -571,7 +572,10 @@ Begin: uchar *p = &lx->chrbuf[lx->chrbuf0]; int n = 1; for (; !aissep(p[n]); ++n) { - if (n >= MAXLITLEN) goto TooLong; + if (n >= MAXLITLEN) { + lx->chridx = lx->chridxbuf[lx->chrbuf0+n-1]; + goto TooLong; + } } tk->blue = 0; tk->len = n; |