#671 DialogF.c:648: possible bad size in memset ?

development
open
nobody
None
5
2014-08-19
2014-08-19
dcb
No

[DialogF.c:648]: (warning) Division by result of sizeof(). memset() expects a size in bytes, did you intend to multiply instead?

Boolean mnemonicUsed[UCHAR_MAX + 1];

memset(mnemonicUsed, FALSE, sizeof mnemonicUsed / sizeof *mnemonicUsed);

Maybe better code

Boolean mnemonicUsed[UCHAR_MAX + 1];

memset(mnemonicUsed, FALSE, (UCHAR + 1) * sizeof Boolean);

Related

Bugs: #671

Discussion

  • Scott Tringali
    Scott Tringali
    2014-08-19

    On 08/19/2014 03:37 PM, dcb wrote:


    [bugs:#671] http://sourceforge.net/p/nedit/bugs/671 DialogF.c:648:
    possible bad size in memset ?

    Status: open
    Group: development
    Created: Tue Aug 19, 2014 07:37 PM UTC by dcb
    Last Updated: Tue Aug 19, 2014 07:37 PM UTC
    Owner: nobody

    [DialogF.c:648]: (warning) Division by result of sizeof(). memset()
    expects a size in bytes, did you intend to multiply instead?

    Boolean mnemonicUsed[UCHAR_MAX + 1];

    memset(mnemonicUsed, FALSE, sizeof mnemonicUsed / sizeof *mnemonicUsed);

    Maybe better code

    Boolean mnemonicUsed[UCHAR_MAX + 1];

    memset(mnemonicUsed, FALSE, (UCHAR + 1) * sizeof Boolean);

    The division is just unneeded. sizeof already return the size in bytes.

     

    Related

    Bugs: #671