mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Avoid "goto exit" bypassing variable init'n
This commit is contained in:
1 parent
f82c33db2f
commit
98ccfedc96
2 files changed
+12
-8
No files matched your search
@@ -191,10 +191,6 @@ func (g *gen) writeFuncImplHeader(b *buffer) error {
|
|||||||
b.writes("}\n")
|
b.writes("}\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
if g.currFunk.suspendible {
|
|
||||||
b.printf("%sstatus status = %sSTATUS_OK;\n", g.pkgPrefix, g.PKGPREFIX)
|
|
||||||
}
|
|
||||||
|
|
||||||
// For public functions, check (at runtime) the other args for bounds and
|
// For public functions, check (at runtime) the other args for bounds and
|
||||||
// null-ness. For private functions, those checks are done at compile time.
|
// null-ness. For private functions, those checks are done at compile time.
|
||||||
if g.currFunk.public {
|
if g.currFunk.public {
|
||||||
@@ -202,6 +198,10 @@ func (g *gen) writeFuncImplHeader(b *buffer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if g.currFunk.suspendible {
|
||||||
|
b.printf("%sstatus status = %sSTATUS_OK;\n", g.pkgPrefix, g.PKGPREFIX)
|
||||||
|
}
|
||||||
b.writes("\n")
|
b.writes("\n")
|
||||||
|
|
||||||
// Generate the local variables.
|
// Generate the local variables.
|
||||||
@@ -369,8 +369,12 @@ func (g *gen) writeFuncImplArgChecks(b *buffer, n *a.Func) error {
|
|||||||
}
|
}
|
||||||
b.writes(") {")
|
b.writes(") {")
|
||||||
if g.currFunk.suspendible {
|
if g.currFunk.suspendible {
|
||||||
b.printf("status = %sERROR_BAD_ARGUMENT; goto exit;", g.PKGPREFIX)
|
if g.currFunk.public {
|
||||||
|
b.printf("self->private_impl.status = %sERROR_BAD_ARGUMENT;\n", g.PKGPREFIX)
|
||||||
|
}
|
||||||
|
b.printf("return %sERROR_BAD_ARGUMENT;\n\n", g.PKGPREFIX)
|
||||||
} else if !n.Receiver().IsZero() {
|
} else if !n.Receiver().IsZero() {
|
||||||
|
// TODO: unused code path??
|
||||||
b.printf("self->private_impl.status = %sERROR_BAD_ARGUMENT; return;", g.PKGPREFIX)
|
b.printf("self->private_impl.status = %sERROR_BAD_ARGUMENT; return;", g.PKGPREFIX)
|
||||||
} else {
|
} else {
|
||||||
b.printf("return;")
|
b.printf("return;")
|
||||||
|
|||||||
+3
-3
@@ -869,11 +869,11 @@ wuffs_gif__status wuffs_gif__decoder__decode_config(
|
|||||||
if (self->private_impl.status < 0) {
|
if (self->private_impl.status < 0) {
|
||||||
return self->private_impl.status;
|
return self->private_impl.status;
|
||||||
}
|
}
|
||||||
wuffs_gif__status status = WUFFS_GIF__STATUS_OK;
|
|
||||||
if (!a_dst) {
|
if (!a_dst) {
|
||||||
status = WUFFS_GIF__ERROR_BAD_ARGUMENT;
|
self->private_impl.status = WUFFS_GIF__ERROR_BAD_ARGUMENT;
|
||||||
goto exit;
|
return WUFFS_GIF__ERROR_BAD_ARGUMENT;
|
||||||
}
|
}
|
||||||
|
wuffs_gif__status status = WUFFS_GIF__STATUS_OK;
|
||||||
|
|
||||||
uint8_t* b_rptr_src = NULL;
|
uint8_t* b_rptr_src = NULL;
|
||||||
uint8_t* b_rstart_src = NULL;
|
uint8_t* b_rstart_src = NULL;
|
||||||
|
|||||||
Reference in new issue
Block a user