diff --git a/cmd/wuffs-c/internal/cgen/func.go b/cmd/wuffs-c/internal/cgen/func.go index 987cbbb8..6c5f6c69 100644 --- a/cmd/wuffs-c/internal/cgen/func.go +++ b/cmd/wuffs-c/internal/cgen/func.go @@ -40,6 +40,7 @@ type funk struct { public bool suspendible bool usesScratch bool + hasGotoOK bool shortReads []string } @@ -133,6 +134,8 @@ func (g *gen) writeFuncImpl(b *buffer, n *a.Func) error { b.writex(k.bBody) if k.suspendible && k.coroSuspPoint > 0 { b.writex(k.bBodySuspend) + } else if k.hasGotoOK { + b.writes("\ngoto ok;ok:\n") // The goto avoids the "unused label" warning. } b.writex(k.bFooter) b.writes("}\n\n") @@ -274,14 +277,12 @@ func (g *gen) writeFuncImplBodySuspend(b *buffer) error { // We've reached the end of the function body. Reset the coroutine // suspension point so that the next call to this function starts at // the top. - b.writes("\ngoto ok;\n") // Avoid the "unused label" warning. - b.writes("ok:\n") + b.writes("\ngoto ok;ok:") // The goto avoids the "unused label" warning. b.printf("self->private_impl.%s%s[0].coro_susp_point = 0;\n", cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm)) b.writes("goto exit; }\n\n") // Close the coroutine switch. - b.writes("goto suspend;\n") // Avoid the "unused label" warning. - b.writes("suspend:\n") + b.writes("goto suspend;suspend:") // The goto avoids the "unused label" warning. b.printf("self->private_impl.%s%s[0].coro_susp_point = coro_susp_point;\n", cPrefix, g.currFunk.astFunc.FuncName().Str(g.tm)) @@ -295,8 +296,7 @@ func (g *gen) writeFuncImplBodySuspend(b *buffer) error { func (g *gen) writeFuncImplFooter(b *buffer) error { if g.currFunk.suspendible { - b.writes("goto exit;\n") // Avoid the "unused label" warning. - b.writes("exit:") + b.writes("goto exit;exit:") // The goto avoids the "unused label" warning. for _, o := range g.currFunk.astFunc.In().Fields() { o := o.Field() diff --git a/cmd/wuffs-c/internal/cgen/statement.go b/cmd/wuffs-c/internal/cgen/statement.go index 1bc4c4a6..4473334a 100644 --- a/cmd/wuffs-c/internal/cgen/statement.go +++ b/cmd/wuffs-c/internal/cgen/statement.go @@ -348,8 +348,10 @@ func (g *gen) writeStatementRet(b *buffer, n *a.Ret, depth uint32) error { case t.IDError: b.writes("goto exit;") case t.IDStatus: + g.currFunk.hasGotoOK = true b.writes("goto ok;") default: + g.currFunk.hasGotoOK = true b.printf("if (status == 0) { goto ok; } else if (status > 0) { "+ "status = %sERROR_CANNOT_RETURN_A_SUSPENSION; } goto exit;", g.PKGPREFIX) } diff --git a/gen/c/std/gif.c b/gen/c/std/gif.c index 44ae82e7..f5a25850 100644 --- a/gen/c/std/gif.c +++ b/gen/c/std/gif.c @@ -3628,9 +3628,13 @@ static wuffs_gif__status wuffs_gif__decoder__copy_to_image_buffer( v_dst = wuffs_base__table_u8__linearize(v_tab); if (((uint64_t)(v_dst.len)) == 0) { } - } else { - v_dst = wuffs_base__table_u8__row(v_tab, self->private_impl.f_dst_y); + status = WUFFS_GIF__STATUS_OK; + goto ok; } + v_dst = wuffs_base__table_u8__row(v_tab, self->private_impl.f_dst_y); + + goto ok; +ok: goto exit; exit: return status; diff --git a/std/gif/decode_gif.wuffs b/std/gif/decode_gif.wuffs index 53bfe965..90a8f27c 100644 --- a/std/gif/decode_gif.wuffs +++ b/std/gif/decode_gif.wuffs @@ -505,8 +505,8 @@ pri func decoder.copy_to_image_buffer?(ib ptr base.image_buffer)() { if dst.length() == 0 { // TODO. } - } else { - dst = tab.row(y:this.dst_y) - // TODO. + return } + + dst = tab.row(y:this.dst_y) }