php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61477 Fix C compilation warnings
Submitted: 2012-03-22 17:55 UTC Modified: 2012-03-24 23:58 UTC
From: nolte at adobe dot com Assigned: bd808 (profile)
Status: Closed Package: yaml (PECL)
PHP Version: 5.3.10 OS: Mac OS X 10.7.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: nolte at adobe dot com
New email:
PHP Version: OS:

 

 [2012-03-22 17:55 UTC] nolte at adobe dot com
Description:
------------
Yaml.c zeroes just a pointer's worth of the state buffer instead of the whole 
thing.  It should use "sizeof(state)" instead of "sizeof(&state)".

Emit.c is passing an char* instead of an unsigned char* (aka yaml_char_t*) and 
needs an explicit cast.

Test script:
---------------
% phpize
% ./configure
% make

Expected result:
----------------
<no compilation warnings>

Actual result:
--------------
/Users/enolte/src/pecl/yaml/yaml.c:419:27: warning: argument to 'sizeof' in
      '__builtin___memset_chk' call is the same expression as the destination;
      did you mean to remove the addressof? [-Wsizeof-pointer-memaccess]
        memset(&state, 0, sizeof(&state));
        ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/secure/_string.h:77:41: note: expanded from macro 'memset'
   ? __builtin___memset_chk (dest, val, len, __darwin_obsz0 (dest))     \
                                        ^
/Users/enolte/src/pecl/yaml/yaml.c:509:27: warning: argument to 'sizeof' in
      '__builtin___memset_chk' call is the same expression as the destination;
      did you mean to remove the addressof? [-Wsizeof-pointer-memaccess]
        memset(&state, 0, sizeof(&state));
        ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/secure/_string.h:77:41: note: expanded from macro 'memset'
   ? __builtin___memset_chk (dest, val, len, __darwin_obsz0 (dest))     \
                                        ^
/Users/enolte/src/pecl/yaml/yaml.c:612:27: warning: argument to 'sizeof' in
      '__builtin___memset_chk' call is the same expression as the destination;
      did you mean to remove the addressof? [-Wsizeof-pointer-memaccess]
        memset(&state, 0, sizeof(&state));
        ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
/usr/include/secure/_string.h:77:41: note: expanded from macro 'memset'
   ? __builtin___memset_chk (dest, val, len, __darwin_obsz0 (dest))     \
                                        ^
3 warnings generated.


/Users/enolte/src/pecl/yaml/emit.c:749:39: warning: passing 'char *' to
      parameter of type 'yaml_char_t *' (aka 'unsigned char *') converts between
      pointers to integer types with different sign [-Wpointer-sign]
        return y_write_zval(state, (*zdata), Z_STRVAL_PP(ztag) TSRMLS_CC);
                                             ^~~~~~~~~~~~~~~~~
/opt/local/include/php/Zend/zend_operators.h:422:30: note: expanded from macro
      'Z_STRVAL_PP'
#define Z_STRVAL_PP(zval_pp)    Z_STRVAL(**zval_pp)
                                ^
/opt/local/include/php/Zend/zend_operators.h:392:26: note: expanded from macro
      'Z_STRVAL'
#define Z_STRVAL(zval)                  (zval).value.str.val
                                        ^~~~~~~~~~~~~~~~~~~~
/Users/enolte/src/pecl/yaml/emit.c:238:51: note: passing argument to parameter
      'tag' here
                y_emit_state_t *state, zval *data, yaml_char_t *tag TSRMLS_DC)
                                                                ^
1 warning generated.


Patches

yaml-warnings.patch (last revision 2012-03-22 17:56 UTC by nolte at adobe dot com)

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-22 20:36 UTC] bd808@php.net
-Assigned To: +Assigned To: bd808
 [2012-03-24 23:50 UTC] bd808@php.net
Automatic comment from SVN on behalf of bd808
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=324513
Log: Bug #61477: fix compiler warnings in emit.c
 [2012-03-24 23:57 UTC] bd808@php.net
Automatic comment from SVN on behalf of bd808
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=324514
Log: Bug #61477: memset sizeof(struct) instead of sizeof(pointer).
 [2012-03-24 23:58 UTC] bd808@php.net
-Status: Assigned +Status: Closed
 [2012-03-24 23:58 UTC] bd808@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Fri Dec 03 07:03:34 2021 UTC