GLContextProvider::ContextFormat() calls memset with arguments reversed, and ends up with a no-op.

RESOLVED DUPLICATE of bug 567190

Status

()

Core
Graphics
RESOLVED DUPLICATE of bug 567190
8 years ago
8 years ago

People

(Reporter: dholbert, Assigned: dholbert)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Whiteboard: [build_warning])

Attachments

(1 attachment)

(Assignee)

Description

8 years ago
{
In function ‘void* memset(void*, int, size_t)’,
    inlined from ‘mozilla::gl::GLContextProvider::ContextFormat::ContextFormat(mozilla::gl::GLContextProvider::ContextFormat::StandardContextFormat)’ at ../../../dist/include/GLContextProvider.h:65,
    inlined from ‘(static initializers for /usr/include/bits/string3.h)’ at ../../../../mozilla/gfx/thebes/src/GLContext.cpp:55:
/usr/include/bits/string3.h:83: warning: call to ‘__warn_memset_zero_len’ declared with attribute warning: memset used with constant zero length parameter; this could be due to transposed parameters
}

Looks like the warning is right - unwrapping the inlining, the blamed line is:
> 64         ContextFormat(const StandardContextFormat cf) {
> 65             memset(this, sizeof(ContextFormat), 0);
http://hg.mozilla.org/mozilla-central/annotate/6d70525ff299/gfx/thebes/public/GLContextProvider.h#l64

That's clearly trying to zero out |*this|.  However, it ends up doing nothing, since 0 is actually passed in the |count| argument. (The 2nd and 3rd argument are swapped.)
http://www.cplusplus.com/reference/clibrary/cstring/memset/
(Assignee)

Updated

8 years ago
Whiteboard: [build_warning]
(Assignee)

Comment 1

8 years ago
Created attachment 446150 [details] [diff] [review]
fix
Assignee: nobody → dholbert
Status: NEW → ASSIGNED
Attachment #446150 - Flags: review?(vladimir)
(Assignee)

Comment 2

8 years ago
It looks like bug 567190 has fixed this. (It was filed a few days after this bug, but it's the patch that got review & landed, so I'm duping this one to that one.)
Status: ASSIGNED → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 567190
(Assignee)

Updated

8 years ago
Attachment #446150 - Flags: review?(vladimir)
You need to log in before you can comment on or make changes to this bug.