libvirt-php 0.4.5 and php 5.4

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I'm working on updating PHP to 5.4.0 (probably a fedora 17 feature).

libvirt 0.4.5 doesn't build because function_entry have been removed
See http://news.php.net/php.pecl.dev/7123

Fix is trivial :
	s/function_entry/zend_function_entry/

Attcached patch solves this issue and also fixes a lot of compiler
warning (unused variable, unset, ...)

There is still a lot of warning... (most are trivial to fix)

I Hope this helps.
Remi.



P.S. Here is the full log (with -Wall)


Making all in src
make[3]: Entering directory `/dev/shm/libvirt-php-0.4.5/src'
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic
-DCOMPILE_DL_LIBVIRT=1 -I/usr/include/php -I/usr/include/php/main
-I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext
-I/usr/include/php/ext/date/lib -c -o libvirt-php.o libvirt-php.c
-I/usr/include/libxml2   -DHAVE_CONFIG_H
rm -f *.o
libvirt-php.c: In function 'zif_libvirt_domain_send_keys':
libvirt-php.c:3002:2: warning: pointer targets in passing argument 3 of
'vnc_send_keys' differ in signedness [-Wpointer-sign]
libvirt-php.h:200:5: note: expected 'unsigned char *' but argument is of
type 'char *'
libvirt-php.c: In function 'zif_libvirt_image_create':
libvirt-php.c:1674:8: warning: ignoring return value of 'system',
declared with attribute warn_unused_result [-Wunused-result]
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic
-DCOMPILE_DL_LIBVIRT=1 -c -o vncfunc.o vncfunc.c -I/usr/include/php
-I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend
-I/usr/include/php/ext -I/usr/include/php/ext/date/lib
-I/usr/include/libxml2   -DHAVE_CONFIG_H
vncfunc.c: In function 'vnc_parse_fb_params':
vncfunc.c:178:2: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness [-Wpointer-sign]
/usr/include/string.h:399:15: note: expected 'const char *' but argument
is of type 'unsigned char *'
vncfunc.c:178:2: warning: pointer targets in passing argument 1 of
'__strdup' differ in signedness [-Wpointer-sign]
/usr/include/bits/string2.h:1303:14: note: expected 'const char *' but
argument is of type 'unsigned char *'
vncfunc.c:178:21: warning: pointer targets in assignment differ in
signedness [-Wpointer-sign]
vncfunc.c:141:17: warning: unused variable 'name' [-Wunused-variable]
vncfunc.c:139:6: warning: unused variable 'i' [-Wunused-variable]
vncfunc.c: In function 'vnc_send_key':
vncfunc.c:205:6: warning: unused variable 'i' [-Wunused-variable]
vncfunc.c: In function 'vnc_connect':
vncfunc.c:438:2: warning: implicit declaration of function
'connect_socket' [-Wimplicit-function-declaration]
vncfunc.c: In function 'vnc_get_dimensions':
vncfunc.c:511:2: warning: pointer targets in passing argument 1 of
'vnc_parse_fb_params' differ in signedness [-Wpointer-sign]
vncfunc.c:137:17: note: expected 'unsigned char *' but argument is of
type 'char *'
vncfunc.c:525:2: warning: implicit declaration of function
'socket_has_data' [-Wimplicit-function-declaration]
vncfunc.c:526:3: warning: implicit declaration of function 'socket_read'
[-Wimplicit-function-declaration]
vncfunc.c:484:20: warning: unused variable 'err' [-Wunused-variable]
vncfunc.c:484:9: warning: unused variable 'skip_next' [-Wunused-variable]
vncfunc.c:484:6: warning: unused variable 'i' [-Wunused-variable]
vncfunc.c: In function 'vnc_send_keys':
vncfunc.c:569:2: warning: pointer targets in passing argument 1 of
'vnc_parse_fb_params' differ in signedness [-Wpointer-sign]
vncfunc.c:137:17: note: expected 'unsigned char *' but argument is of
type 'char *'
vncfunc.c:572:2: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness [-Wpointer-sign]
/usr/include/string.h:399:15: note: expected 'const char *' but argument
is of type 'unsigned char *'
vncfunc.c:572:2: warning: format '%d' expects argument of type 'int',
but argument 5 has type 'size_t' [-Wformat]
vncfunc.c:573:2: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness [-Wpointer-sign]
/usr/include/string.h:399:15: note: expected 'const char *' but argument
is of type 'unsigned char *'
vncfunc.c:580:3: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness [-Wpointer-sign]
/usr/include/string.h:399:15: note: expected 'const char *' but argument
is of type 'unsigned char *'
vncfunc.c:600:2: warning: pointer targets in passing argument 1 of
'strlen' differ in signedness [-Wpointer-sign]
/usr/include/string.h:399:15: note: expected 'const char *' but argument
is of type 'unsigned char *'
vncfunc.c:600:2: warning: format '%d' expects argument of type 'int',
but argument 4 has type 'size_t' [-Wformat]
vncfunc.c:547:20: warning: unused variable 'err' [-Wunused-variable]
vncfunc.c: In function 'vnc_send_pointer_event':
vncfunc.c:627:16: warning: unused variable 'end' [-Wunused-variable]
vncfunc.c:625:26: warning: unused variable 'err' [-Wunused-variable]
vncfunc.c:625:22: warning: unused variable 'ok' [-Wunused-variable]
vncfunc.c:625:19: warning: unused variable 'i' [-Wunused-variable]
vncfunc.c:625:11: warning: unused variable 'j' [-Wunused-variable]
vncfunc.c: In function 'vnc_refresh_screen':
vncfunc.c:697:20: warning: unused variable 'err' [-Wunused-variable]
vncfunc.c:697:9: warning: unused variable 'skip_next' [-Wunused-variable]
vncfunc.c:697:6: warning: unused variable 'i' [-Wunused-variable]
In file included from /usr/include/string.h:642:0,
                 from /usr/include/php/main/../main/php_config.h:2440,
                 from /usr/include/php/Zend/zend_config.h:1,
                 from /usr/include/php/Zend/zend.h:51,
                 from /usr/include/php/main/php.h:34,
                 from libvirt-php.h:44,
                 from vncfunc.c:10:
In function 'memset',
    inlined from 'vnc_send_client_pointer' at vncfunc.c:252:8:
/usr/include/bits/string3.h:85:3: warning: call to
__builtin___memset_chk will always overflow destination buffer [enabled
by default]
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fpic
-DCOMPILE_DL_LIBVIRT=1 -c -o sockets.o sockets.c -I/usr/include/php
-I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend
-I/usr/include/php/ext -I/usr/include/php/ext/date/lib
-I/usr/include/libxml2   -DHAVE_CONFIG_H
sockets.c: In function 'socket_has_data':
sockets.c:118:10: warning: unused variable 'result' [-Wunused-variable]
sockets.c: In function 'socket_read':
sockets.c:177:7: warning: ignoring return value of 'read', declared with
attribute warn_unused_result [-Wunused-result]
gcc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions
-fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -shared
-lvirt  -rdynamic -o libvirt-php.so vncfunc.o sockets.o libvirt-php.o
-ldl -lvirt -lxml2
echo "Extension compiled as libvirt-php.so"
Extension compiled as libvirt-php.so
diff -up libvirt-php-0.4.5/src/libvirt-php.c.php54 libvirt-php-0.4.5/src/libvirt-php.c
--- libvirt-php-0.4.5/src/libvirt-php.c.php54	2011-11-27 16:49:11.201682937 +0100
+++ libvirt-php-0.4.5/src/libvirt-php.c	2011-11-27 17:05:24.092827417 +0100
@@ -16,6 +16,11 @@
 
 #include "libvirt-php.h"
 
+// From vncfunc.c
+int vnc_get_dimensions(char *server, char *port, int *width, int *height);
+// From sockets.c
+int connect_socket(char *server, char *port, int keepalive, int nodelay, int allow_server_override);
+
 #ifdef DEBUG_CORE
 #define DPRINTF(fmt, ...) \
 if (LIBVIRT_G(debug)) \
@@ -50,7 +55,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_libvirt_c
 	ZEND_ARG_INFO(0, readonly)
 ZEND_END_ARG_INFO()
 
-static function_entry libvirt_functions[] = {
+static zend_function_entry libvirt_functions[] = {
 	/* Common functions */
 	PHP_FE(libvirt_get_last_error,NULL)
 	/* Connect functions */
@@ -775,7 +780,7 @@ unsigned long long size_def_to_mbytes(ch
 		return 0;
 
 	unit = arg[strlen(arg)-1];
-	switch (arg[strlen(arg)-1]) {
+	switch (unit) {
 		case 'G':
 			multiplicator = 1 << 10;
 			break;
@@ -1419,7 +1424,7 @@ PHP_FUNCTION(libvirt_connect)
 					if (zend_hash_get_current_key_ex(arr_hash, &key, &key_len, &index, 0, &pointer) == HASH_KEY_IS_STRING) {
 						PHPWRITE(key, key_len);
 					} else {
-						DPRINTF("%s: credentials index %d\n", PHPFUNC, index);
+						DPRINTF("%s: credentials index %d\n", PHPFUNC, (int)index);
 						creds[j].type=index;
 						creds[j].result=emalloc( Z_STRLEN_PP(data) + 1 );
 						memset(creds[j].result, 0, Z_STRLEN_PP(data) + 1);
@@ -1623,7 +1628,7 @@ PHP_FUNCTION(libvirt_image_create)
 	zval *zconn;
 	char msg[1024];
 	char cmd[4096] = { 0 };
-	char *path;
+	char *path = NULL;
 	char fpath[4096] = { 0 };
 	char *image = NULL;
 	int image_len;
@@ -1965,7 +1970,7 @@ void dec_to_bin(unsigned long long decim
 	int  k = 0, n = 0;
 	int  neg_flag = 0;
 	int  remain;
-	int  old_decimal;
+	// int  old_decimal;
 	char temp[128] = { 0 };
 
 	if (decimal < 0)
@@ -1975,7 +1980,7 @@ void dec_to_bin(unsigned long long decim
 	}
 	do 
 	{
-		old_decimal = decimal;
+		// old_decimal = decimal;
 		remain    = decimal % 2;
 		decimal   = decimal / 2;
 		temp[k++] = remain + '0';
@@ -2050,7 +2055,7 @@ long get_next_free_numeric_value(virDoma
 	int retval = -1;
 	HashTable *arr_hash;
 	HashPosition pointer;
-	int array_count;
+	// int array_count;
 	zval **data;
 	char *key;
 	unsigned int key_len;
@@ -2063,7 +2068,7 @@ long get_next_free_numeric_value(virDoma
 	free( get_string_from_xpath(xml, xpath, &output, &retval) );
 
 	arr_hash = Z_ARRVAL_P(output);
-	array_count = zend_hash_num_elements(arr_hash);
+	// array_count = zend_hash_num_elements(arr_hash);
 	for (zend_hash_internal_pointer_reset_ex(arr_hash, &pointer);
 			zend_hash_get_current_data_ex(arr_hash, (void**) &data, &pointer) == SUCCESS;
 			zend_hash_move_forward_ex(arr_hash, &pointer)) {
@@ -2188,7 +2193,7 @@ char *connection_get_arch(virConnectPtr 
 	int retval = -1;
 	char *tmp = NULL;
 	char *caps = NULL;
-	char xpath[1024] = { 0 };
+	// char xpath[1024] = { 0 };
 
 	caps = virConnectGetCapabilities(conn);
 	if (caps == NULL)
@@ -2219,7 +2224,7 @@ char *generate_uuid_any()
 	int i;
 	char a[37] = { 0 };
 	char hexa[] = "0123456789abcdef";
-	virDomainPtr domain=NULL;
+	// virDomainPtr domain=NULL;
 	
 	srand(time(NULL));
 	for (i = 0; i < 36; i++) {
@@ -2304,7 +2309,7 @@ char *get_disk_xml(unsigned long long si
 		ret = WEXITSTATUS(system(cmd));
 		DPRINTF("%s: Command '%s' finished with error code %d\n", __FUNCTION__, cmd, ret);
 		if (ret != 0) {
-			DPRINTF("%s: File creation failed\n");
+			DPRINTF("%s: File creation failed\n", path);
 			return NULL;
 		}
 		
@@ -2387,7 +2392,7 @@ char *installation_get_xml(int step, vir
 	char features[128] = { 0 };
 	char *tmp = NULL;
 	char type[64] = { 0 };
-	virDomainPtr domain=NULL;
+	// virDomainPtr domain=NULL;
 	
 	if (conn == NULL) {
 		DPRINTF("%s: Invalid libvirt connection pointer\n", __FUNCTION__);
@@ -2978,7 +2983,7 @@ PHP_FUNCTION(libvirt_domain_send_keys)
 
 	GET_DOMAIN_FROM_ARGS("rss",&zdomain, &hostname, &hostname_len, &keys, &keys_len);
 
-	DPRINTF("%s: Sending %d VNC keys to %s...\n", PHPFUNC, strlen(keys), hostname);
+	DPRINTF("%s: Sending %d VNC keys to %s...\n", PHPFUNC, (int)strlen(keys), hostname);
 
 	xml=virDomainGetXMLDesc(domain->domain, 0);
 	if (xml==NULL) {
@@ -2992,7 +2997,7 @@ PHP_FUNCTION(libvirt_domain_send_keys)
 		RETURN_FALSE;
 	}
 
-	DPRINTF("%s: About to send string '%s' (%d keys) to %s:%s\n", PHPFUNC, keys, strlen(keys), hostname, tmp);
+	DPRINTF("%s: About to send string '%s' (%d keys) to %s:%s\n", PHPFUNC, keys, (int)strlen(keys), hostname, tmp);
 
 	ret = vnc_send_keys(hostname, tmp, keys);
 	DPRINTF("%s: Sequence sending result is %d\n", PHPFUNC, ret);
@@ -3214,15 +3219,15 @@ PHP_FUNCTION(libvirt_connect_get_emulato
 void parse_array(zval *arr, tVMDisk *disk, tVMNetwork *network)
 {
 	HashTable *arr_hash;
-	int array_count;
-	zval **zvalue, **data;
+	// int array_count;
+	zval **data; // removed **zvalue
 	HashPosition pointer;
 	char *key;
 	unsigned int key_len;
 	unsigned long index;
 
 	arr_hash = Z_ARRVAL_P(arr);
-	array_count = zend_hash_num_elements(arr_hash);
+	//array_count = zend_hash_num_elements(arr_hash);
 
 	if (disk != NULL)
 		memset(disk, 0, sizeof(tVMDisk));
@@ -3297,7 +3302,7 @@ PHP_FUNCTION(libvirt_domain_new)
 	char *tmp;
 	char *name;
 	char name_len=0;
-	char *emulator;
+	// char *emulator;
 	char *iso_image = NULL;
 	int iso_image_len;
 	int vcpus = -1;
@@ -3308,7 +3313,7 @@ PHP_FUNCTION(libvirt_domain_new)
 	int maxmemMB = -1;
 	HashTable *arr_hash;
 	int numDisks, numNets, i;
-	zval **zvalue, **data;
+	zval **data; // removed **zvalue
 	HashPosition pointer;
 	char vncl[2048] = { 0 };
 	char tmpname[1024] = { 0 };
@@ -3677,7 +3682,7 @@ PHP_FUNCTION(libvirt_domain_change_memor
 	long allocMem = 0;
 	long allocMax = 0;
 	int retval = -1;
-	int pos = -1;
+	// int pos = -1;
 	int len = 0;
 	php_libvirt_domain *res_domain = NULL;
 	php_libvirt_connection *conn   = NULL;
@@ -3703,7 +3708,7 @@ PHP_FUNCTION(libvirt_domain_change_memor
 	snprintf(new, sizeof(new), "  <memory>%d</memory>\n  <currentMemory>%d</currentMemory>\n", allocMax, allocMem);
 	tmpA = strstr(xml, "<memory>");
 	tmp1 = strstr(xml, "</currentMemory>") + strlen("</currentMemory>");
-	pos = strlen(xml) - strlen(tmp1);
+	// pos = strlen(xml) - strlen(tmp1);
 	len = strlen(xml) - strlen(tmpA);
 
 	tmp2 = emalloc( ( len + 1 )* sizeof(char) );
@@ -3770,7 +3775,7 @@ PHP_FUNCTION(libvirt_domain_change_boot_
 	char *second = NULL;
 	int second_len;
 	int retval = -1;
-	int pos = -1;
+	// int pos = -1;
 	int len = 0;
 	php_libvirt_domain *res_domain = NULL;
 	php_libvirt_connection *conn   = NULL;
@@ -3793,7 +3798,7 @@ PHP_FUNCTION(libvirt_domain_change_boot_
 
 	tmpA = strstr(xml, "</type>") + strlen("</type>");
 	tmp1 = strstr(xml, "</os>");
-	pos = strlen(xml) - strlen(tmp1);
+	// pos = strlen(xml) - strlen(tmp1);
 	len = strlen(xml) - strlen(tmpA);
 
 	tmp2 = emalloc( ( len + 1 )* sizeof(char) );
--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]