Skip to content

incorrect memset() in fpu.c #20

@mitchblank

Description

@mitchblank

In addition to the build error described in #15 a modern compiler gives this warning:

../intermediates/fpu.post.c:3573:38: warning: 'size' argument to memset is '0'; did you mean to transpose the last two arguments? [-Wmemset-transposed-args]
 3573 |     memset(fpu, sizeof(fpu_state_t), 0);

Definitely looks like the warning is indicating a real error. To fix:

diff --git a/core/fpu.c b/core/fpu.c
index ce50a37..29ac717 100644
--- a/core/fpu.c
+++ b/core/fpu.c
@@ -3289,7 +3289,7 @@ void inst_fpu_other () {
 void fpu_initialize()
 {
     fpu_state_t *fpu = (fpu_state_t*)p_alloc(shoe.pool, sizeof(fpu_state_t));
-    memset(fpu, sizeof(fpu_state_t), 0);
+    memset(fpu, 0, sizeof(*fpu));
     shoe.fpu_state = fpu;
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions