php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60822 Compile warnings: Bucket.arKey type change from 5.3 -> 5.4
Submitted: 2012-01-20 19:04 UTC Modified: 2012-01-23 10:02 UTC
From: uw@php.net Assigned: uw (profile)
Status: Closed Package: APC (PECL)
PHP Version: 5.4SVN-2012-01-20 (SVN) OS:
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: uw@php.net
New email:
PHP Version: OS:

 

 [2012-01-20 19:04 UTC] uw@php.net
Description:
------------
APC: pecl/svn - trunk (Revision 322504)
PHP: 5_4, svn - PHP 5.4.0RC7-dev
Static build: ./configure  --enable-apc --enable-debug --enable-maintainer-zts
GCC: gcc (SUSE Linux) 4.6.2


GCC bails a bit on char*/const char* differences in apc_string.c:


nst’ qualifier from pointer target type [enabled by default]
/usr/include/string.h:44:14: note: expected ‘void * __restrict__’ but argument is of type ‘const char *’
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:126:5: warning: return discards ‘const’ qualifier from pointer target type [enabled by default]
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c: In function ‘apc_copy_internal_strings’:
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:136:13: warning: passing argument 1 of ‘apc_new_interned_string’ discards ‘const’ qualifier from pointer target type [enabled by default]
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:68:7: note: expected ‘char *’ but argument is of type ‘const char *’
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:146:13: warning: passing argument 1 of ‘apc_new_interned_string’ discards ‘const’ qualifier from pointer target type [enabled by default]
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:68:7: note: expected ‘char *’ but argument is of type ‘const char *’
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:150:4: warning: passing argument 1 of ‘apc_new_interned_string’ discards ‘const’ qualifier from pointer target type [enabled by default]
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:68:7: note: expected ‘char *’ but argument is of type ‘const char *’
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:158:17: warning: passing argument 1 of ‘apc_new_interned_string’ discards ‘const’ qualifier from pointer target type [enabled by default]
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:68:7: note: expected ‘char *’ but argument is of type ‘const char *’
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:162:17: warning: passing argument 1 of ‘apc_new_interned_string’ discards ‘const’ qualifier from pointer target type [enabled by default]
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:68:7: note: expected ‘char *’ but argument is of type ‘const char *’
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:171:17: warning: passing argument 1 of ‘apc_new_interned_string’ discards ‘const’ qualifier from pointer target type [enabled by default]
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:68:7: note: expected ‘char *’ but argument is of type ‘const char *’
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:179:17: warning: passing argument 1 of ‘apc_new_interned_string’ discards ‘const’ qualifier from pointer target type [enabled by default]
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:68:7: note: expected ‘char *’ but argument is of type ‘const char *’
/home/nixnutz/php-src/branches/PHP_5_4/ext/apc/apc_string.c:190:13: warning: passing argument 1 of ‘apc_new_interned_string’ discards ‘const’ qualifier from pointer target type [enabled by default]


apc_new_interned_string() seems to have been created to copy arKey members of a Bucket. arKey is defined as a const char* in PHP 5.4:


typedef struct bucket {
	ulong h;						/* Used for numeric indexing */
	uint nKeyLength;
	void *pData;
	void *pDataPtr;
	struct bucket *pListNext;
	struct bucket *pListLast;
	struct bucket *pNext;
	struct bucket *pLast;
	const char *arKey;
} Bucket;

In PHP 5.3 there is no const qualifier for arKey:

     53 
     54 typedef struct bucket {
     55 	ulong h;						/* Used for numeric indexing */
     56 	uint nKeyLength;
     57 	void *pData;
     58 	void *pDataPtr;
     59 	struct bucket *pListNext;
     60 	struct bucket *pListLast;
     61 	struct bucket *pNext;
     62 	struct bucket *pLast;
     63 	char arKey[1]; /* Must be last element */
     64 } Bucket;


Please, update APC to avoid the compiler warnings. For example, change the apc_new_interned_string() signature in 5.4 to:

const char *apc_new_interned_string(const char *arKey, int nKeyLength TSRMLS_DC)






Test script:
---------------
./configure  --enable-apc --enable-debug --enable-maintainer-zts

Check out for APC related compiler warnings


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-21 04:56 UTC] rasmus@php.net
Yup, go ahead. Commit the fix.
 [2012-01-21 04:56 UTC] rasmus@php.net
-Status: Open +Status: Feedback
 [2012-01-23 10:01 UTC] uw@php.net
Automatic comment from SVN on behalf of uw
Revision: http://svn.php.net/viewvc/?view=revision&revision=322617
Log: Fix bug #60822. Avoid compiler warnings - Bucket arKey is const char* in PHP 5.4
 [2012-01-23 10:02 UTC] uw@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: uw
 [2012-01-23 10:02 UTC] uw@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.

http://news.php.net/php.pecl.cvs/17491
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 16:01:27 2024 UTC