[libvirt] [libvirt-php][PATCH 00/14] Fix code styling in libvirt-php

Fixed some basic code styling issues in libvirt-php.c that made the code hard to read. Katerina Koukiou (14): libvirt-php.c: Fix coding style issues: space required after ',' libvirt-php.c: Fix coding style issues: spaces required around '==', '>=', '<=' etc. libvirt-php.c: Fix coding style issues: space prohibited between function name and open parenthesis '(' libvirt-php.c: Fix coding style issues: remove unwanted spaces after '(' and before ')' libvirt-php.c: Fix code styling issues: no space needed after '[' and before ']' libvirt-php.c: Fix code styling issues: if then else statement style issues libvirt-php.c: Fix coding style issues with braces libvirt-php.c Fix coding style issues with if statements libvirt-php.c: Fix coding style issues: space required around '=' in assignments libvirt-php.c: Fix code styling issues with for loops libvirt-php.c: Fix coding style issues: "(foo*)" should be "(foo *)" libvirt-php.c: Fix coding style issues with operators libvirt-php.c: Fix coding style issues with extra/less spaces libvirt-php.c: Fix coding style issues in macros src/libvirt-php.c | 2220 ++++++++++++++++++++++++++--------------------------- 1 file changed, 1101 insertions(+), 1119 deletions(-) -- 2.7.3

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 414 +++++++++++++++++++++++++++--------------------------- 1 file changed, 207 insertions(+), 207 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index df2f32a..b28d4b4 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -1116,10 +1116,10 @@ PHP_MINFO_FUNCTION(libvirt) php_info_print_table_row(2, "Debug support", tmp); php_info_print_table_row(2, "Extension version", PHP_LIBVIRT_WORLD_VERSION); - if (virGetVersion(&libVer,NULL,NULL)== 0) + if (virGetVersion(&libVer, NULL, NULL)== 0) { char version[100]; - snprintf(version, sizeof(version), "%i.%i.%i", (long)((libVer/1000000) % 1000),(long)((libVer/1000) % 1000),(long)(libVer % 1000)); + snprintf(version, sizeof(version), "%i.%i.%i", (long)((libVer/1000000) % 1000), (long)((libVer/1000) % 1000), (long)(libVer % 1000)); php_info_print_table_row(2, "Libvirt version", version); } @@ -1177,8 +1177,8 @@ void set_error(char *msg TSRMLS_DC) return; } - php_error_docref(NULL TSRMLS_CC, E_WARNING,"%s",msg); - LIBVIRT_G (last_error)=estrndup(msg,strlen(msg)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", msg); + LIBVIRT_G (last_error)=estrndup(msg, strlen(msg)); } /* @@ -1198,7 +1198,7 @@ void set_vnc_location(char *msg TSRMLS_DC) return; } - LIBVIRT_G (vnc_location)=estrndup(msg,strlen(msg)); + LIBVIRT_G (vnc_location)=estrndup(msg, strlen(msg)); DPRINTF("set_vnc_location: VNC server location set to '%s'\n", LIBVIRT_G (vnc_location)); } @@ -1255,7 +1255,7 @@ void free_resource(int type, void *mem TSRMLS_DC) rv = virDomainFree( (virDomainPtr)mem ); if (rv != 0) { DPRINTF("%s: virDomainFree(%p) returned %d (%s)\n", __FUNCTION__, (virDomainPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virDomainFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virDomainFree(%p) completed successfully\n", __FUNCTION__, (virDomainPtr)mem); @@ -1267,7 +1267,7 @@ void free_resource(int type, void *mem TSRMLS_DC) rv = virStreamFree( (virStreamPtr)mem ); if (rv != 0) { DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, (virStreamPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virStreamFree(%p) completed successfully\n", __FUNCTION__, (virStreamPtr)mem); @@ -1279,7 +1279,7 @@ void free_resource(int type, void *mem TSRMLS_DC) rv = virNetworkFree( (virNetworkPtr)mem ); if (rv != 0) { DPRINTF("%s: virNetworkFree(%p) returned %d (%s)\n", __FUNCTION__, (virNetworkPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virNetworkFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNetworkFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virNetworkFree(%p) completed successfully\n", __FUNCTION__, (virNetworkPtr)mem); @@ -1291,7 +1291,7 @@ void free_resource(int type, void *mem TSRMLS_DC) rv = virNodeDeviceFree( (virNodeDevicePtr)mem ); if (rv != 0) { DPRINTF("%s: virNodeDeviceFree(%p) returned %d (%s)\n", __FUNCTION__, (virNodeDevicePtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virNodeDeviceFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNodeDeviceFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virNodeDeviceFree(%p) completed successfully\n", __FUNCTION__, (virNodeDevicePtr)mem); @@ -1303,7 +1303,7 @@ void free_resource(int type, void *mem TSRMLS_DC) rv = virStoragePoolFree( (virStoragePoolPtr)mem ); if (rv != 0) { DPRINTF("%s: virStoragePoolFree(%p) returned %d (%s)\n", __FUNCTION__, (virStoragePoolPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virStoragePoolFree(%p) completed successfully\n", __FUNCTION__, (virStoragePoolPtr)mem); @@ -1315,7 +1315,7 @@ void free_resource(int type, void *mem TSRMLS_DC) rv = virStorageVolFree( (virStorageVolPtr)mem ); if (rv != 0) { DPRINTF("%s: virStorageVolFree(%p) returned %d (%s)\n", __FUNCTION__, (virStorageVolPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virStorageVolFree(%p) completed successfully\n", __FUNCTION__, (virStorageVolPtr)mem); @@ -1327,7 +1327,7 @@ void free_resource(int type, void *mem TSRMLS_DC) rv = virDomainSnapshotFree( (virDomainSnapshotPtr)mem ); if (rv != 0) { DPRINTF("%s: virDomainSnapshotFree(%p) returned %d (%s)\n", __FUNCTION__, (virDomainSnapshotPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virDomainSnapshotFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainSnapshotFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virDomainSnapshotFree(%p) completed successfully\n", __FUNCTION__, (virDomainSnapshotPtr)mem); @@ -1496,7 +1496,7 @@ static void php_libvirt_connection_dtor( rv = virConnectClose(conn->conn); if (rv == -1) { DPRINTF("%s: virConnectClose(%p) returned %d (%s)\n", __FUNCTION__, conn->conn, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virConnectClose failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virConnectClose failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virConnectClose(%p) completed successfully\n", __FUNCTION__, conn->conn); @@ -1533,7 +1533,7 @@ static void php_libvirt_domain_dtor( rv = virDomainFree(domain->domain); if (rv != 0) { DPRINTF("%s: virDomainFree(%p) returned %d (%s)\n", __FUNCTION__, domain->domain, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virDomainFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virDomainFree(%p) completed successfully\n", __FUNCTION__, domain->domain); @@ -1569,7 +1569,7 @@ static void php_libvirt_stream_dtor( rv = virStreamFree(stream->stream); if (rv != 0) { DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, stream->stream, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virStreamFree(%p) completed successfully\n", __FUNCTION__, stream->stream); @@ -1605,7 +1605,7 @@ static void php_libvirt_storagepool_dtor( rv = virStoragePoolFree(pool->pool); if (rv!=0) { DPRINTF("%s: virStoragePoolFree(%p) returned %d (%s)\n", __FUNCTION__, pool->pool, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virStoragePoolFree(%p) completed successfully\n", __FUNCTION__, pool->pool); @@ -1641,7 +1641,7 @@ static void php_libvirt_volume_dtor( rv = virStorageVolFree (volume->volume); if (rv!=0) { DPRINTF("%s: virStorageVolFree(%p) returned %d (%s)\n", __FUNCTION__, volume->volume, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virStorageVolFree(%p) completed successfully\n", __FUNCTION__, volume->volume); @@ -1677,7 +1677,7 @@ static void php_libvirt_network_dtor( rv = virNetworkFree(network->network); if (rv!=0) { DPRINTF("%s: virNetworkFree(%p) returned %d (%s)\n", __FUNCTION__, network->network, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virNetworkFree(%p) completed successfully\n", __FUNCTION__, network->network); @@ -1713,7 +1713,7 @@ static void php_libvirt_nodedev_dtor( rv = virNodeDeviceFree(nodedev->device); if (rv!=0) { DPRINTF("%s: virNodeDeviceFree(%p) returned %d (%s)\n", __FUNCTION__, nodedev->device, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virNodeDeviceFree(%p) completed successfully\n", __FUNCTION__, nodedev->device); @@ -1749,7 +1749,7 @@ static void php_libvirt_snapshot_dtor( rv = virDomainSnapshotFree(snapshot->snapshot); if (rv!=0) { DPRINTF("%s: virDomainSnapshotFree(%p) returned %d\n", __FUNCTION__, snapshot->snapshot, rv); - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } else { DPRINTF("%s: virDomainSnapshotFree(%p) completed successfully\n", __FUNCTION__, snapshot->snapshot); @@ -2151,24 +2151,24 @@ if ((snapshot==NULL) || (snapshot->snapshot==NULL)) RETURN_FALSE;\ #define LONGLONG_INIT \ char tmpnumber[64] -#define LONGLONG_ASSOC(out,key,in) \ +#define LONGLONG_ASSOC(out, key, in) \ if (LIBVIRT_G(longlong_to_string_ini)) { \ - snprintf(tmpnumber,63,"%llu",in); \ + snprintf(tmpnumber, 63, "%llu", in); \ VIRT_ADD_ASSOC_STRING(out, key, tmpnumber); \ } \ else \ { \ - add_assoc_long(out,key,in); \ + add_assoc_long(out, key, in); \ } -#define LONGLONG_INDEX(out,key,in) \ +#define LONGLONG_INDEX(out, key, in) \ if (LIBVIRT_G(longlong_to_string_ini)) { \ - snprintf(tmpnumber,63,"%llu",in); \ + snprintf(tmpnumber, 63, "%llu", in); \ VIRT_ADD_INDEX_STRING(out, key, tmpnumber); \ } \ else \ { \ - add_index_long(out, key,in); \ + add_index_long(out, key, in); \ } #define LONGLONG_RETURN_AS_STRING(in) \ @@ -2181,7 +2181,7 @@ static int libvirt_virConnectAuthCallback(virConnectCredentialPtr cred, unsigned { TSRMLS_FETCH(); - unsigned int i,j; + unsigned int i, j; php_libvirt_cred_value *creds=(php_libvirt_cred_value*) cbdata; for (i = 0; i < (unsigned int)ncred; i++) { @@ -2194,7 +2194,7 @@ static int libvirt_virConnectAuthCallback(virConnectCredentialPtr cred, unsigned cred[i].resultlen=creds[j].resultlen; cred[i].result=(char *)malloc(creds[j].resultlen + 1); memset(cred[i].result, 0, creds[j].resultlen + 1); - strncpy(cred[i].result,creds[j].result,creds[j].resultlen); + strncpy(cred[i].result, creds[j].result, creds[j].resultlen); } } DPRINTF("%s: result %s (%d)\n", __FUNCTION__, cred[i].result, cred[i].resultlen); @@ -2259,11 +2259,11 @@ PHP_FUNCTION(libvirt_connect) unsigned long libVer; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sba", &url,&url_len,&readonly,&zcreds) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sba", &url, &url_len, &readonly, &zcreds) == FAILURE) { RETURN_FALSE; } - if (virGetVersion(&libVer,NULL,NULL)!= 0) + if (virGetVersion(&libVer, NULL, NULL)!= 0) RETURN_FALSE; if (libVer<6002) @@ -2273,7 +2273,7 @@ PHP_FUNCTION(libvirt_connect) } if ((count_resources(INT_RESOURCE_CONNECTION TSRMLS_CC) + 1) > LIBVIRT_G(max_connections_ini)) { - DPRINTF("%s: maximum number of connections allowed exceeded (max %lu)\n",PHPFUNC, (unsigned long)LIBVIRT_G(max_connections_ini)); + DPRINTF("%s: maximum number of connections allowed exceeded (max %lu)\n", PHPFUNC, (unsigned long)LIBVIRT_G(max_connections_ini)); set_error("Maximum number of connections allowed exceeded" TSRMLS_CC); RETURN_FALSE; } @@ -2359,9 +2359,9 @@ PHP_FUNCTION(libvirt_node_get_info) zval *zconn; int retval; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); - retval=virNodeGetInfo (conn->conn,&info); + retval=virNodeGetInfo (conn->conn, &info); DPRINTF("%s: virNodeGetInfo returned %d\n", PHPFUNC, retval); if (retval==-1) RETURN_FALSE; @@ -2687,7 +2687,7 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) char **ret = NULL; int i, num = -1; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); caps = virConnectGetCapabilities(conn->conn); if (caps == NULL) @@ -2835,7 +2835,7 @@ PHP_FUNCTION(libvirt_connect_get_information) int iTmp = -1, maxvcpus = -1; php_libvirt_connection *conn = NULL; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); tmp = virConnectGetURI(conn->conn); DPRINTF("%s: Got connection URI of %s...\n", PHPFUNC, tmp); @@ -2849,9 +2849,9 @@ PHP_FUNCTION(libvirt_connect_get_information) if ((virConnectGetVersion(conn->conn, &hvVer) == 0) && (type = virConnectGetType(conn->conn))) { VIRT_ADD_ASSOC_STRING(return_value, "hypervisor", (char *)type); - add_assoc_long(return_value, "hypervisor_major",(long)((hvVer/1000000) % 1000)); - add_assoc_long(return_value, "hypervisor_minor",(long)((hvVer/1000) % 1000)); - add_assoc_long(return_value, "hypervisor_release",(long)(hvVer %1000)); + add_assoc_long(return_value, "hypervisor_major", (long)((hvVer/1000000) % 1000)); + add_assoc_long(return_value, "hypervisor_minor", (long)((hvVer/1000) % 1000)); + add_assoc_long(return_value, "hypervisor_release", (long)(hvVer %1000)); snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type, (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000)); VIRT_ADD_ASSOC_STRING(return_value, "hypervisor_string", hvStr); @@ -2915,7 +2915,7 @@ PHP_FUNCTION(libvirt_connect_get_uri) char *uri; php_libvirt_connection *conn = NULL; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); uri = virConnectGetURI(conn->conn); DPRINTF("%s: virConnectGetURI returned %s\n", PHPFUNC, uri); if (uri == NULL) RETURN_FALSE; @@ -2937,7 +2937,7 @@ PHP_FUNCTION(libvirt_connect_get_hostname) zval *zconn; char *hostname; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); hostname=virConnectGetHostname(conn->conn); DPRINTF("%s: virConnectGetHostname returned %s\n", PHPFUNC, hostname); @@ -2982,7 +2982,7 @@ PHP_FUNCTION(libvirt_image_create) RETURN_FALSE; } - GET_CONNECTION_FROM_ARGS("rsss",&zconn,&image,&image_len,&size_str,&size_str_len,&format,&format_len); + GET_CONNECTION_FROM_ARGS("rsss", &zconn, &image, &image_len, &size_str, &size_str_len, &format, &format_len); if (size_str == NULL) RETURN_FALSE; @@ -3036,7 +3036,7 @@ PHP_FUNCTION(libvirt_image_remove) char *image = NULL; strsize_t image_len; - GET_CONNECTION_FROM_ARGS("rs",&zconn,&image,&image_len); + GET_CONNECTION_FROM_ARGS("rs", &zconn, &image, &image_len); // Disable remote connections if (!is_local_connection(conn->conn)) { @@ -3084,7 +3084,7 @@ PHP_FUNCTION(libvirt_connect_get_hypervisor) const char *type = NULL; char hvStr[64] = { 0 }; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); if (virConnectGetVersion(conn->conn, &hvVer) != 0) RETURN_FALSE; @@ -3097,9 +3097,9 @@ PHP_FUNCTION(libvirt_connect_get_hypervisor) array_init(return_value); VIRT_ADD_ASSOC_STRING(return_value, "hypervisor", (char *)type); - add_assoc_long(return_value, "major",(long)((hvVer/1000000) % 1000)); - add_assoc_long(return_value, "minor",(long)((hvVer/1000) % 1000)); - add_assoc_long(return_value, "release",(long)(hvVer %1000)); + add_assoc_long(return_value, "major", (long)((hvVer/1000000) % 1000)); + add_assoc_long(return_value, "minor", (long)((hvVer/1000) % 1000)); + add_assoc_long(return_value, "release", (long)(hvVer %1000)); snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type, (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000)); @@ -3118,7 +3118,7 @@ PHP_FUNCTION(libvirt_connect_get_encrypted) php_libvirt_connection *conn=NULL; zval *zconn; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); RETURN_LONG( virConnectIsEncrypted(conn->conn) ); } @@ -3136,7 +3136,7 @@ PHP_FUNCTION(libvirt_connect_get_secure) php_libvirt_connection *conn=NULL; zval *zconn; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); RETURN_LONG( virConnectIsSecure(conn->conn) ); } @@ -3164,7 +3164,7 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats) virTypedParameter params; virDomainStatsRecordPtr *retstats = NULL; - GET_CONNECTION_FROM_ARGS("r|l|l",&zconn, &stats, &flags); + GET_CONNECTION_FROM_ARGS("r|l|l", &zconn, &stats, &flags); retval = virConnectGetAllDomainStats(conn->conn, stats, &retstats, flags); @@ -3233,7 +3233,7 @@ PHP_FUNCTION(libvirt_connect_get_maxvcpus) zval *zconn; const char *type = NULL; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); type = virConnectGetType(conn->conn); if (type == NULL) @@ -3255,7 +3255,7 @@ PHP_FUNCTION(libvirt_connect_get_sysinfo) zval *zconn; char *sysinfo; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); sysinfo=virConnectGetSysinfo(conn->conn, 0); if (sysinfo==NULL) RETURN_FALSE; @@ -4049,7 +4049,7 @@ PHP_FUNCTION(libvirt_domain_get_counts) int count_defined; int count_active; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); count_defined = virConnectNumOfDefinedDomains (conn->conn); count_active = virConnectNumOfDomains (conn->conn); @@ -4307,9 +4307,9 @@ PHP_FUNCTION(libvirt_domain_lookup_by_name) virDomainPtr domain=NULL; php_libvirt_domain *res_domain; - GET_CONNECTION_FROM_ARGS("rs",&zconn,&name,&name_len); + GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); if ( (name == NULL) || (name_len<1)) RETURN_FALSE; - domain=virDomainLookupByName(conn->conn,name); + domain=virDomainLookupByName(conn->conn, name); if (domain==NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -4342,10 +4342,10 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid) virDomainPtr domain=NULL; php_libvirt_domain *res_domain; - GET_CONNECTION_FROM_ARGS("rs",&zconn,&uuid,&uuid_len); + GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); if ( (uuid == NULL) || (uuid_len<1)) RETURN_FALSE; - domain=virDomainLookupByUUID(conn->conn,uuid); + domain=virDomainLookupByUUID(conn->conn, uuid); if (domain==NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -4407,10 +4407,10 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string) virDomainPtr domain=NULL; php_libvirt_domain *res_domain; - GET_CONNECTION_FROM_ARGS("rs",&zconn,&uuid,&uuid_len); + GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); if ( (uuid == NULL) || (uuid_len<1)) RETURN_FALSE; - domain=virDomainLookupByUUIDString(conn->conn,uuid); + domain=virDomainLookupByUUIDString(conn->conn, uuid); if (domain==NULL) RETURN_FALSE; res_domain =(php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -4648,9 +4648,9 @@ PHP_FUNCTION(libvirt_domain_lookup_by_id) virDomainPtr domain=NULL; php_libvirt_domain *res_domain; - GET_CONNECTION_FROM_ARGS("rl",&zconn,&id); + GET_CONNECTION_FROM_ARGS("rl", &zconn, &id); - domain=virDomainLookupByID(conn->conn,(int)id); + domain=virDomainLookupByID(conn->conn, (int)id); if (domain==NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -4679,7 +4679,7 @@ PHP_FUNCTION(libvirt_domain_get_name) zval *zdomain; const char *name=NULL; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); if (domain->domain == NULL) RETURN_FALSE; @@ -4705,10 +4705,10 @@ PHP_FUNCTION(libvirt_domain_get_uuid_string) char *uuid; int retval; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); uuid = (char *)emalloc(VIR_UUID_STRING_BUFLEN); - retval=virDomainGetUUIDString(domain->domain,uuid); + retval=virDomainGetUUIDString(domain->domain, uuid); DPRINTF("%s: virDomainGetUUIDString(%p) returned %d (%s)\n", PHPFUNC, domain->domain, retval, uuid); if (retval!=0) RETURN_FALSE; @@ -4873,7 +4873,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) } } - GET_DOMAIN_FROM_ARGS("rs|l",&zdomain, &hostname, &hostname_len, &scancode); + GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &hostname, &hostname_len, &scancode); xml = virDomainGetXMLDesc(domain->domain, 0); if (!xml) { @@ -4995,7 +4995,7 @@ PHP_FUNCTION(libvirt_domain_get_screen_dimensions) int width; int height; - GET_DOMAIN_FROM_ARGS("rs",&zdomain, &hostname, &hostname_len); + GET_DOMAIN_FROM_ARGS("rs", &zdomain, &hostname, &hostname_len); xml = virDomainGetXMLDesc(domain->domain, 0); if (!xml) { @@ -5064,7 +5064,7 @@ PHP_FUNCTION(libvirt_domain_send_keys) strsize_t keys_len; int ret = 0; - GET_DOMAIN_FROM_ARGS("rss",&zdomain, &hostname, &hostname_len, &keys, &keys_len); + GET_DOMAIN_FROM_ARGS("rss", &zdomain, &hostname, &hostname_len, &keys, &keys_len); DPRINTF("%s: Sending %d VNC keys to %s...\n", PHPFUNC, (int)strlen((const char *)keys), hostname); @@ -5183,7 +5183,7 @@ PHP_FUNCTION(libvirt_domain_send_pointer_event) zend_bool release = 1; int ret; - GET_DOMAIN_FROM_ARGS("rslll|b",&zdomain, &hostname, &hostname_len, &pos_x, &pos_y, &clicked, &release); + GET_DOMAIN_FROM_ARGS("rslll|b", &zdomain, &hostname, &hostname_len, &pos_x, &pos_y, &clicked, &release); xml = virDomainGetXMLDesc(domain->domain, 0); if (!xml) { @@ -5239,10 +5239,10 @@ PHP_FUNCTION(libvirt_domain_get_uuid) char *uuid; int retval; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); uuid=(char *)emalloc(VIR_UUID_BUFLEN); - retval=virDomainGetUUID(domain->domain,(unsigned char *)uuid); + retval=virDomainGetUUID(domain->domain, (unsigned char *)uuid); DPRINTF("%s: virDomainGetUUID(%p, %p) returned %d\n", PHPFUNC, domain->domain, uuid, retval); if (retval!=0) RETURN_FALSE; @@ -5264,7 +5264,7 @@ PHP_FUNCTION(libvirt_domain_get_id) zval *zdomain; int retval; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); retval=virDomainGetID(domain->domain); DPRINTF("%s: virDomainGetID(%p) returned %d\n", PHPFUNC, domain->domain, retval); @@ -5285,7 +5285,7 @@ PHP_FUNCTION(libvirt_domain_get_next_dev_ids) php_libvirt_domain *domain=NULL; zval *zdomain; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); DPRINTF("%s: Getting the next dev ids for domain %p\n", PHPFUNC, domain->domain); @@ -5319,7 +5319,7 @@ PHP_FUNCTION(libvirt_connect_get_capabilities) char *tmp = NULL; int retval = -1; - GET_CONNECTION_FROM_ARGS("r|s",&zconn,&xpath,&xpath_len); + GET_CONNECTION_FROM_ARGS("r|s", &zconn, &xpath, &xpath_len); caps = virConnectGetCapabilities(conn->conn); if (caps == NULL) @@ -5352,7 +5352,7 @@ PHP_FUNCTION(libvirt_connect_get_emulator) strsize_t arch_len; char *tmp; - GET_CONNECTION_FROM_ARGS("r|s",&zconn,&arch,&arch_len); + GET_CONNECTION_FROM_ARGS("r|s", &zconn, &arch, &arch_len); if ((arch == NULL) || (arch_len == 0)) arch = NULL; @@ -5383,7 +5383,7 @@ PHP_FUNCTION(libvirt_connect_get_nic_models) strsize_t arch_len; char *tmp; - GET_CONNECTION_FROM_ARGS("r|s",&zconn,&arch,&arch_len); + GET_CONNECTION_FROM_ARGS("r|s", &zconn, &arch, &arch_len); /* Disable getting it on remote connections */ if (!is_local_connection(conn->conn)) { @@ -5455,7 +5455,7 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) char *tmp; zend_long flags = 0; - GET_CONNECTION_FROM_ARGS("r|sl",&zconn,&arch,&arch_len,&flags); + GET_CONNECTION_FROM_ARGS("r|sl", &zconn, &arch, &arch_len, &flags); if ((arch == NULL) || (arch_len == 0)) arch = NULL; @@ -5646,7 +5646,7 @@ PHP_FUNCTION(libvirt_domain_new) zend_long flags = 0; int fd = -1; - GET_CONNECTION_FROM_ARGS("rsslllsaa|l",&zconn,&name,&name_len,&arch,&arch_len,&memMB,&maxmemMB,&vcpus,&iso_image,&iso_image_len,&disks,&networks,&flags); + GET_CONNECTION_FROM_ARGS("rsslllsaa|l", &zconn, &name, &name_len, &arch, &arch_len, &memMB, &maxmemMB, &vcpus, &iso_image, &iso_image_len, &disks, &networks, &flags); if (iso_image == NULL) { DPRINTF("%s: Iso image is not defined\n", PHPFUNC); @@ -5814,13 +5814,13 @@ PHP_FUNCTION(libvirt_domain_get_xml_desc) zend_long flags=0; int retval = -1; - GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&xpath,&xpath_len,&flags); + GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &xpath, &xpath_len, &flags); if (xpath_len < 1) xpath = NULL; DPRINTF("%s: Getting the XML for domain %p (xPath = %s)\n", PHPFUNC, domain->domain, xpath); - xml = virDomainGetXMLDesc(domain->domain,flags); + xml = virDomainGetXMLDesc(domain->domain, flags); if (!xml) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); RETURN_FALSE; @@ -5851,7 +5851,7 @@ PHP_FUNCTION(libvirt_domain_get_disk_devices) char *xml; int retval = -1; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); DPRINTF("%s: Getting disk device list for domain %p\n", PHPFUNC, domain->domain); @@ -5886,7 +5886,7 @@ PHP_FUNCTION(libvirt_domain_get_interface_devices) char *xml; int retval = -1; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); DPRINTF("%s: Getting interface device list for domain %p\n", PHPFUNC, domain->domain); @@ -5922,7 +5922,7 @@ PHP_FUNCTION(libvirt_domain_change_vcpus) php_libvirt_domain *domain=NULL; zval *zdomain; - GET_DOMAIN_FROM_ARGS("rl|l",&zdomain,&numCpus,&flags); + GET_DOMAIN_FROM_ARGS("rl|l", &zdomain, &numCpus, &flags); if (virDomainSetVcpusFlags(domain->domain, numCpus, flags) == 0) { RETURN_TRUE; @@ -5962,7 +5962,7 @@ PHP_FUNCTION(libvirt_domain_change_memory) php_libvirt_connection *conn = NULL; virDomainPtr dom = NULL; - GET_DOMAIN_FROM_ARGS("rll|l",&zdomain,&allocMem, &allocMax, &xflags); + GET_DOMAIN_FROM_ARGS("rll|l", &zdomain, &allocMem, &allocMax, &xflags); DPRINTF("%s: Changing domain memory count to %d MiB current/%d MiB max, domain = %p\n", PHPFUNC, (int)allocMem, (int)allocMax, domain->domain); @@ -5973,7 +5973,7 @@ PHP_FUNCTION(libvirt_domain_change_memory) if (allocMem > allocMax) allocMem = allocMax; - xml = virDomainGetXMLDesc(domain->domain,xflags); + xml = virDomainGetXMLDesc(domain->domain, xflags); if (!xml) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); RETURN_FALSE; @@ -6049,9 +6049,9 @@ PHP_FUNCTION(libvirt_domain_change_boot_devices) php_libvirt_connection *conn = NULL; virDomainPtr dom = NULL; - GET_DOMAIN_FROM_ARGS("rss|l",&zdomain,&first, &first_len, &second, &second_len, &xflags); + GET_DOMAIN_FROM_ARGS("rss|l", &zdomain, &first, &first_len, &second, &second_len, &xflags); - xml = virDomainGetXMLDesc(domain->domain,xflags); + xml = virDomainGetXMLDesc(domain->domain, xflags); if (!xml) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); RETURN_FALSE; @@ -6133,12 +6133,12 @@ PHP_FUNCTION(libvirt_domain_disk_add) char *xpath = NULL; char *tmp = NULL; - GET_DOMAIN_FROM_ARGS("rssss|l",&zdomain,&img,&img_len,&dev,&dev_len,&typ,&typ_len,&driver,&driver_len,&xflags); + GET_DOMAIN_FROM_ARGS("rssss|l", &zdomain, &img, &img_len, &dev, &dev_len, &typ, &typ_len, &driver, &driver_len, &xflags); DPRINTF("%s: Domain %p, device = %s, image = %s, type = %s, driver = %s\n", PHPFUNC, domain->domain, dev, img, typ, driver); - xml = virDomainGetXMLDesc(domain->domain,xflags); + xml = virDomainGetXMLDesc(domain->domain, xflags); if (!xml) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); goto error; @@ -6223,11 +6223,11 @@ PHP_FUNCTION(libvirt_domain_disk_remove) char *xpath = NULL; char *tmp = NULL; - GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&dev,&dev_len,&xflags); + GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &dev, &dev_len, &xflags); DPRINTF("%s: Trying to remove %s from domain %p\n", PHPFUNC, dev, domain->domain); - xml = virDomainGetXMLDesc(domain->domain,xflags); + xml = virDomainGetXMLDesc(domain->domain, xflags); if (!xml) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); RETURN_FALSE; @@ -6302,13 +6302,13 @@ PHP_FUNCTION(libvirt_domain_nic_add) DPRINTF("%s: Entering\n", PHPFUNC); - GET_DOMAIN_FROM_ARGS("rsss|l",&zdomain,&mac,&mac_len,&net,&net_len,&model,&model_len,&xflags); + GET_DOMAIN_FROM_ARGS("rsss|l", &zdomain, &mac, &mac_len, &net, &net_len, &model, &model_len, &xflags); if (model_len < 1) model = NULL; DPRINTF("%s: domain = %p, mac = %s, net = %s, model = %s\n", PHPFUNC, domain->domain, mac, net, model); - xml = virDomainGetXMLDesc(domain->domain,xflags); + xml = virDomainGetXMLDesc(domain->domain, xflags); if (!xml) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); RETURN_FALSE; @@ -6389,11 +6389,11 @@ PHP_FUNCTION(libvirt_domain_nic_remove) char *xpath = NULL; char *tmp = NULL; - GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&mac,&mac_len,&xflags); + GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &mac, &mac_len, &xflags); DPRINTF("%s: Trying to remove NIC device with MAC address %s from domain %p\n", PHPFUNC, mac, domain->domain); - xml = virDomainGetXMLDesc(domain->domain,xflags); + xml = virDomainGetXMLDesc(domain->domain, xflags); if (!xml) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); RETURN_FALSE; @@ -6502,9 +6502,9 @@ PHP_FUNCTION(libvirt_domain_get_info) virDomainInfo domainInfo; int retval; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainGetInfo(domain->domain,&domainInfo); + retval=virDomainGetInfo(domain->domain, &domainInfo); DPRINTF("%s: virDomainGetInfo(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; @@ -6529,7 +6529,7 @@ PHP_FUNCTION(libvirt_domain_create) zval *zdomain; int retval; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); retval=virDomainCreate(domain->domain); DPRINTF("%s: virDomainCreate(%p) returned %d\n", PHPFUNC, domain->domain, retval); @@ -6550,7 +6550,7 @@ PHP_FUNCTION(libvirt_domain_destroy) zval *zdomain; int retval; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); retval=virDomainDestroy(domain->domain); DPRINTF("%s: virDomainDestroy(%p) returned %d\n", PHPFUNC, domain->domain, retval); @@ -6571,7 +6571,7 @@ PHP_FUNCTION(libvirt_domain_resume) zval *zdomain; int retval; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); retval=virDomainResume(domain->domain); DPRINTF("%s: virDomainResume(%p) returned %d\n", PHPFUNC, domain->domain, retval); @@ -6595,7 +6595,7 @@ PHP_FUNCTION(libvirt_domain_core_dump) strsize_t to_len; char *to; - GET_DOMAIN_FROM_ARGS("rs",&zdomain,&to,&to_len); + GET_DOMAIN_FROM_ARGS("rs", &zdomain, &to, &to_len); retval=virDomainCoreDump(domain->domain, to, 0); DPRINTF("%s: virDomainCoreDump(%p, %s, 0) returned %d\n", PHPFUNC, domain->domain, to, retval); @@ -6616,7 +6616,7 @@ PHP_FUNCTION(libvirt_domain_shutdown) zval *zdomain; int retval; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); retval=virDomainShutdown(domain->domain); DPRINTF("%s: virDomainShutdown(%p) returned %d\n", PHPFUNC, domain->domain, retval); @@ -6637,7 +6637,7 @@ PHP_FUNCTION(libvirt_domain_managedsave) zval *zdomain; int retval; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); retval=virDomainManagedSave(domain->domain, 0); DPRINTF("%s: virDomainManagedSave(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; @@ -6657,7 +6657,7 @@ PHP_FUNCTION(libvirt_domain_suspend) zval *zdomain; int retval; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); retval=virDomainSuspend(domain->domain); DPRINTF("%s: virDomainSuspend(%p) returned %d\n", PHPFUNC, domain->domain, retval); @@ -6678,7 +6678,7 @@ PHP_FUNCTION(libvirt_domain_undefine) zval *zdomain; int retval; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); retval=virDomainUndefine(domain->domain); DPRINTF("%s: virDomainUndefine(%p) returned %d\n", PHPFUNC, domain->domain, retval); @@ -6701,9 +6701,9 @@ PHP_FUNCTION(libvirt_domain_reboot) int retval; zend_long flags=0; - GET_DOMAIN_FROM_ARGS("r|l",&zdomain,&flags); + GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags); - retval=virDomainReboot(domain->domain,flags); + retval=virDomainReboot(domain->domain, flags); DPRINTF("%s: virDomainReboot(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; RETURN_TRUE; @@ -6726,9 +6726,9 @@ PHP_FUNCTION(libvirt_domain_define_xml) char *xml; strsize_t xml_len; - GET_CONNECTION_FROM_ARGS("rs",&zconn,&xml,&xml_len); + GET_CONNECTION_FROM_ARGS("rs", &zconn, &xml, &xml_len); - domain=virDomainDefineXML(conn->conn,xml); + domain=virDomainDefineXML(conn->conn, xml); if (domain==NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -6764,7 +6764,7 @@ PHP_FUNCTION(libvirt_domain_create_xml) GET_CONNECTION_FROM_ARGS("rs|l", &zconn, &xml, &xml_len, &flags); - domain=virDomainCreateXML(conn->conn,xml, flags); + domain=virDomainCreateXML(conn->conn, xml, flags); DPRINTF("%s: virDomainCreateXML(%p, <xml>, 0) returned %p\n", PHPFUNC, conn->conn, domain); if (domain==NULL) RETURN_FALSE; @@ -6867,13 +6867,13 @@ PHP_FUNCTION(libvirt_domain_memory_peek) zend_long size; char *buff; - GET_DOMAIN_FROM_ARGS("rlll",&zdomain,&start,&size,&flags); + GET_DOMAIN_FROM_ARGS("rlll", &zdomain, &start, &size, &flags); if (start < 0) { set_error("Negative argument start" TSRMLS_CC); RETURN_FALSE; } buff=(char *)emalloc(size); - retval=virDomainMemoryPeek(domain->domain,start,size,buff,flags); + retval=virDomainMemoryPeek(domain->domain, start, size, buff, flags); if (retval != 0) RETURN_FALSE; VIRT_RETVAL_STRINGL(buff, size); efree(buff); @@ -6896,9 +6896,9 @@ PHP_FUNCTION(libvirt_domain_memory_stats) int i; struct _virDomainMemoryStat stats[VIR_DOMAIN_MEMORY_STAT_NR]; - GET_DOMAIN_FROM_ARGS("r|l",&zdomain,&flags); + GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags); - retval=virDomainMemoryStats(domain->domain,stats,VIR_DOMAIN_MEMORY_STAT_NR,flags); + retval=virDomainMemoryStats(domain->domain, stats, VIR_DOMAIN_MEMORY_STAT_NR, flags); DPRINTF("%s: virDomainMemoryStats(%p...) returned %d\n", PHPFUNC, domain->domain, retval); if (retval == -1) RETURN_FALSE; @@ -6906,7 +6906,7 @@ PHP_FUNCTION(libvirt_domain_memory_stats) array_init(return_value); for (i=0;i<retval;i++) { - LONGLONG_INDEX(return_value, stats[i].tag,stats[i].val) + LONGLONG_INDEX(return_value, stats[i].tag, stats[i].val) } } @@ -6928,9 +6928,9 @@ PHP_FUNCTION(libvirt_domain_update_device) zend_long flags; int res; - GET_DOMAIN_FROM_ARGS("rsl",&zdomain,&xml,&xml_len,&flags); + GET_DOMAIN_FROM_ARGS("rsl", &zdomain, &xml, &xml_len, &flags); - res=virDomainUpdateDeviceFlags(domain->domain,xml,flags); + res=virDomainUpdateDeviceFlags(domain->domain, xml, flags); DPRINTF("%s: virDomainUpdateDeviceFlags(%p) returned %d\n", PHPFUNC, domain->domain, res); if (res != 0) RETURN_FALSE; @@ -6956,9 +6956,9 @@ PHP_FUNCTION(libvirt_domain_block_stats) struct _virDomainBlockStats stats; - GET_DOMAIN_FROM_ARGS("rs",&zdomain,&path,&path_len); + GET_DOMAIN_FROM_ARGS("rs", &zdomain, &path, &path_len); - retval=virDomainBlockStats(domain->domain,path,&stats, sizeof stats); + retval=virDomainBlockStats(domain->domain, path, &stats, sizeof stats); DPRINTF("%s: virDomainBlockStats(%p,%s,<stats>,<size>) returned %d\n", PHPFUNC, domain->domain, path, retval); if (retval == -1) RETURN_FALSE; @@ -6991,7 +6991,7 @@ PHP_FUNCTION(libvirt_domain_block_resize) zend_long size = 0; zend_long flags = 0; - GET_DOMAIN_FROM_ARGS("rsl|l",&zdomain, &path, &path_len, &size, &flags); + GET_DOMAIN_FROM_ARGS("rsl|l", &zdomain, &path, &path_len, &size, &flags); retval=virDomainBlockResize(domain->domain, path, size, flags); if (retval == -1) RETURN_FALSE; @@ -7025,7 +7025,7 @@ PHP_FUNCTION(libvirt_domain_block_commit) long bandwidth = 0; long flags = 0; - GET_DOMAIN_FROM_ARGS("rsssll",&zdomain, &disk, &disk_len, &base, &base_len, &top, &top_len, &bandwidth, &flags); + GET_DOMAIN_FROM_ARGS("rsssll", &zdomain, &disk, &disk_len, &base, &base_len, &top, &top_len, &bandwidth, &flags); retval=virDomainBlockCommit(domain->domain, disk, base, top, bandwidth, flags); if (retval == -1) RETURN_FALSE; @@ -7053,7 +7053,7 @@ PHP_FUNCTION(libvirt_domain_block_job_info) long flags = 0; virDomainBlockJobInfo info; - GET_DOMAIN_FROM_ARGS("rs|l",&zdomain, &disk, &disk_len, &flags); + GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &disk, &disk_len, &flags); retval=virDomainGetBlockJobInfo(domain->domain, disk, &info, flags); @@ -7084,7 +7084,7 @@ PHP_FUNCTION(libvirt_domain_block_job_abort) strsize_t path_len; zend_long flags = 0; - GET_DOMAIN_FROM_ARGS("rs|l",&zdomain, &path, &path_len, &flags); + GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &path, &path_len, &flags); retval=virDomainBlockJobAbort(domain->domain, path, flags); if (retval == -1) RETURN_FALSE; @@ -7112,7 +7112,7 @@ PHP_FUNCTION(libvirt_domain_block_job_set_speed) zend_long bandwidth = 0; zend_long flags = 0; - GET_DOMAIN_FROM_ARGS("rsl|l",&zdomain, &path, &path_len, &bandwidth, &flags); + GET_DOMAIN_FROM_ARGS("rsl|l", &zdomain, &path, &path_len, &bandwidth, &flags); retval=virDomainBlockJobSetSpeed(domain->domain, path, bandwidth, flags); if (retval == -1) RETURN_FALSE; @@ -7141,7 +7141,7 @@ PHP_FUNCTION(libvirt_domain_get_network_info) strsize_t mac_len; char *xpath = NULL; - GET_DOMAIN_FROM_ARGS("rs",&zdomain,&mac,&mac_len); + GET_DOMAIN_FROM_ARGS("rs", &zdomain, &mac, &mac_len); /* Get XML for the domain */ xml = virDomainGetXMLDesc(domain->domain, VIR_DOMAIN_XML_INACTIVE); @@ -7217,7 +7217,7 @@ PHP_FUNCTION(libvirt_domain_get_block_info) struct _virDomainBlockInfo info; - GET_DOMAIN_FROM_ARGS("rs",&zdomain,&dev,&dev_len); + GET_DOMAIN_FROM_ARGS("rs", &zdomain, &dev, &dev_len); /* Get XML for the domain */ xml = virDomainGetXMLDesc(domain->domain, VIR_DOMAIN_XML_INACTIVE); @@ -7258,7 +7258,7 @@ PHP_FUNCTION(libvirt_domain_get_block_info) goto error; } - retval = virDomainGetBlockInfo(domain->domain, tmp, &info,0); + retval = virDomainGetBlockInfo(domain->domain, tmp, &info, 0); if (retval == -1) { set_error("Cannot get domain block information" TSRMLS_CC); goto error; @@ -7319,7 +7319,7 @@ PHP_FUNCTION(libvirt_domain_xml_xpath) zend_long flags = 0; int rc = 0; - GET_DOMAIN_FROM_ARGS("rs|l",&zdomain, &zpath, &path_len, &flags); + GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &zpath, &path_len, &flags); xml = virDomainGetXMLDesc(domain->domain, flags); if (!xml) @@ -7362,9 +7362,9 @@ PHP_FUNCTION(libvirt_domain_interface_stats) struct _virDomainInterfaceStats stats; - GET_DOMAIN_FROM_ARGS("rs",&zdomain,&path,&path_len); + GET_DOMAIN_FROM_ARGS("rs", &zdomain, &path, &path_len); - retval=virDomainInterfaceStats(domain->domain,path,&stats, sizeof stats); + retval=virDomainInterfaceStats(domain->domain, path, &stats, sizeof stats); DPRINTF("%s: virDomainInterfaceStats(%p,%s,<stats>,<size>) returned %d\n", PHPFUNC, domain->domain, path, retval); if (retval == -1) RETURN_FALSE; @@ -7395,7 +7395,7 @@ PHP_FUNCTION(libvirt_domain_get_connect) DPRINTF("%s: Warning: libvirt_domain_get_connect() used. This function should not be used!\n", PHPFUNC); - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); conn= domain->conn; if (conn->conn == NULL) RETURN_FALSE; @@ -7432,9 +7432,9 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri) dname=NULL; dname_len=0; bandwidth=0; - GET_DOMAIN_FROM_ARGS("rsl|sl",&zdomain,&duri,&duri_len,&flags,&dname,&dname_len,&bandwidth); + GET_DOMAIN_FROM_ARGS("rsl|sl", &zdomain, &duri, &duri_len, &flags, &dname, &dname_len, &bandwidth); - retval=virDomainMigrateToURI(domain->domain,duri,flags,dname,bandwidth); + retval=virDomainMigrateToURI(domain->domain, duri, flags, dname, bandwidth); DPRINTF("%s: virDomainMigrateToURI() returned %d\n", PHPFUNC, retval); if (retval == 0) RETURN_TRUE; @@ -7479,7 +7479,7 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri2) dname=NULL; dname_len=0; bandwidth=0; - GET_DOMAIN_FROM_ARGS("r|ssslsl",&zdomain,&dconnuri,&dconnuri_len,&miguri,&miguri_len,&dxml,&dxml_len,&flags,&dname,&dname_len,&bandwidth); + GET_DOMAIN_FROM_ARGS("r|ssslsl", &zdomain, &dconnuri, &dconnuri_len, &miguri, &miguri_len, &dxml, &dxml_len, &flags, &dname, &dname_len, &bandwidth); // set to NULL if empty string if (dconnuri_len == 0) dconnuri=NULL; @@ -7487,7 +7487,7 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri2) if (dxml_len == 0) dxml=NULL; if (dname_len == 0) dname=NULL; - retval=virDomainMigrateToURI2(domain->domain,dconnuri,miguri,dxml,flags,dname,bandwidth); + retval=virDomainMigrateToURI2(domain->domain, dconnuri, miguri, dxml, flags, dname, bandwidth); DPRINTF("%s: virDomainMigrateToURI2() returned %d\n", PHPFUNC, retval); if (retval == 0) RETURN_TRUE; @@ -7523,7 +7523,7 @@ PHP_FUNCTION(libvirt_domain_migrate) dname_len=0; bandwidth=0; - GET_DOMAIN_FROM_ARGS("rrl|sl",&zdomain,&zdconn,&flags,&dname,&dname_len,&bandwidth); + GET_DOMAIN_FROM_ARGS("rrl|sl", &zdomain, &zdconn, &flags, &dname, &dname_len, &bandwidth); if ((domain->domain == NULL) || (domain->conn->conn == NULL)) { set_error("Domain object is not valid" TSRMLS_CC); @@ -7567,9 +7567,9 @@ PHP_FUNCTION(libvirt_domain_get_job_info) struct _virDomainJobInfo jobinfo; - GET_DOMAIN_FROM_ARGS("r",&zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainGetJobInfo(domain->domain,&jobinfo); + retval=virDomainGetJobInfo(domain->domain, &jobinfo); if (retval == -1) RETURN_FALSE; array_init(return_value); @@ -7603,7 +7603,7 @@ PHP_FUNCTION(libvirt_domain_has_current_snapshot) int retval; zend_long flags = 0; - GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags); + GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags); retval=virDomainHasCurrentSnapshot(domain->domain, flags); if (retval <= 0) RETURN_FALSE; @@ -7629,7 +7629,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name) php_libvirt_snapshot *res_snapshot; virDomainSnapshotPtr snapshot = NULL; - GET_DOMAIN_FROM_ARGS("rs|l",&zdomain,&name,&name_len,&flags); + GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &name, &name_len, &flags); if ( (name == NULL) || (name_len<1)) RETURN_FALSE; snapshot=virDomainSnapshotLookupByName(domain->domain, name, flags); @@ -7664,7 +7664,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_create) virDomainSnapshotPtr snapshot = NULL; zend_long flags = 0; - GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags); + GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags); snapshot=virDomainSnapshotCreateXML(domain->domain, "<domainsnapshot/>", flags); DPRINTF("%s: virDomainSnapshotCreateXML(%p, <xml>) returned %p\n", PHPFUNC, domain->domain, snapshot); @@ -7698,7 +7698,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml) php_libvirt_snapshot *snapshot; zend_long flags = 0; - GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags); + GET_SNAPSHOT_FROM_ARGS("r|l", &zsnapshot, &flags); xml = virDomainSnapshotGetXMLDesc(snapshot->snapshot, flags); if (xml==NULL) RETURN_FALSE; @@ -7722,7 +7722,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_revert) int ret; zend_long flags = 0; - GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags); + GET_SNAPSHOT_FROM_ARGS("r|l", &zsnapshot, &flags); ret = virDomainRevertToSnapshot(snapshot->snapshot, flags); DPRINTF("%s: virDomainRevertToSnapshot(%p, 0) returned %d\n", PHPFUNC, snapshot->snapshot, ret); @@ -7745,7 +7745,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_delete) zend_long flags = 0; int retval; - GET_SNAPSHOT_FROM_ARGS("r|l",&zsnapshot, &flags); + GET_SNAPSHOT_FROM_ARGS("r|l", &zsnapshot, &flags); retval = virDomainSnapshotDelete(snapshot->snapshot, flags); DPRINTF("%s: virDomainSnapshotDelete(%p, %d) returned %d\n", PHPFUNC, snapshot->snapshot, (int) flags, retval); @@ -7771,7 +7771,7 @@ PHP_FUNCTION(libvirt_list_domain_snapshots) zend_long flags = 0; int i; - GET_DOMAIN_FROM_ARGS("r|l",&zdomain, &flags); + GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags); expectedcount=virDomainSnapshotNum(domain->domain, flags); DPRINTF("%s: virDomainSnapshotNum(%p, 0) returned %d\n", PHPFUNC, domain->domain, expectedcount); @@ -7813,10 +7813,10 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_name) virStoragePoolPtr pool=NULL; php_libvirt_storagepool *res_pool; - GET_CONNECTION_FROM_ARGS("rs",&zconn,&name,&name_len); + GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); if ( (name == NULL) || (name_len<1)) RETURN_FALSE; - pool=virStoragePoolLookupByName(conn->conn,name); + pool=virStoragePoolLookupByName(conn->conn, name); DPRINTF("%s: virStoragePoolLookupByName(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, pool); if (pool==NULL) RETURN_FALSE; @@ -7885,7 +7885,7 @@ PHP_FUNCTION(libvirt_storagepool_list_volumes) int i; int count=-1; - GET_STORAGEPOOL_FROM_ARGS("r",&zpool); + GET_STORAGEPOOL_FROM_ARGS("r", &zpool); if ((expectedcount=virStoragePoolNumOfVolumes (pool->pool)) < 0) RETURN_FALSE; @@ -7893,7 +7893,7 @@ PHP_FUNCTION(libvirt_storagepool_list_volumes) DPRINTF("%s: virStoragePoolNumOfVolumes(%p) returned %d\n", PHPFUNC, pool->pool, expectedcount); names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virStoragePoolListVolumes(pool->pool,names,expectedcount); + count=virStoragePoolListVolumes(pool->pool, names, expectedcount); DPRINTF("%s: virStoragePoolListVolumes(%p,%p,%d) returned %d\n", PHPFUNC, pool->pool, names, expectedcount, count); array_init(return_value); @@ -7921,9 +7921,9 @@ PHP_FUNCTION(libvirt_storagepool_get_info) virStoragePoolInfo poolInfo; int retval; - GET_STORAGEPOOL_FROM_ARGS("r",&zpool); + GET_STORAGEPOOL_FROM_ARGS("r", &zpool); - retval=virStoragePoolGetInfo(pool->pool,&poolInfo); + retval=virStoragePoolGetInfo(pool->pool, &poolInfo); DPRINTF("%s: virStoragePoolGetInfo(%p, <info>) returned %d\n", PHPFUNC, pool->pool, retval); if (retval != 0) RETURN_FALSE; @@ -7954,10 +7954,10 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name) char *name=NULL; virStorageVolPtr volume=NULL; - GET_STORAGEPOOL_FROM_ARGS("rs",&zpool,&name,&name_len); + GET_STORAGEPOOL_FROM_ARGS("rs", &zpool, &name, &name_len); if ( (name == NULL) || (name_len<1)) RETURN_FALSE; - volume=virStorageVolLookupByName (pool->pool,name); + volume=virStorageVolLookupByName (pool->pool, name); DPRINTF("%s: virStorageVolLookupByName(%p, %s) returned %p\n", PHPFUNC, pool->pool, name, volume); if (volume==NULL) RETURN_FALSE; @@ -7991,10 +7991,10 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_path) char *name=NULL; virStorageVolPtr volume=NULL; - GET_CONNECTION_FROM_ARGS("rs",&zconn,&name,&name_len); + GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); if ( (name == NULL) || (name_len<1)) RETURN_FALSE; - volume=virStorageVolLookupByPath (conn->conn,name); + volume=virStorageVolLookupByPath (conn->conn, name); DPRINTF("%s: virStorageVolLookupByPath(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, volume); if (volume==NULL) { @@ -8074,9 +8074,9 @@ PHP_FUNCTION(libvirt_storagevolume_get_info) virStorageVolInfo volumeInfo; int retval; - GET_VOLUME_FROM_ARGS("r",&zvolume); + GET_VOLUME_FROM_ARGS("r", &zvolume); - retval=virStorageVolGetInfo(volume->volume,&volumeInfo); + retval=virStorageVolGetInfo(volume->volume, &volumeInfo); DPRINTF("%s: virStorageVolGetInfo(%p, <info>) returned %d\n", PHPFUNC, volume->volume, retval); if (retval != 0) RETURN_FALSE; @@ -8107,13 +8107,13 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc) zend_long flags=0; int retval = -1; - GET_VOLUME_FROM_ARGS("rs|l",&zvolume,&xpath,&xpath_len,&flags); + GET_VOLUME_FROM_ARGS("rs|l", &zvolume, &xpath, &xpath_len, &flags); if (xpath_len < 1) xpath = NULL; DPRINTF("%s: volume = %p, xpath = %s, flags = %ld\n", PHPFUNC, volume->volume, xpath, flags); - xml=virStorageVolGetXMLDesc(volume->volume,flags); + xml=virStorageVolGetXMLDesc(volume->volume, flags); if (xml==NULL) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); RETURN_FALSE; @@ -8149,7 +8149,7 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml) zend_long flags = 0; strsize_t xml_len; - GET_STORAGEPOOL_FROM_ARGS("rs|l",&zpool,&xml,&xml_len, &flags); + GET_STORAGEPOOL_FROM_ARGS("rs|l", &zpool, &xml, &xml_len, &flags); volume=virStorageVolCreateXML(pool->pool, xml, flags); DPRINTF("%s: virStorageVolCreateXML(%p, <xml>, 0) returned %p\n", PHPFUNC, pool->pool, volume); @@ -8202,7 +8202,7 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) if ((pl_volume==NULL)||(pl_volume->volume==NULL))RETURN_FALSE; resource_change_counter(INT_RESOURCE_VOLUME, NULL, pl_volume->volume, 1 TSRMLS_CC); - volume=virStorageVolCreateXMLFrom(pool->pool,xml, pl_volume->volume, 0); + volume=virStorageVolCreateXMLFrom(pool->pool, xml, pl_volume->volume, 0); DPRINTF("%s: virStorageVolCreateXMLFrom(%p, <xml>, %p, 0) returned %p\n", PHPFUNC, pool->pool, pl_volume->volume, volume); if (volume==NULL) RETURN_FALSE; @@ -8234,7 +8234,7 @@ PHP_FUNCTION(libvirt_storagevolume_delete) zend_long flags = 0; int retval = 0; - GET_VOLUME_FROM_ARGS("r|l",&zvolume,&flags); + GET_VOLUME_FROM_ARGS("r|l", &zvolume, &flags); retval = virStorageVolDelete(volume->volume, flags); DPRINTF("%s: virStorageVolDelete(%p, %d) returned %d\n", PHPFUNC, volume->volume, (int) flags, retval); @@ -8765,13 +8765,13 @@ PHP_FUNCTION(libvirt_list_storagepools) char **names; int i; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); if ((expectedcount=virConnectNumOfStoragePools(conn->conn)) < 0) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListStoragePools(conn->conn,names,expectedcount); + count=virConnectListStoragePools(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { @@ -8822,13 +8822,13 @@ PHP_FUNCTION(libvirt_list_active_storagepools) char **names; int i; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); if ((expectedcount=virConnectNumOfStoragePools(conn->conn)) < 0) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListStoragePools(conn->conn,names,expectedcount); + count=virConnectListStoragePools(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { @@ -8860,7 +8860,7 @@ PHP_FUNCTION(libvirt_list_inactive_storagepools) char **names; int i; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); if ((expectedcount = virConnectNumOfDefinedStoragePools (conn->conn)) < 0) RETURN_FALSE; @@ -8901,7 +8901,7 @@ PHP_FUNCTION(libvirt_list_domains) int i, rv; virDomainPtr domain=NULL; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); if ((expectedcount=virConnectNumOfDomains (conn->conn)) < 0) RETURN_FALSE; @@ -8909,13 +8909,13 @@ PHP_FUNCTION(libvirt_list_domains) DPRINTF("%s: Found %d domains\n", PHPFUNC, expectedcount); ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains (conn->conn,ids,expectedcount); + count=virConnectListDomains (conn->conn, ids, expectedcount); DPRINTF("%s: virConnectListDomains returned %d domains\n", PHPFUNC, count); array_init(return_value); for (i=0;i<count;i++) { - domain=virDomainLookupByID(conn->conn,ids[i]); + domain=virDomainLookupByID(conn->conn, ids[i]); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, domain, 1 TSRMLS_CC); if (domain!=NULL) { @@ -8929,7 +8929,7 @@ PHP_FUNCTION(libvirt_list_domains) } rv = virDomainFree (domain); if (rv != 0) { - php_error_docref(NULL TSRMLS_CC, E_WARNING,"virDomainFree failed with %i on list_domain: %s", + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on list_domain: %s", rv, LIBVIRT_G (last_error)); } else { @@ -8947,7 +8947,7 @@ PHP_FUNCTION(libvirt_list_domains) } names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedDomains (conn->conn,names,expectedcount); + count=virConnectListDefinedDomains (conn->conn, names, expectedcount); DPRINTF("%s: virConnectListDefinedDomains returned %d domains\n", PHPFUNC, count); if (count < 0) { DPRINTF("%s: virConnectListDefinedDomains failed with error code %d\n", PHPFUNC, count); @@ -8988,13 +8988,13 @@ PHP_FUNCTION(libvirt_list_domain_resources) virDomainPtr domain=NULL; php_libvirt_domain *res_domain; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); if ((expectedcount=virConnectNumOfDomains (conn->conn)) < 0) RETURN_FALSE; ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains (conn->conn,ids,expectedcount); + count=virConnectListDomains (conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { efree (ids); @@ -9003,7 +9003,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) array_init(return_value); for (i=0;i<count;i++) { - domain=virDomainLookupByID(conn->conn,ids[i]); + domain=virDomainLookupByID(conn->conn, ids[i]); if (domain!=NULL) { res_domain= (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -9028,7 +9028,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedDomains (conn->conn,names ,expectedcount); + count=virConnectListDefinedDomains (conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { efree (names); @@ -9036,7 +9036,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) } for (i=0;i<count;i++) { - domain=virDomainLookupByName (conn->conn,names[i]); + domain=virDomainLookupByName (conn->conn, names[i]); if (domain!=NULL) { res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -9075,13 +9075,13 @@ PHP_FUNCTION(libvirt_list_active_domain_ids) int *ids; int i; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); if ((expectedcount=virConnectNumOfDomains (conn->conn)) < 0) RETURN_FALSE; ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains (conn->conn,ids,expectedcount); + count=virConnectListDomains (conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { efree (ids); @@ -9113,13 +9113,13 @@ PHP_FUNCTION(libvirt_list_active_domains) virDomainPtr domain = NULL; const char *name; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); if ((expectedcount=virConnectNumOfDomains (conn->conn)) < 0) RETURN_FALSE; ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains (conn->conn,ids,expectedcount); + count=virConnectListDomains (conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { efree (ids); @@ -9129,7 +9129,7 @@ PHP_FUNCTION(libvirt_list_active_domains) array_init(return_value); for (i=0;i<count;i++) { - domain=virDomainLookupByID(conn->conn,ids[i]); + domain=virDomainLookupByID(conn->conn, ids[i]); if (domain!=NULL) { if (!(name = virDomainGetName(domain))) { @@ -9162,13 +9162,13 @@ PHP_FUNCTION(libvirt_list_inactive_domains) char **names; int i; - GET_CONNECTION_FROM_ARGS("r",&zconn); + GET_CONNECTION_FROM_ARGS("r", &zconn); if ((expectedcount=virConnectNumOfDefinedDomains (conn->conn)) < 0) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedDomains (conn->conn,names ,expectedcount); + count=virConnectListDefinedDomains (conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { efree (names); @@ -9202,7 +9202,7 @@ PHP_FUNCTION(libvirt_list_networks) char **names; int i, done = 0; - GET_CONNECTION_FROM_ARGS("r|l",&zconn,&flags); + GET_CONNECTION_FROM_ARGS("r|l", &zconn, &flags); array_init(return_value); if (flags & VIR_NETWORKS_ACTIVE) { @@ -9210,7 +9210,7 @@ PHP_FUNCTION(libvirt_list_networks) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListNetworks(conn->conn,names,expectedcount); + count=virConnectListNetworks(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { efree (names); @@ -9231,7 +9231,7 @@ PHP_FUNCTION(libvirt_list_networks) if ((expectedcount=virConnectNumOfDefinedNetworks(conn->conn)) < 0) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedNetworks(conn->conn,names,expectedcount); + count=virConnectListDefinedNetworks(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { efree (names); @@ -9271,7 +9271,7 @@ PHP_FUNCTION(libvirt_list_nodedevs) int i; strsize_t cap_len; - GET_CONNECTION_FROM_ARGS("r|s",&zconn,&cap,&cap_len); + GET_CONNECTION_FROM_ARGS("r|s", &zconn, &cap, &cap_len); if ((expectedcount=virNodeNumOfDevices(conn->conn, cap, 0)) < 0) RETURN_FALSE; @@ -9311,7 +9311,7 @@ PHP_FUNCTION(libvirt_nodedev_get) char *name; strsize_t name_len; - GET_CONNECTION_FROM_ARGS("rs",&zconn,&name,&name_len); + GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); if ((dev = virNodeDeviceLookupByName(conn->conn, name)) == NULL) { set_error("Cannot get find requested node device" TSRMLS_CC); @@ -9347,7 +9347,7 @@ PHP_FUNCTION(libvirt_nodedev_capabilities) char **names; int i; - GET_NODEDEV_FROM_ARGS("r",&znodedev); + GET_NODEDEV_FROM_ARGS("r", &znodedev); if ((expectedcount=virNodeDeviceNumOfCaps(nodedev->device)) < 0) RETURN_FALSE; @@ -9383,7 +9383,7 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc) strsize_t xpath_len; int retval = -1; - GET_NODEDEV_FROM_ARGS("r|s",&znodedev,&xpath,&xpath_len); + GET_NODEDEV_FROM_ARGS("r|s", &znodedev, &xpath, &xpath_len); if (xpath_len < 1) { xpath = NULL; @@ -9422,7 +9422,7 @@ PHP_FUNCTION(libvirt_nodedev_get_information) char *tmp = NULL; char *cap = NULL; - GET_NODEDEV_FROM_ARGS("r",&znodedev); + GET_NODEDEV_FROM_ARGS("r", &znodedev); xml = virNodeDeviceGetXMLDesc(nodedev->device, 0); if (!xml) { @@ -9581,7 +9581,7 @@ PHP_FUNCTION(libvirt_network_define_xml) char *xml = NULL; strsize_t xml_len; - GET_CONNECTION_FROM_ARGS("rs",&zconn,&xml,&xml_len); + GET_CONNECTION_FROM_ARGS("rs", &zconn, &xml, &xml_len); if ((net = virNetworkDefineXML(conn->conn, xml)) == NULL) { set_error_if_unset("Cannot define a new network" TSRMLS_CC); @@ -9613,7 +9613,7 @@ PHP_FUNCTION(libvirt_network_undefine) php_libvirt_network *network = NULL; zval *znetwork; - GET_NETWORK_FROM_ARGS("r",&znetwork); + GET_NETWORK_FROM_ARGS("r", &znetwork); if (virNetworkUndefine(network->network) != 0) RETURN_FALSE; @@ -9638,7 +9638,7 @@ PHP_FUNCTION(libvirt_network_get) char *name; strsize_t name_len; - GET_CONNECTION_FROM_ARGS("rs",&zconn,&name,&name_len); + GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); if ((net = virNetworkLookupByName(conn->conn, name)) == NULL) { set_error_if_unset("Cannot get find requested network" TSRMLS_CC); @@ -9671,7 +9671,7 @@ PHP_FUNCTION(libvirt_network_get_bridge) zval *znetwork; char *name; - GET_NETWORK_FROM_ARGS("r",&znetwork); + GET_NETWORK_FROM_ARGS("r", &znetwork); name = virNetworkGetBridgeName(network->network); @@ -9697,7 +9697,7 @@ PHP_FUNCTION(libvirt_network_get_active) zval *znetwork; int res; - GET_NETWORK_FROM_ARGS("r",&znetwork); + GET_NETWORK_FROM_ARGS("r", &znetwork); res = virNetworkIsActive(network->network); @@ -9731,7 +9731,7 @@ PHP_FUNCTION(libvirt_network_get_information) char *dhcp_end = NULL; char fixedtemp[32] = { 0 }; - GET_NETWORK_FROM_ARGS("r",&znetwork); + GET_NETWORK_FROM_ARGS("r", &znetwork); xml=virNetworkGetXMLDesc(network->network, 0); @@ -9866,7 +9866,7 @@ PHP_FUNCTION(libvirt_network_get_xml_desc) strsize_t xpath_len; int retval = -1; - GET_NETWORK_FROM_ARGS("r|s",&znetwork,&xpath,&xpath_len); + GET_NETWORK_FROM_ARGS("r|s", &znetwork, &xpath, &xpath_len); if (xpath_len < 1) { xpath = NULL; @@ -9903,25 +9903,25 @@ PHP_FUNCTION(libvirt_version) unsigned long typeVer; strsize_t type_len; char *type=NULL; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type,&type_len) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type, &type_len) == FAILURE) { set_error("Invalid arguments" TSRMLS_CC); RETURN_FALSE; } if (ZEND_NUM_ARGS() == 0) { - if (virGetVersion(&libVer,NULL,NULL) != 0) + if (virGetVersion(&libVer, NULL, NULL) != 0) RETURN_FALSE; } else { - if (virGetVersion(&libVer,type,&typeVer) != 0) + if (virGetVersion(&libVer, type, &typeVer) != 0) RETURN_FALSE; } /* The version is returned as: major * 1,000,000 + minor * 1,000 + release. */ array_init(return_value); - add_assoc_long(return_value, "libvirt.release",(long)(libVer %1000)); - add_assoc_long(return_value, "libvirt.minor",(long)((libVer/1000) % 1000)); - add_assoc_long(return_value, "libvirt.major",(long)((libVer/1000000) % 1000)); + add_assoc_long(return_value, "libvirt.release", (long)(libVer %1000)); + add_assoc_long(return_value, "libvirt.minor", (long)((libVer/1000) % 1000)); + add_assoc_long(return_value, "libvirt.major", (long)((libVer/1000000) % 1000)); VIRT_ADD_ASSOC_STRING(return_value, "connector.version", PHP_LIBVIRT_WORLD_VERSION); add_assoc_long(return_value, "connector.major", VERSION_MAJOR); @@ -9929,9 +9929,9 @@ PHP_FUNCTION(libvirt_version) add_assoc_long(return_value, "connector.release", VERSION_MICRO); if (ZEND_NUM_ARGS() > 0) { - add_assoc_long(return_value, "type.release",(long)(typeVer %1000)); - add_assoc_long(return_value, "type.minor",(long)((typeVer/1000) % 1000)); - add_assoc_long(return_value, "type.major",(long)((typeVer/1000000) % 1000)); + add_assoc_long(return_value, "type.release", (long)(typeVer %1000)); + add_assoc_long(return_value, "type.minor", (long)((typeVer/1000) % 1000)); + add_assoc_long(return_value, "type.major", (long)((typeVer/1000000) % 1000)); } } @@ -9955,7 +9955,7 @@ PHP_FUNCTION(libvirt_check_version) RETURN_FALSE; } - if (virGetVersion(&libVer,NULL,NULL) != 0) + if (virGetVersion(&libVer, NULL, NULL) != 0) RETURN_FALSE; DPRINTF("%s: Checking for version %lu.%lu.%lu of %s\n", PHPFUNC, major, minor, micro, -- 2.7.3

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 122 +++++++++++++++++++++++++++--------------------------- 1 file changed, 61 insertions(+), 61 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index b28d4b4..a325b1f 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -834,8 +834,8 @@ PHP_RINIT_FUNCTION(libvirt) /* PHP request destruction */ PHP_RSHUTDOWN_FUNCTION(libvirt) { - if (LIBVIRT_G (last_error)!=NULL) efree(LIBVIRT_G (last_error)); - if (LIBVIRT_G (vnc_location)!=NULL) efree(LIBVIRT_G (vnc_location)); + if (LIBVIRT_G (last_error) != NULL) efree(LIBVIRT_G (last_error)); + if (LIBVIRT_G (vnc_location) != NULL) efree(LIBVIRT_G (vnc_location)); return SUCCESS; } @@ -1116,7 +1116,7 @@ PHP_MINFO_FUNCTION(libvirt) php_info_print_table_row(2, "Debug support", tmp); php_info_print_table_row(2, "Extension version", PHP_LIBVIRT_WORLD_VERSION); - if (virGetVersion(&libVer, NULL, NULL)== 0) + if (virGetVersion(&libVer, NULL, NULL) == 0) { char version[100]; snprintf(version, sizeof(version), "%i.%i.%i", (long)((libVer/1000000) % 1000), (long)((libVer/1000) % 1000), (long)(libVer % 1000)); @@ -1603,7 +1603,7 @@ static void php_libvirt_storagepool_dtor( return; } rv = virStoragePoolFree(pool->pool); - if (rv!=0) { + if (rv != 0) { DPRINTF("%s: virStoragePoolFree(%p) returned %d (%s)\n", __FUNCTION__, pool->pool, rv, LIBVIRT_G (last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } @@ -1639,7 +1639,7 @@ static void php_libvirt_volume_dtor( return; } rv = virStorageVolFree (volume->volume); - if (rv!=0) { + if (rv != 0) { DPRINTF("%s: virStorageVolFree(%p) returned %d (%s)\n", __FUNCTION__, volume->volume, rv, LIBVIRT_G (last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } @@ -1675,7 +1675,7 @@ static void php_libvirt_network_dtor( return; } rv = virNetworkFree(network->network); - if (rv!=0) { + if (rv != 0) { DPRINTF("%s: virNetworkFree(%p) returned %d (%s)\n", __FUNCTION__, network->network, rv, LIBVIRT_G (last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } @@ -1711,7 +1711,7 @@ static void php_libvirt_nodedev_dtor( return; } rv = virNodeDeviceFree(nodedev->device); - if (rv!=0) { + if (rv != 0) { DPRINTF("%s: virNodeDeviceFree(%p) returned %d (%s)\n", __FUNCTION__, nodedev->device, rv, LIBVIRT_G (last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } @@ -1747,7 +1747,7 @@ static void php_libvirt_snapshot_dtor( return; } rv = virDomainSnapshotFree(snapshot->snapshot); - if (rv!=0) { + if (rv != 0) { DPRINTF("%s: virDomainSnapshotFree(%p) returned %d\n", __FUNCTION__, snapshot->snapshot, rv); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); } @@ -2086,7 +2086,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection);\ -if ((conn==NULL) || (conn->conn==NULL)) RETURN_FALSE;\ +if ((conn == NULL) || (conn->conn == NULL)) RETURN_FALSE;\ #define GET_DOMAIN_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2096,7 +2096,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(domain, php_libvirt_domain*, &zdomain, PHP_LIBVIRT_DOMAIN_RES_NAME, le_libvirt_domain);\ -if ((domain==NULL) || (domain->domain==NULL)) RETURN_FALSE;\ +if ((domain == NULL) || (domain->domain == NULL)) RETURN_FALSE;\ #define GET_NETWORK_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2106,7 +2106,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(network, php_libvirt_network*, &znetwork, PHP_LIBVIRT_NETWORK_RES_NAME, le_libvirt_network);\ -if ((network==NULL) || (network->network==NULL)) RETURN_FALSE;\ +if ((network == NULL) || (network->network == NULL)) RETURN_FALSE;\ #define GET_NODEDEV_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2116,7 +2116,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(nodedev, php_libvirt_nodedev*, &znodedev, PHP_LIBVIRT_NODEDEV_RES_NAME, le_libvirt_nodedev);\ -if ((nodedev==NULL) || (nodedev->device==NULL)) RETURN_FALSE;\ +if ((nodedev == NULL) || (nodedev->device == NULL)) RETURN_FALSE;\ #define GET_STORAGEPOOL_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2126,7 +2126,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool);\ -if ((pool==NULL) || (pool->pool==NULL)) RETURN_FALSE;\ +if ((pool == NULL) || (pool->pool == NULL)) RETURN_FALSE;\ #define GET_VOLUME_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2136,7 +2136,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);\ -if ((volume==NULL) || (volume->volume==NULL)) RETURN_FALSE;\ +if ((volume == NULL) || (volume->volume == NULL)) RETURN_FALSE;\ #define GET_SNAPSHOT_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2146,7 +2146,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(snapshot, php_libvirt_snapshot*, &zsnapshot, PHP_LIBVIRT_SNAPSHOT_RES_NAME, le_libvirt_snapshot);\ -if ((snapshot==NULL) || (snapshot->snapshot==NULL)) RETURN_FALSE;\ +if ((snapshot == NULL) || (snapshot->snapshot == NULL)) RETURN_FALSE;\ #define LONGLONG_INIT \ char tmpnumber[64] @@ -2189,7 +2189,7 @@ static int libvirt_virConnectAuthCallback(virConnectCredentialPtr cred, unsigned if (creds != NULL) for (j = 0; j < (unsigned int)creds[0].count; j++) { - if (creds[j].type==cred[i].type) + if (creds[j].type == cred[i].type) { cred[i].resultlen=creds[j].resultlen; cred[i].result=(char *)malloc(creds[j].resultlen + 1); @@ -2266,7 +2266,7 @@ PHP_FUNCTION(libvirt_connect) if (virGetVersion(&libVer, NULL, NULL)!= 0) RETURN_FALSE; - if (libVer<6002) + if (libVer < 6002) { set_error("Only libvirt 0.6.2 and higher supported. Please upgrade your libvirt" TSRMLS_CC); RETURN_FALSE; @@ -2283,7 +2283,7 @@ PHP_FUNCTION(libvirt_connect) url = NULL; conn=(php_libvirt_connection *)emalloc(sizeof(php_libvirt_connection)); - if (zcreds==NULL) + if (zcreds == NULL) { /* connecting without providing authentication */ if (readonly) conn->conn = virConnectOpenReadOnly(url); @@ -2321,7 +2321,7 @@ PHP_FUNCTION(libvirt_connect) creds[0].count=j; libvirt_virConnectAuth.cbdata = (void*)creds; conn->conn = virConnectOpenAuth (url, &libvirt_virConnectAuth, readonly ? VIR_CONNECT_RO : 0); - for (i=0;i<creds[0].count;i++) + for (i=0;i < creds[0].count;i++) efree(creds[i].result); efree(creds); } @@ -2363,7 +2363,7 @@ PHP_FUNCTION(libvirt_node_get_info) retval=virNodeGetInfo (conn->conn, &info); DPRINTF("%s: virNodeGetInfo returned %d\n", PHPFUNC, retval); - if (retval==-1) RETURN_FALSE; + if (retval == -1) RETURN_FALSE; array_init(return_value); VIRT_ADD_ASSOC_STRING(return_value, "model", info.model); @@ -2941,7 +2941,7 @@ PHP_FUNCTION(libvirt_connect_get_hostname) hostname=virConnectGetHostname(conn->conn); DPRINTF("%s: virConnectGetHostname returned %s\n", PHPFUNC, hostname); - if (hostname==NULL) RETURN_FALSE; + if (hostname == NULL) RETURN_FALSE; VIRT_RETVAL_STRING(hostname); free(hostname); @@ -3258,7 +3258,7 @@ PHP_FUNCTION(libvirt_connect_get_sysinfo) GET_CONNECTION_FROM_ARGS("r", &zconn); sysinfo=virConnectGetSysinfo(conn->conn, 0); - if (sysinfo==NULL) RETURN_FALSE; + if (sysinfo == NULL) RETURN_FALSE; VIRT_RETVAL_STRING(sysinfo); free(sysinfo); @@ -4310,7 +4310,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_name) GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); if ( (name == NULL) || (name_len<1)) RETURN_FALSE; domain=virDomainLookupByName(conn->conn, name); - if (domain==NULL) RETURN_FALSE; + if (domain == NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -4346,7 +4346,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid) if ( (uuid == NULL) || (uuid_len<1)) RETURN_FALSE; domain=virDomainLookupByUUID(conn->conn, uuid); - if (domain==NULL) RETURN_FALSE; + if (domain == NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -4411,7 +4411,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string) if ( (uuid == NULL) || (uuid_len<1)) RETURN_FALSE; domain=virDomainLookupByUUIDString(conn->conn, uuid); - if (domain==NULL) RETURN_FALSE; + if (domain == NULL) RETURN_FALSE; res_domain =(php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -4444,10 +4444,10 @@ PHP_FUNCTION(libvirt_stream_create) RETURN_FALSE; } VIRT_FETCH_RESOURCE (conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection); - if ((conn==NULL)||(conn->conn==NULL))RETURN_FALSE; + if ((conn == NULL)||(conn->conn == NULL))RETURN_FALSE; stream = virStreamNew(conn->conn, 0); - if (stream==NULL) { + if (stream == NULL) { set_error("Cannot create new stream" TSRMLS_CC); RETURN_FALSE; } @@ -4481,7 +4481,7 @@ PHP_FUNCTION(libvirt_stream_close) RETURN_LONG(retval); } VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); retval = virStreamFree(stream->stream); if (retval != 0) { @@ -4510,7 +4510,7 @@ PHP_FUNCTION(libvirt_stream_abort) RETURN_LONG(retval); } VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); retval = virStreamAbort(stream->stream); if (retval != 0) { @@ -4537,7 +4537,7 @@ PHP_FUNCTION(libvirt_stream_finish) RETURN_LONG(retval); } VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); retval = virStreamFinish(stream->stream); if (retval != 0) { @@ -4568,7 +4568,7 @@ PHP_FUNCTION(libvirt_stream_recv) RETURN_LONG(retval); } VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); recv_buf = emalloc(length + 1); memset(recv_buf, 0, length + 1); @@ -4618,7 +4618,7 @@ PHP_FUNCTION(libvirt_stream_send) RETURN_LONG(retval); } VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); cstr = Z_STRVAL_P(zbuf); //cstrlen = Z_STRLEN_P(zbuf); @@ -4651,7 +4651,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_id) GET_CONNECTION_FROM_ARGS("rl", &zconn, &id); domain=virDomainLookupByID(conn->conn, (int)id); - if (domain==NULL) RETURN_FALSE; + if (domain == NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -4686,7 +4686,7 @@ PHP_FUNCTION(libvirt_domain_get_name) name = virDomainGetName(domain->domain); DPRINTF("%s: virDomainGetName(%p) returned %s\n", PHPFUNC, domain->domain, name); - if (name==NULL) RETURN_FALSE; + if (name == NULL) RETURN_FALSE; VIRT_RETURN_STRING(name); //we can use the copy mechanism as we need not to free name (we even can not!) } @@ -4710,7 +4710,7 @@ PHP_FUNCTION(libvirt_domain_get_uuid_string) uuid = (char *)emalloc(VIR_UUID_STRING_BUFLEN); retval=virDomainGetUUIDString(domain->domain, uuid); DPRINTF("%s: virDomainGetUUIDString(%p) returned %d (%s)\n", PHPFUNC, domain->domain, retval, uuid); - if (retval!=0) RETURN_FALSE; + if (retval != 0) RETURN_FALSE; VIRT_RETVAL_STRING(uuid); efree(uuid); @@ -5244,7 +5244,7 @@ PHP_FUNCTION(libvirt_domain_get_uuid) uuid=(char *)emalloc(VIR_UUID_BUFLEN); retval=virDomainGetUUID(domain->domain, (unsigned char *)uuid); DPRINTF("%s: virDomainGetUUID(%p, %p) returned %d\n", PHPFUNC, domain->domain, uuid, retval); - if (retval!=0) RETURN_FALSE; + if (retval != 0) RETURN_FALSE; VIRT_RETVAL_STRING(uuid); efree(uuid); @@ -5495,7 +5495,7 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) if (!fgets(cmd, sizeof(cmd), fp)) break; - if (strncmp(cmd, "Valid ", 6)== 0) { + if (strncmp(cmd, "Valid ", 6) == 0) { inFunc = 1; continue; } @@ -5996,7 +5996,7 @@ PHP_FUNCTION(libvirt_domain_change_memory) conn = domain->conn; dom=virDomainDefineXML(conn->conn, new_xml); - if (dom==NULL) { + if (dom == NULL) { free(xml); efree(new_xml); RETURN_FALSE; @@ -6080,7 +6080,7 @@ PHP_FUNCTION(libvirt_domain_change_boot_devices) conn = domain->conn; dom=virDomainDefineXML(conn->conn, new_xml); - if (dom==NULL) { + if (dom == NULL) { DPRINTF("%s: Function failed, restoring original XML\n", PHPFUNC); free(xml); efree(newXml); @@ -6729,7 +6729,7 @@ PHP_FUNCTION(libvirt_domain_define_xml) GET_CONNECTION_FROM_ARGS("rs", &zconn, &xml, &xml_len); domain=virDomainDefineXML(conn->conn, xml); - if (domain==NULL) RETURN_FALSE; + if (domain == NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -6766,7 +6766,7 @@ PHP_FUNCTION(libvirt_domain_create_xml) domain=virDomainCreateXML(conn->conn, xml, flags); DPRINTF("%s: virDomainCreateXML(%p, <xml>, 0) returned %p\n", PHPFUNC, conn->conn, domain); - if (domain==NULL) RETURN_FALSE; + if (domain == NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -7531,7 +7531,7 @@ PHP_FUNCTION(libvirt_domain_migrate) } VIRT_FETCH_RESOURCE(dconn, php_libvirt_connection*, &zdconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection); - if ((dconn==NULL) || (dconn->conn==NULL)) { + if ((dconn == NULL) || (dconn->conn == NULL)) { set_error("Destination connection object is not valid" TSRMLS_CC); RETURN_FALSE; } @@ -7633,7 +7633,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name) if ( (name == NULL) || (name_len<1)) RETURN_FALSE; snapshot=virDomainSnapshotLookupByName(domain->domain, name, flags); - if (snapshot==NULL) RETURN_FALSE; + if (snapshot == NULL) RETURN_FALSE; res_snapshot = (php_libvirt_snapshot *)emalloc(sizeof(php_libvirt_snapshot)); res_snapshot->domain = domain; @@ -7701,7 +7701,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml) GET_SNAPSHOT_FROM_ARGS("r|l", &zsnapshot, &flags); xml = virDomainSnapshotGetXMLDesc(snapshot->snapshot, flags); - if (xml==NULL) RETURN_FALSE; + if (xml == NULL) RETURN_FALSE; VIRT_RETVAL_STRING(xml); free(xml); @@ -7818,7 +7818,7 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_name) if ( (name == NULL) || (name_len<1)) RETURN_FALSE; pool=virStoragePoolLookupByName(conn->conn, name); DPRINTF("%s: virStoragePoolLookupByName(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, pool); - if (pool==NULL) RETURN_FALSE; + if (pool == NULL) RETURN_FALSE; res_pool = (php_libvirt_storagepool *)emalloc(sizeof(php_libvirt_storagepool)); res_pool->pool = pool; @@ -7959,7 +7959,7 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name) volume=virStorageVolLookupByName (pool->pool, name); DPRINTF("%s: virStorageVolLookupByName(%p, %s) returned %p\n", PHPFUNC, pool->pool, name, volume); - if (volume==NULL) RETURN_FALSE; + if (volume == NULL) RETURN_FALSE; res_volume = (php_libvirt_volume *)emalloc(sizeof(php_libvirt_volume)); res_volume->volume = volume; @@ -7996,7 +7996,7 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_path) volume=virStorageVolLookupByPath (conn->conn, name); DPRINTF("%s: virStorageVolLookupByPath(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, volume); - if (volume==NULL) + if (volume == NULL) { set_error_if_unset("Cannot find storage volume on requested path" TSRMLS_CC); RETURN_FALSE; @@ -8114,7 +8114,7 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc) DPRINTF("%s: volume = %p, xpath = %s, flags = %ld\n", PHPFUNC, volume->volume, xpath, flags); xml=virStorageVolGetXMLDesc(volume->volume, flags); - if (xml==NULL) { + if (xml == NULL) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); RETURN_FALSE; } @@ -8153,7 +8153,7 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml) volume=virStorageVolCreateXML(pool->pool, xml, flags); DPRINTF("%s: virStorageVolCreateXML(%p, <xml>, 0) returned %p\n", PHPFUNC, pool->pool, volume); - if (volume==NULL) RETURN_FALSE; + if (volume == NULL) RETURN_FALSE; res_volume= (php_libvirt_volume *)emalloc(sizeof(php_libvirt_volume)); res_volume->volume = volume; @@ -8197,14 +8197,14 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) } VIRT_FETCH_RESOURCE (pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool); - if ((pool==NULL)||(pool->pool==NULL))RETURN_FALSE; + if ((pool == NULL)||(pool->pool == NULL))RETURN_FALSE; VIRT_FETCH_RESOURCE (pl_volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); - if ((pl_volume==NULL)||(pl_volume->volume==NULL))RETURN_FALSE; + if ((pl_volume == NULL)||(pl_volume->volume == NULL))RETURN_FALSE; resource_change_counter(INT_RESOURCE_VOLUME, NULL, pl_volume->volume, 1 TSRMLS_CC); volume=virStorageVolCreateXMLFrom(pool->pool, xml, pl_volume->volume, 0); DPRINTF("%s: virStorageVolCreateXMLFrom(%p, <xml>, %p, 0) returned %p\n", PHPFUNC, pool->pool, pl_volume->volume, volume); - if (volume==NULL) RETURN_FALSE; + if (volume == NULL) RETURN_FALSE; res_volume = (php_libvirt_volume *)emalloc(sizeof(php_libvirt_volume)); res_volume->volume = volume; @@ -8301,9 +8301,9 @@ PHP_FUNCTION(libvirt_storagevolume_download) RETURN_LONG(retval); } VIRT_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); - if ((volume==NULL)||(volume->volume==NULL))RETURN_LONG(retval); + if ((volume == NULL)||(volume->volume == NULL))RETURN_LONG(retval); VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); retval = virStorageVolDownload(volume->volume, stream->stream, offset, length, flags); DPRINTF("%s: virStorageVolDownload(%p, %p, %d, %d, %d) returned %d\n", PHPFUNC, volume->volume, stream->stream, (int) offset, (int) length, (int) flags, retval); @@ -8342,9 +8342,9 @@ PHP_FUNCTION(libvirt_storagevolume_upload) RETURN_LONG(retval); } VIRT_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); - if ((volume==NULL)||(volume->volume==NULL))RETURN_LONG(retval); + if ((volume == NULL)||(volume->volume == NULL))RETURN_LONG(retval); VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream==NULL)||(stream->stream==NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); retval = virStorageVolUpload(volume->volume, stream->stream, offset, length, flags); DPRINTF("%s: virStorageVolUpload(%p, %p, %d, %d, %d) returned %d\n", PHPFUNC, volume->volume, stream->stream, (int) offset, (int) length, (int) flags, retval); @@ -8917,7 +8917,7 @@ PHP_FUNCTION(libvirt_list_domains) { domain=virDomainLookupByID(conn->conn, ids[i]); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, domain, 1 TSRMLS_CC); - if (domain!=NULL) + if (domain != NULL) { name=virDomainGetName(domain); if (name != NULL) { @@ -9004,7 +9004,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) for (i=0;i<count;i++) { domain=virDomainLookupByID(conn->conn, ids[i]); - if (domain!=NULL) + if (domain != NULL) { res_domain= (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -9037,7 +9037,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) for (i=0;i<count;i++) { domain=virDomainLookupByName (conn->conn, names[i]); - if (domain!=NULL) + if (domain != NULL) { res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -9130,7 +9130,7 @@ PHP_FUNCTION(libvirt_list_active_domains) for (i=0;i<count;i++) { domain=virDomainLookupByID(conn->conn, ids[i]); - if (domain!=NULL) + if (domain != NULL) { if (!(name = virDomainGetName(domain))) { efree(ids); @@ -9874,7 +9874,7 @@ PHP_FUNCTION(libvirt_network_get_xml_desc) xml=virNetworkGetXMLDesc(network->network, 0); - if (xml==NULL) { + if (xml == NULL) { set_error_if_unset("Cannot get network XML" TSRMLS_CC); RETURN_FALSE; } -- 2.7.3

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 298 +++++++++++++++++++++++++++--------------------------- 1 file changed, 149 insertions(+), 149 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index a325b1f..b95774b 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -834,8 +834,8 @@ PHP_RINIT_FUNCTION(libvirt) /* PHP request destruction */ PHP_RSHUTDOWN_FUNCTION(libvirt) { - if (LIBVIRT_G (last_error) != NULL) efree(LIBVIRT_G (last_error)); - if (LIBVIRT_G (vnc_location) != NULL) efree(LIBVIRT_G (vnc_location)); + if (LIBVIRT_G(last_error) != NULL) efree(LIBVIRT_G(last_error)); + if (LIBVIRT_G(vnc_location) != NULL) efree(LIBVIRT_G(vnc_location)); return SUCCESS; } @@ -1169,16 +1169,16 @@ PHP_MINFO_FUNCTION(libvirt) */ void set_error(char *msg TSRMLS_DC) { - if (LIBVIRT_G (last_error) != NULL) - efree(LIBVIRT_G (last_error)); + if (LIBVIRT_G(last_error) != NULL) + efree(LIBVIRT_G(last_error)); if (msg == NULL) { - LIBVIRT_G (last_error) = NULL; + LIBVIRT_G(last_error) = NULL; return; } php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", msg); - LIBVIRT_G (last_error)=estrndup(msg, strlen(msg)); + LIBVIRT_G(last_error)=estrndup(msg, strlen(msg)); } /* @@ -1190,17 +1190,17 @@ void set_error(char *msg TSRMLS_DC) */ void set_vnc_location(char *msg TSRMLS_DC) { - if (LIBVIRT_G (vnc_location) != NULL) - efree(LIBVIRT_G (vnc_location)); + if (LIBVIRT_G(vnc_location) != NULL) + efree(LIBVIRT_G(vnc_location)); if (msg == NULL) { - LIBVIRT_G (vnc_location) = NULL; + LIBVIRT_G(vnc_location) = NULL; return; } - LIBVIRT_G (vnc_location)=estrndup(msg, strlen(msg)); + LIBVIRT_G(vnc_location)=estrndup(msg, strlen(msg)); - DPRINTF("set_vnc_location: VNC server location set to '%s'\n", LIBVIRT_G (vnc_location)); + DPRINTF("set_vnc_location: VNC server location set to '%s'\n", LIBVIRT_G(vnc_location)); } /* @@ -1212,7 +1212,7 @@ void set_vnc_location(char *msg TSRMLS_DC) */ void set_error_if_unset(char *msg TSRMLS_DC) { - if (LIBVIRT_G (last_error) == NULL) + if (LIBVIRT_G(last_error) == NULL) set_error(msg TSRMLS_CC); } @@ -1254,8 +1254,8 @@ void free_resource(int type, void *mem TSRMLS_DC) if (type == INT_RESOURCE_DOMAIN) { rv = virDomainFree( (virDomainPtr)mem ); if (rv != 0) { - DPRINTF("%s: virDomainFree(%p) returned %d (%s)\n", __FUNCTION__, (virDomainPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virDomainFree(%p) returned %d (%s)\n", __FUNCTION__, (virDomainPtr)mem, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virDomainFree(%p) completed successfully\n", __FUNCTION__, (virDomainPtr)mem); @@ -1266,8 +1266,8 @@ void free_resource(int type, void *mem TSRMLS_DC) if (type == INT_RESOURCE_STREAM) { rv = virStreamFree( (virStreamPtr)mem ); if (rv != 0) { - DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, (virStreamPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, (virStreamPtr)mem, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virStreamFree(%p) completed successfully\n", __FUNCTION__, (virStreamPtr)mem); @@ -1278,8 +1278,8 @@ void free_resource(int type, void *mem TSRMLS_DC) if (type == INT_RESOURCE_NETWORK) { rv = virNetworkFree( (virNetworkPtr)mem ); if (rv != 0) { - DPRINTF("%s: virNetworkFree(%p) returned %d (%s)\n", __FUNCTION__, (virNetworkPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNetworkFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virNetworkFree(%p) returned %d (%s)\n", __FUNCTION__, (virNetworkPtr)mem, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNetworkFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virNetworkFree(%p) completed successfully\n", __FUNCTION__, (virNetworkPtr)mem); @@ -1290,8 +1290,8 @@ void free_resource(int type, void *mem TSRMLS_DC) if (type == INT_RESOURCE_NODEDEV) { rv = virNodeDeviceFree( (virNodeDevicePtr)mem ); if (rv != 0) { - DPRINTF("%s: virNodeDeviceFree(%p) returned %d (%s)\n", __FUNCTION__, (virNodeDevicePtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNodeDeviceFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virNodeDeviceFree(%p) returned %d (%s)\n", __FUNCTION__, (virNodeDevicePtr)mem, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNodeDeviceFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virNodeDeviceFree(%p) completed successfully\n", __FUNCTION__, (virNodeDevicePtr)mem); @@ -1302,8 +1302,8 @@ void free_resource(int type, void *mem TSRMLS_DC) if (type == INT_RESOURCE_STORAGEPOOL) { rv = virStoragePoolFree( (virStoragePoolPtr)mem ); if (rv != 0) { - DPRINTF("%s: virStoragePoolFree(%p) returned %d (%s)\n", __FUNCTION__, (virStoragePoolPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virStoragePoolFree(%p) returned %d (%s)\n", __FUNCTION__, (virStoragePoolPtr)mem, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virStoragePoolFree(%p) completed successfully\n", __FUNCTION__, (virStoragePoolPtr)mem); @@ -1314,8 +1314,8 @@ void free_resource(int type, void *mem TSRMLS_DC) if (type == INT_RESOURCE_VOLUME) { rv = virStorageVolFree( (virStorageVolPtr)mem ); if (rv != 0) { - DPRINTF("%s: virStorageVolFree(%p) returned %d (%s)\n", __FUNCTION__, (virStorageVolPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virStorageVolFree(%p) returned %d (%s)\n", __FUNCTION__, (virStorageVolPtr)mem, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virStorageVolFree(%p) completed successfully\n", __FUNCTION__, (virStorageVolPtr)mem); @@ -1326,8 +1326,8 @@ void free_resource(int type, void *mem TSRMLS_DC) if (type == INT_RESOURCE_SNAPSHOT) { rv = virDomainSnapshotFree( (virDomainSnapshotPtr)mem ); if (rv != 0) { - DPRINTF("%s: virDomainSnapshotFree(%p) returned %d (%s)\n", __FUNCTION__, (virDomainSnapshotPtr)mem, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainSnapshotFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virDomainSnapshotFree(%p) returned %d (%s)\n", __FUNCTION__, (virDomainSnapshotPtr)mem, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainSnapshotFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virDomainSnapshotFree(%p) completed successfully\n", __FUNCTION__, (virDomainSnapshotPtr)mem); @@ -1495,8 +1495,8 @@ static void php_libvirt_connection_dtor( rv = virConnectClose(conn->conn); if (rv == -1) { - DPRINTF("%s: virConnectClose(%p) returned %d (%s)\n", __FUNCTION__, conn->conn, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virConnectClose failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virConnectClose(%p) returned %d (%s)\n", __FUNCTION__, conn->conn, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virConnectClose failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virConnectClose(%p) completed successfully\n", __FUNCTION__, conn->conn); @@ -1504,7 +1504,7 @@ static void php_libvirt_connection_dtor( } conn->conn=NULL; } - efree (conn); + efree(conn); } } @@ -1526,14 +1526,14 @@ static void php_libvirt_domain_dtor( { if (!check_resource_allocation(domain->conn->conn, INT_RESOURCE_DOMAIN, domain->domain TSRMLS_CC)) { domain->domain=NULL; - efree (domain); + efree(domain); return; } rv = virDomainFree(domain->domain); if (rv != 0) { - DPRINTF("%s: virDomainFree(%p) returned %d (%s)\n", __FUNCTION__, domain->domain, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virDomainFree(%p) returned %d (%s)\n", __FUNCTION__, domain->domain, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virDomainFree(%p) completed successfully\n", __FUNCTION__, domain->domain); @@ -1541,7 +1541,7 @@ static void php_libvirt_domain_dtor( } domain->domain=NULL; } - efree (domain); + efree(domain); } } @@ -1563,13 +1563,13 @@ static void php_libvirt_stream_dtor( { if (!check_resource_allocation(NULL, INT_RESOURCE_STREAM, stream->stream TSRMLS_CC)) { stream->stream=NULL; - efree (stream); + efree(stream); return; } rv = virStreamFree(stream->stream); if (rv != 0) { - DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, stream->stream, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, stream->stream, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virStreamFree(%p) completed successfully\n", __FUNCTION__, stream->stream); @@ -1577,7 +1577,7 @@ static void php_libvirt_stream_dtor( } stream->stream=NULL; } - efree (stream); + efree(stream); } } @@ -1604,8 +1604,8 @@ static void php_libvirt_storagepool_dtor( } rv = virStoragePoolFree(pool->pool); if (rv != 0) { - DPRINTF("%s: virStoragePoolFree(%p) returned %d (%s)\n", __FUNCTION__, pool->pool, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virStoragePoolFree(%p) returned %d (%s)\n", __FUNCTION__, pool->pool, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virStoragePoolFree(%p) completed successfully\n", __FUNCTION__, pool->pool); @@ -1638,10 +1638,10 @@ static void php_libvirt_volume_dtor( efree(volume); return; } - rv = virStorageVolFree (volume->volume); + rv = virStorageVolFree(volume->volume); if (rv != 0) { - DPRINTF("%s: virStorageVolFree(%p) returned %d (%s)\n", __FUNCTION__, volume->volume, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virStorageVolFree(%p) returned %d (%s)\n", __FUNCTION__, volume->volume, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virStorageVolFree(%p) completed successfully\n", __FUNCTION__, volume->volume); @@ -1676,8 +1676,8 @@ static void php_libvirt_network_dtor( } rv = virNetworkFree(network->network); if (rv != 0) { - DPRINTF("%s: virNetworkFree(%p) returned %d (%s)\n", __FUNCTION__, network->network, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virNetworkFree(%p) returned %d (%s)\n", __FUNCTION__, network->network, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virNetworkFree(%p) completed successfully\n", __FUNCTION__, network->network); @@ -1712,8 +1712,8 @@ static void php_libvirt_nodedev_dtor( } rv = virNodeDeviceFree(nodedev->device); if (rv != 0) { - DPRINTF("%s: virNodeDeviceFree(%p) returned %d (%s)\n", __FUNCTION__, nodedev->device, rv, LIBVIRT_G (last_error)); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + DPRINTF("%s: virNodeDeviceFree(%p) returned %d (%s)\n", __FUNCTION__, nodedev->device, rv, LIBVIRT_G(last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virNodeDeviceFree(%p) completed successfully\n", __FUNCTION__, nodedev->device); @@ -1749,7 +1749,7 @@ static void php_libvirt_snapshot_dtor( rv = virDomainSnapshotFree(snapshot->snapshot); if (rv != 0) { DPRINTF("%s: virDomainSnapshotFree(%p) returned %d\n", __FUNCTION__, snapshot->snapshot, rv); - php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G (last_error)); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); } else { DPRINTF("%s: virDomainSnapshotFree(%p) completed successfully\n", __FUNCTION__, snapshot->snapshot); @@ -2320,7 +2320,7 @@ PHP_FUNCTION(libvirt_connect) DPRINTF("%s: Found %d elements for credentials\n", PHPFUNC, j); creds[0].count=j; libvirt_virConnectAuth.cbdata = (void*)creds; - conn->conn = virConnectOpenAuth (url, &libvirt_virConnectAuth, readonly ? VIR_CONNECT_RO : 0); + conn->conn = virConnectOpenAuth(url, &libvirt_virConnectAuth, readonly ? VIR_CONNECT_RO : 0); for (i=0;i < creds[0].count;i++) efree(creds[i].result); efree(creds); @@ -2329,7 +2329,7 @@ PHP_FUNCTION(libvirt_connect) if (conn->conn == NULL) { DPRINTF("%s: Cannot establish connection to %s\n", PHPFUNC, url); - efree (conn); + efree(conn); RETURN_FALSE; } @@ -4051,8 +4051,8 @@ PHP_FUNCTION(libvirt_domain_get_counts) GET_CONNECTION_FROM_ARGS("r", &zconn); - count_defined = virConnectNumOfDefinedDomains (conn->conn); - count_active = virConnectNumOfDomains (conn->conn); + count_defined = virConnectNumOfDefinedDomains(conn->conn); + count_active = virConnectNumOfDomains(conn->conn); array_init(return_value); add_assoc_long(return_value, "total", (long)(count_defined + count_active)); @@ -4073,7 +4073,7 @@ PHP_FUNCTION(libvirt_domain_is_persistent) zval *zdomain; int p; - GET_DOMAIN_FROM_ARGS ("r", &zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); if ((p = virDomainIsPersistent(domain->domain)) < 0) { RETURN_LONG(-1); @@ -4099,7 +4099,7 @@ PHP_FUNCTION(libvirt_domain_set_max_memory) zval *zdomain; zend_long memory = 0; - GET_DOMAIN_FROM_ARGS ("rl", &zdomain, &memory); + GET_DOMAIN_FROM_ARGS("rl", &zdomain, &memory); if (virDomainSetMaxMemory(domain->domain, memory) != 0) RETURN_FALSE; @@ -4121,7 +4121,7 @@ PHP_FUNCTION(libvirt_domain_set_memory) zval *zdomain; zend_long memory = 0; - GET_DOMAIN_FROM_ARGS ("rl", &zdomain, &memory); + GET_DOMAIN_FROM_ARGS("rl", &zdomain, &memory); if (virDomainSetMemory(domain->domain, memory) != 0) RETURN_FALSE; @@ -4145,7 +4145,7 @@ PHP_FUNCTION(libvirt_domain_set_memory_flags) zend_long memory = 0; zend_long flags = 0; - GET_DOMAIN_FROM_ARGS ("rl|l", &zdomain, &memory, &flags); + GET_DOMAIN_FROM_ARGS("rl|l", &zdomain, &memory, &flags); if (virDomainSetMemoryFlags(domain->domain, memory, flags) != 0) RETURN_FALSE; @@ -4166,13 +4166,13 @@ PHP_FUNCTION(libvirt_domain_get_autostart) zval *zdomain; int flags = 0; - GET_DOMAIN_FROM_ARGS ("r", &zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); if (virDomainGetAutostart (domain->domain, &flags) != 0) { - RETURN_LONG (-1); + RETURN_LONG(-1); } - RETURN_LONG ((long)flags); + RETURN_LONG((long)flags); } /* @@ -4189,7 +4189,7 @@ PHP_FUNCTION(libvirt_domain_set_autostart) zval *zdomain; zend_bool flags = 0; - GET_DOMAIN_FROM_ARGS ("rb", &zdomain, &flags); + GET_DOMAIN_FROM_ARGS("rb", &zdomain, &flags); if (virDomainSetAutostart (domain->domain, flags) != 0) { @@ -4218,7 +4218,7 @@ PHP_FUNCTION(libvirt_domain_get_metadata) strsize_t uri_len; char *ret = NULL; - GET_DOMAIN_FROM_ARGS ("rlsl", &zdomain, &type, &uri, &uri_len, &flags); + GET_DOMAIN_FROM_ARGS("rlsl", &zdomain, &type, &uri, &uri_len, &flags); if ((uri != NULL) && (strlen(uri) == 0)) uri = NULL; @@ -4262,7 +4262,7 @@ PHP_FUNCTION(libvirt_domain_set_metadata) zend_long flags = 0; int rc; - GET_DOMAIN_FROM_ARGS ("rlsssl", &zdomain, &type, &metadata, &metadata_len, &key, &key_len, &uri, &uri_len, &flags); + GET_DOMAIN_FROM_ARGS("rlsssl", &zdomain, &type, &metadata, &metadata_len, &key, &key_len, &uri, &uri_len, &flags); if ((key != NULL) && (strlen(key) == 0)) key = NULL; @@ -4285,9 +4285,9 @@ PHP_FUNCTION(libvirt_domain_is_active) php_libvirt_domain *domain = NULL; zval *zdomain; - GET_DOMAIN_FROM_ARGS ("r", &zdomain); + GET_DOMAIN_FROM_ARGS("r", &zdomain); - RETURN_LONG (virDomainIsActive(domain->domain)); + RETURN_LONG(virDomainIsActive(domain->domain)); } /* @@ -4443,7 +4443,7 @@ PHP_FUNCTION(libvirt_stream_create) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zconn) == FAILURE) { RETURN_FALSE; } - VIRT_FETCH_RESOURCE (conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection); + VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection); if ((conn == NULL)||(conn->conn == NULL))RETURN_FALSE; stream = virStreamNew(conn->conn, 0); @@ -4480,7 +4480,7 @@ PHP_FUNCTION(libvirt_stream_close) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) { RETURN_LONG(retval); } - VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); retval = virStreamFree(stream->stream); @@ -4509,7 +4509,7 @@ PHP_FUNCTION(libvirt_stream_abort) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) { RETURN_LONG(retval); } - VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); retval = virStreamAbort(stream->stream); @@ -4536,7 +4536,7 @@ PHP_FUNCTION(libvirt_stream_finish) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) { RETURN_LONG(retval); } - VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); retval = virStreamFinish(stream->stream); @@ -4567,7 +4567,7 @@ PHP_FUNCTION(libvirt_stream_recv) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) { RETURN_LONG(retval); } - VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); recv_buf = emalloc(length + 1); @@ -4617,7 +4617,7 @@ PHP_FUNCTION(libvirt_stream_send) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) { RETURN_LONG(retval); } - VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); cstr = Z_STRVAL_P(zbuf); @@ -7849,9 +7849,9 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_volume) virStoragePoolPtr pool=NULL; php_libvirt_storagepool *res_pool; - GET_VOLUME_FROM_ARGS ("r", &zvolume); + GET_VOLUME_FROM_ARGS("r", &zvolume); - pool = virStoragePoolLookupByVolume (volume->volume); + pool = virStoragePoolLookupByVolume(volume->volume); DPRINTF("%s: virStoragePoolLookupByVolume(%p) returned %p\n", PHPFUNC, volume->volume, pool); if (pool == NULL) RETURN_FALSE; @@ -7887,7 +7887,7 @@ PHP_FUNCTION(libvirt_storagepool_list_volumes) GET_STORAGEPOOL_FROM_ARGS("r", &zpool); - if ((expectedcount=virStoragePoolNumOfVolumes (pool->pool)) < 0) + if ((expectedcount=virStoragePoolNumOfVolumes(pool->pool)) < 0) RETURN_FALSE; DPRINTF("%s: virStoragePoolNumOfVolumes(%p) returned %d\n", PHPFUNC, pool->pool, expectedcount); @@ -7957,7 +7957,7 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name) GET_STORAGEPOOL_FROM_ARGS("rs", &zpool, &name, &name_len); if ( (name == NULL) || (name_len<1)) RETURN_FALSE; - volume=virStorageVolLookupByName (pool->pool, name); + volume=virStorageVolLookupByName(pool->pool, name); DPRINTF("%s: virStorageVolLookupByName(%p, %s) returned %p\n", PHPFUNC, pool->pool, name, volume); if (volume == NULL) RETURN_FALSE; @@ -7994,7 +7994,7 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_path) GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); if ( (name == NULL) || (name_len<1)) RETURN_FALSE; - volume=virStorageVolLookupByPath (conn->conn, name); + volume=virStorageVolLookupByPath(conn->conn, name); DPRINTF("%s: virStorageVolLookupByPath(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, volume); if (volume == NULL) { @@ -8028,9 +8028,9 @@ PHP_FUNCTION(libvirt_storagevolume_get_name) zval *zvolume; const char *retval; - GET_VOLUME_FROM_ARGS ("r", &zvolume); + GET_VOLUME_FROM_ARGS("r", &zvolume); - retval = virStorageVolGetName (volume->volume); + retval = virStorageVolGetName(volume->volume); DPRINTF("%s: virStorageVolGetName(%p) returned %s\n", PHPFUNC, volume->volume, retval); if (retval == NULL) RETURN_FALSE; @@ -8050,7 +8050,7 @@ PHP_FUNCTION(libvirt_storagevolume_get_path) zval *zvolume; char *retval; - GET_VOLUME_FROM_ARGS ("r", &zvolume); + GET_VOLUME_FROM_ARGS("r", &zvolume); retval = virStorageVolGetPath(volume->volume); DPRINTF("%s: virStorageVolGetPath(%p) returned %s\n", PHPFUNC, volume->volume, retval); @@ -8190,15 +8190,15 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) char *xml; strsize_t xml_len; - if (zend_parse_parameters (ZEND_NUM_ARGS() TSRMLS_CC, "rsr", &zpool, &xml, &xml_len, &zvolume) == FAILURE) + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsr", &zpool, &xml, &xml_len, &zvolume) == FAILURE) { set_error("Invalid pool resource, XML or volume resouce" TSRMLS_CC); RETURN_FALSE; } - VIRT_FETCH_RESOURCE (pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool); + VIRT_FETCH_RESOURCE(pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool); if ((pool == NULL)||(pool->pool == NULL))RETURN_FALSE; - VIRT_FETCH_RESOURCE (pl_volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); + VIRT_FETCH_RESOURCE(pl_volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); if ((pl_volume == NULL)||(pl_volume->volume == NULL))RETURN_FALSE; resource_change_counter(INT_RESOURCE_VOLUME, NULL, pl_volume->volume, 1 TSRMLS_CC); @@ -8300,9 +8300,9 @@ PHP_FUNCTION(libvirt_storagevolume_download) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) { RETURN_LONG(retval); } - VIRT_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); + VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); if ((volume == NULL)||(volume->volume == NULL))RETURN_LONG(retval); - VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); retval = virStorageVolDownload(volume->volume, stream->stream, offset, length, flags); @@ -8341,9 +8341,9 @@ PHP_FUNCTION(libvirt_storagevolume_upload) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) { RETURN_LONG(retval); } - VIRT_FETCH_RESOURCE (volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); + VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); if ((volume == NULL)||(volume->volume == NULL))RETURN_LONG(retval); - VIRT_FETCH_RESOURCE (stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); + VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); retval = virStorageVolUpload(volume->volume, stream->stream, offset, length, flags); @@ -8371,10 +8371,10 @@ PHP_FUNCTION(libvirt_storagepool_get_uuid_string) char *uuid; int retval; - GET_STORAGEPOOL_FROM_ARGS ("r", &zpool); + GET_STORAGEPOOL_FROM_ARGS("r", &zpool); - uuid = (char *)emalloc (VIR_UUID_STRING_BUFLEN); - retval = virStoragePoolGetUUIDString (pool->pool, uuid); + uuid = (char *)emalloc(VIR_UUID_STRING_BUFLEN); + retval = virStoragePoolGetUUIDString(pool->pool, uuid); DPRINTF("%s: virStoragePoolGetUUIDString(%p, %p) returned %d (%s)\n", PHPFUNC, pool->pool, uuid, retval, uuid); if (retval != 0) RETURN_FALSE; @@ -8398,7 +8398,7 @@ PHP_FUNCTION(libvirt_storagepool_get_name) GET_STORAGEPOOL_FROM_ARGS("r", &zpool); - name = virStoragePoolGetName (pool->pool); + name = virStoragePoolGetName(pool->pool); DPRINTF("%s: virStoragePoolGetName(%p) returned %s\n", PHPFUNC, pool->pool, name); if (name == NULL) RETURN_FALSE; @@ -8428,12 +8428,12 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_uuid_string) if ((uuid == NULL) || (uuid_len < 1)) RETURN_FALSE; - storage = virStoragePoolLookupByUUIDString (conn->conn, uuid); + storage = virStoragePoolLookupByUUIDString(conn->conn, uuid); DPRINTF("%s: virStoragePoolLookupByUUIDString(%p, %s) returned %p\n", PHPFUNC, conn->conn, uuid, storage); if (storage == NULL) RETURN_FALSE; - res_pool = (php_libvirt_storagepool *)emalloc (sizeof (php_libvirt_storagepool)); + res_pool = (php_libvirt_storagepool *)emalloc(sizeof(php_libvirt_storagepool)); res_pool->pool = storage; res_pool->conn = conn; @@ -8442,7 +8442,7 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_uuid_string) #if PHP_MAJOR_VERSION >= 7 ZVAL_RES(return_value, zend_register_resource(res_pool, le_libvirt_storagepool)); #else - ZEND_REGISTER_RESOURCE (return_value, res_pool, le_libvirt_storagepool); + ZEND_REGISTER_RESOURCE(return_value, res_pool, le_libvirt_storagepool); #endif } @@ -8471,7 +8471,7 @@ PHP_FUNCTION(libvirt_storagepool_get_xml_desc) DPRINTF("%s: pool = %p, flags = %ld, xpath = %s\n", PHPFUNC, pool->pool, flags, xpath); - xml = virStoragePoolGetXMLDesc (pool->pool, flags); + xml = virStoragePoolGetXMLDesc(pool->pool, flags); if (xml == NULL) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); @@ -8509,14 +8509,14 @@ PHP_FUNCTION(libvirt_storagepool_define_xml) zend_long flags = 0; - GET_CONNECTION_FROM_ARGS ("rs|l", &zconn, &xml, &xml_len, &flags); + GET_CONNECTION_FROM_ARGS("rs|l", &zconn, &xml, &xml_len, &flags); - pool = virStoragePoolDefineXML (conn->conn, xml, (unsigned int)flags); + pool = virStoragePoolDefineXML(conn->conn, xml, (unsigned int)flags); DPRINTF("%s: virStoragePoolDefineXML(%p, <xml>) returned %p\n", PHPFUNC, conn->conn, pool); if (pool == NULL) RETURN_FALSE; - res_pool = (php_libvirt_storagepool *)emalloc (sizeof (php_libvirt_storagepool)); + res_pool = (php_libvirt_storagepool *)emalloc(sizeof(php_libvirt_storagepool)); res_pool->pool = pool; res_pool->conn = conn; @@ -8525,7 +8525,7 @@ PHP_FUNCTION(libvirt_storagepool_define_xml) #if PHP_MAJOR_VERSION >= 7 ZVAL_RES(return_value, zend_register_resource(res_pool, le_libvirt_storagepool)); #else - ZEND_REGISTER_RESOURCE (return_value, res_pool, le_libvirt_storagepool); + ZEND_REGISTER_RESOURCE(return_value, res_pool, le_libvirt_storagepool); #endif } @@ -8542,7 +8542,7 @@ PHP_FUNCTION(libvirt_storagepool_undefine) zval *zpool; int retval = 0; - GET_STORAGEPOOL_FROM_ARGS ("r", &zpool); + GET_STORAGEPOOL_FROM_ARGS("r", &zpool); retval = virStoragePoolUndefine(pool->pool); DPRINTF("%s: virStoragePoolUndefine(%p) returned %d\n", PHPFUNC, pool->pool, retval); @@ -8565,7 +8565,7 @@ PHP_FUNCTION(libvirt_storagepool_create) zval *zpool; int retval; - GET_STORAGEPOOL_FROM_ARGS ("r", &zpool); + GET_STORAGEPOOL_FROM_ARGS("r", &zpool); retval = virStoragePoolCreate (pool->pool, 0); DPRINTF("%s: virStoragePoolCreate(%p, 0) returned %d\n", PHPFUNC, pool->pool, retval); @@ -8587,7 +8587,7 @@ PHP_FUNCTION(libvirt_storagepool_destroy) zval *zpool; int retval; - GET_STORAGEPOOL_FROM_ARGS ("r", &zpool); + GET_STORAGEPOOL_FROM_ARGS("r", &zpool); retval = virStoragePoolDestroy(pool->pool); DPRINTF("%s: virStoragePoolDestroy(%p) returned %d\n", PHPFUNC, pool->pool, retval); @@ -8608,9 +8608,9 @@ PHP_FUNCTION(libvirt_storagepool_is_active) php_libvirt_storagepool *pool = NULL; zval *zpool; - GET_STORAGEPOOL_FROM_ARGS ("r", &zpool); + GET_STORAGEPOOL_FROM_ARGS("r", &zpool); - RETURN_LONG (virStoragePoolIsActive (pool->pool)); + RETURN_LONG(virStoragePoolIsActive(pool->pool)); } /* @@ -8625,9 +8625,9 @@ PHP_FUNCTION(libvirt_storagepool_get_volume_count) php_libvirt_storagepool *pool = NULL; zval *zpool; - GET_STORAGEPOOL_FROM_ARGS ("r", &zpool); + GET_STORAGEPOOL_FROM_ARGS("r", &zpool); - RETURN_LONG (virStoragePoolNumOfVolumes(pool->pool)); + RETURN_LONG(virStoragePoolNumOfVolumes(pool->pool)); } /* @@ -8645,7 +8645,7 @@ PHP_FUNCTION(libvirt_storagepool_refresh) zend_long flags = 0; int retval; - GET_STORAGEPOOL_FROM_ARGS ("r|l", &zpool, &flags); + GET_STORAGEPOOL_FROM_ARGS("r|l", &zpool, &flags); retval = virStoragePoolRefresh(pool->pool, flags); DPRINTF("%s: virStoragePoolRefresh(%p, %ld) returned %d\n", PHPFUNC, pool->pool, flags, retval); @@ -8669,7 +8669,7 @@ PHP_FUNCTION(libvirt_storagepool_set_autostart) zend_bool flags = 0; int retval; - GET_STORAGEPOOL_FROM_ARGS ("rb", &zpool, &flags); + GET_STORAGEPOOL_FROM_ARGS("rb", &zpool, &flags); retval = virStoragePoolSetAutostart(pool->pool, flags); DPRINTF("%s: virStoragePoolSetAutostart(%p, %d) returned %d\n", PHPFUNC, pool->pool, flags, retval); @@ -8691,7 +8691,7 @@ PHP_FUNCTION(libvirt_storagepool_get_autostart) zval *zpool; int autostart; - GET_STORAGEPOOL_FROM_ARGS ("r", &zpool); + GET_STORAGEPOOL_FROM_ARGS("r", &zpool); if (virStoragePoolGetAutostart(pool->pool, &autostart) == 0 && autostart != 0) @@ -8714,7 +8714,7 @@ PHP_FUNCTION(libvirt_storagepool_build) int flags = 0; int retval; - GET_STORAGEPOOL_FROM_ARGS ("r", &zpool); + GET_STORAGEPOOL_FROM_ARGS("r", &zpool); retval = virStoragePoolBuild(pool->pool, flags); DPRINTF("%s: virStoragePoolBuild(%p, %d) returned %d\n", PHPFUNC, pool->pool, flags, retval); @@ -8738,7 +8738,7 @@ PHP_FUNCTION(libvirt_storagepool_delete) int flags = 0; int retval; - GET_STORAGEPOOL_FROM_ARGS ("r", &zpool); + GET_STORAGEPOOL_FROM_ARGS("r", &zpool); retval = virStoragePoolDelete(pool->pool, flags); DPRINTF("%s: virStoragePoolDelete(%p, %d) returned %d\n", PHPFUNC, pool->pool, flags, retval); @@ -8775,7 +8775,7 @@ PHP_FUNCTION(libvirt_list_storagepools) if ((count != expectedcount) || (count<0)) { - efree (names); + efree(names); RETURN_FALSE; } @@ -8788,22 +8788,22 @@ PHP_FUNCTION(libvirt_list_storagepools) efree(names); - if ((expectedcount = virConnectNumOfDefinedStoragePools (conn->conn)) < 0) + if ((expectedcount = virConnectNumOfDefinedStoragePools(conn->conn)) < 0) RETURN_FALSE; - names = (char **)emalloc (expectedcount * sizeof(char *)); - count = virConnectListDefinedStoragePools (conn->conn, names, expectedcount); + names = (char **)emalloc(expectedcount * sizeof(char *)); + count = virConnectListDefinedStoragePools(conn->conn, names, expectedcount); if ((count != expectedcount) || (count < 0)) { - efree (names); + efree(names); RETURN_FALSE; } for (i = 0; i < count; i++) { - VIRT_ADD_NEXT_INDEX_STRING (return_value, names[i]); - free (names[i]); + VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); + free(names[i]); } - efree (names); + efree(names); } /* @@ -8832,7 +8832,7 @@ PHP_FUNCTION(libvirt_list_active_storagepools) if ((count != expectedcount) || (count<0)) { - efree (names); + efree(names); RETURN_FALSE; } array_init(return_value); @@ -8862,24 +8862,24 @@ PHP_FUNCTION(libvirt_list_inactive_storagepools) GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount = virConnectNumOfDefinedStoragePools (conn->conn)) < 0) + if ((expectedcount = virConnectNumOfDefinedStoragePools(conn->conn)) < 0) RETURN_FALSE; - names= (char **)emalloc (expectedcount * sizeof(char *)); - count = virConnectListDefinedStoragePools (conn->conn, names, expectedcount); + names= (char **)emalloc(expectedcount * sizeof(char *)); + count = virConnectListDefinedStoragePools(conn->conn, names, expectedcount); if ((count != expectedcount) || (count < 0)) { - efree (names); + efree(names); RETURN_FALSE; } array_init(return_value); for (i = 0; i < count; i++) { - VIRT_ADD_NEXT_INDEX_STRING (return_value, names[i]); - free (names[i]); + VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); + free(names[i]); } - efree (names); + efree(names); } /* @@ -8903,13 +8903,13 @@ PHP_FUNCTION(libvirt_list_domains) GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfDomains (conn->conn)) < 0) + if ((expectedcount=virConnectNumOfDomains(conn->conn)) < 0) RETURN_FALSE; DPRINTF("%s: Found %d domains\n", PHPFUNC, expectedcount); ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains (conn->conn, ids, expectedcount); + count=virConnectListDomains(conn->conn, ids, expectedcount); DPRINTF("%s: virConnectListDomains returned %d domains\n", PHPFUNC, count); array_init(return_value); @@ -8927,10 +8927,10 @@ PHP_FUNCTION(libvirt_list_domains) else DPRINTF("%s: Cannot get ID for running domain %d\n", PHPFUNC, ids[i]); } - rv = virDomainFree (domain); + rv = virDomainFree(domain); if (rv != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on list_domain: %s", - rv, LIBVIRT_G (last_error)); + rv, LIBVIRT_G(last_error)); } else { resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, domain, 0 TSRMLS_CC); @@ -8939,7 +8939,7 @@ PHP_FUNCTION(libvirt_list_domains) } efree(ids); - expectedcount=virConnectNumOfDefinedDomains (conn->conn); + expectedcount=virConnectNumOfDefinedDomains(conn->conn); DPRINTF("%s: virConnectNumOfDefinedDomains returned %d domains\n", PHPFUNC, expectedcount); if (expectedcount < 0) { DPRINTF("%s: virConnectNumOfDefinedDomains failed with error code %d\n", PHPFUNC, expectedcount); @@ -8947,7 +8947,7 @@ PHP_FUNCTION(libvirt_list_domains) } names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedDomains (conn->conn, names, expectedcount); + count=virConnectListDefinedDomains(conn->conn, names, expectedcount); DPRINTF("%s: virConnectListDefinedDomains returned %d domains\n", PHPFUNC, count); if (count < 0) { DPRINTF("%s: virConnectListDefinedDomains failed with error code %d\n", PHPFUNC, count); @@ -8990,14 +8990,14 @@ PHP_FUNCTION(libvirt_list_domain_resources) GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfDomains (conn->conn)) < 0) + if ((expectedcount=virConnectNumOfDomains(conn->conn)) < 0) RETURN_FALSE; ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains (conn->conn, ids, expectedcount); + count=virConnectListDomains(conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { - efree (ids); + efree(ids); RETURN_FALSE; } array_init(return_value); @@ -9024,19 +9024,19 @@ PHP_FUNCTION(libvirt_list_domain_resources) } efree(ids); - if ((expectedcount=virConnectNumOfDefinedDomains (conn->conn)) < 0) + if ((expectedcount=virConnectNumOfDefinedDomains(conn->conn)) < 0) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedDomains (conn->conn, names, expectedcount); + count=virConnectListDefinedDomains(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { - efree (names); + efree(names); RETURN_FALSE; } for (i=0;i<count;i++) { - domain=virDomainLookupByName (conn->conn, names[i]); + domain=virDomainLookupByName(conn->conn, names[i]); if (domain != NULL) { res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -9077,14 +9077,14 @@ PHP_FUNCTION(libvirt_list_active_domain_ids) GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfDomains (conn->conn)) < 0) + if ((expectedcount=virConnectNumOfDomains(conn->conn)) < 0) RETURN_FALSE; ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains (conn->conn, ids, expectedcount); + count=virConnectListDomains(conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { - efree (ids); + efree(ids); RETURN_FALSE; } array_init(return_value); @@ -9115,14 +9115,14 @@ PHP_FUNCTION(libvirt_list_active_domains) GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfDomains (conn->conn)) < 0) + if ((expectedcount=virConnectNumOfDomains(conn->conn)) < 0) RETURN_FALSE; ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains (conn->conn, ids, expectedcount); + count=virConnectListDomains(conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { - efree (ids); + efree(ids); RETURN_FALSE; } @@ -9164,14 +9164,14 @@ PHP_FUNCTION(libvirt_list_inactive_domains) GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfDefinedDomains (conn->conn)) < 0) + if ((expectedcount=virConnectNumOfDefinedDomains(conn->conn)) < 0) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedDomains (conn->conn, names, expectedcount); + count=virConnectListDefinedDomains(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { - efree (names); + efree(names); RETURN_FALSE; } @@ -9213,7 +9213,7 @@ PHP_FUNCTION(libvirt_list_networks) count=virConnectListNetworks(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { - efree (names); + efree(names); RETURN_FALSE; } @@ -9234,7 +9234,7 @@ PHP_FUNCTION(libvirt_list_networks) count=virConnectListDefinedNetworks(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { - efree (names); + efree(names); RETURN_FALSE; } @@ -9279,7 +9279,7 @@ PHP_FUNCTION(libvirt_list_nodedevs) count=virNodeListDevices(conn->conn, cap, names, expectedcount, 0); if ((count != expectedcount) || (count<0)) { - efree (names); + efree(names); RETURN_FALSE; } -- 2.7.3

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 114 +++++++++++++++++++++++++++--------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index b95774b..235157e 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -858,7 +858,7 @@ char *get_datetime(void) if (tmp == NULL) return NULL; - outstr = (char *)malloc( 32 * sizeof(char) ); + outstr = (char *)malloc(32 * sizeof(char)); if (strftime(outstr, 32, "%Y-%m-%d %H:%M:%S", tmp) == 0) return NULL; @@ -948,13 +948,13 @@ tTokenizer tokenize(char *string, char *by) tTokenizer t; tmp = strdup(string); - t.tokens = (char **)malloc( sizeof(char *) ); + t.tokens = (char **)malloc(sizeof(char *)); for (str = tmp; ; str = NULL) { token = strtok_r(str, by, &save); if (token == NULL) break; - t.tokens = realloc( t.tokens, (i + 1) * sizeof(char *) ); + t.tokens = realloc(t.tokens, (i + 1) * sizeof(char *)); t.tokens[i++] = strdup(token); } @@ -1022,11 +1022,11 @@ int resource_change_counter(int type, virConnectPtr conn, void *mem, int inc TSR if (pos == -1) { if (binding_resources == NULL) { binding_resources_count = 1; - binding_resources = (resource_info *)malloc( sizeof(resource_info) ); + binding_resources = (resource_info *)malloc(sizeof(resource_info)); } else { binding_resources_count++; - binding_resources = (resource_info *)realloc( binding_resources, binding_resources_count * sizeof(resource_info) ); + binding_resources = (resource_info *)realloc(binding_resources, binding_resources_count * sizeof(resource_info)); } if (binding_resources == NULL) @@ -1252,7 +1252,7 @@ void free_resource(int type, void *mem TSRMLS_DC) DPRINTF("%s: Freeing libvirt %s resource at 0x%lx\n", __FUNCTION__, translate_counter_type(type), (long) mem); if (type == INT_RESOURCE_DOMAIN) { - rv = virDomainFree( (virDomainPtr)mem ); + rv = virDomainFree((virDomainPtr)mem); if (rv != 0) { DPRINTF("%s: virDomainFree(%p) returned %d (%s)\n", __FUNCTION__, (virDomainPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); @@ -1264,7 +1264,7 @@ void free_resource(int type, void *mem TSRMLS_DC) } if (type == INT_RESOURCE_STREAM) { - rv = virStreamFree( (virStreamPtr)mem ); + rv = virStreamFree((virStreamPtr)mem); if (rv != 0) { DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, (virStreamPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); @@ -1276,7 +1276,7 @@ void free_resource(int type, void *mem TSRMLS_DC) } if (type == INT_RESOURCE_NETWORK) { - rv = virNetworkFree( (virNetworkPtr)mem ); + rv = virNetworkFree((virNetworkPtr)mem); if (rv != 0) { DPRINTF("%s: virNetworkFree(%p) returned %d (%s)\n", __FUNCTION__, (virNetworkPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNetworkFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); @@ -1288,7 +1288,7 @@ void free_resource(int type, void *mem TSRMLS_DC) } if (type == INT_RESOURCE_NODEDEV) { - rv = virNodeDeviceFree( (virNodeDevicePtr)mem ); + rv = virNodeDeviceFree((virNodeDevicePtr)mem); if (rv != 0) { DPRINTF("%s: virNodeDeviceFree(%p) returned %d (%s)\n", __FUNCTION__, (virNodeDevicePtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNodeDeviceFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); @@ -1300,7 +1300,7 @@ void free_resource(int type, void *mem TSRMLS_DC) } if (type == INT_RESOURCE_STORAGEPOOL) { - rv = virStoragePoolFree( (virStoragePoolPtr)mem ); + rv = virStoragePoolFree((virStoragePoolPtr)mem); if (rv != 0) { DPRINTF("%s: virStoragePoolFree(%p) returned %d (%s)\n", __FUNCTION__, (virStoragePoolPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); @@ -1312,7 +1312,7 @@ void free_resource(int type, void *mem TSRMLS_DC) } if (type == INT_RESOURCE_VOLUME) { - rv = virStorageVolFree( (virStorageVolPtr)mem ); + rv = virStorageVolFree((virStorageVolPtr)mem); if (rv != 0) { DPRINTF("%s: virStorageVolFree(%p) returned %d (%s)\n", __FUNCTION__, (virStorageVolPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); @@ -1324,7 +1324,7 @@ void free_resource(int type, void *mem TSRMLS_DC) } if (type == INT_RESOURCE_SNAPSHOT) { - rv = virDomainSnapshotFree( (virDomainSnapshotPtr)mem ); + rv = virDomainSnapshotFree((virDomainSnapshotPtr)mem); if (rv != 0) { DPRINTF("%s: virDomainSnapshotFree(%p) returned %d (%s)\n", __FUNCTION__, (virDomainSnapshotPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainSnapshotFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); @@ -2296,7 +2296,7 @@ PHP_FUNCTION(libvirt_connect) array_count = zend_hash_num_elements(arr_hash); credscount=array_count; - creds=(php_libvirt_cred_value *)emalloc( credscount * sizeof(php_libvirt_cred_value) ); + creds=(php_libvirt_cred_value *)emalloc(credscount * sizeof(php_libvirt_cred_value)); j=0; /* parse the input Array and create list of credentials. The list (array) is passed to callback function. */ VIRT_FOREACH(arr_hash, pointer, data) { @@ -2309,7 +2309,7 @@ PHP_FUNCTION(libvirt_connect) } else { DPRINTF("%s: credentials index %d\n", PHPFUNC, (int)index); creds[j].type=index; - creds[j].result = (char *)emalloc( Z_STRLEN_P(data) + 1 ); + creds[j].result = (char *)emalloc(Z_STRLEN_P(data) + 1); memset(creds[j].result, 0, Z_STRLEN_P(data) + 1); creds[j].resultlen = Z_STRLEN_P(data); strncpy(creds[j].result, Z_STRVAL_P(data), Z_STRLEN_P(data)); @@ -2529,7 +2529,7 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu) iter = 0; done = 0; - while ( !done ) { + while (!done) { #if PHP_MAJOR_VERSION >= 7 zval *arr, zarr; arr = &zarr; @@ -2975,7 +2975,7 @@ PHP_FUNCTION(libvirt_image_create) int cmdRet; if (LIBVIRT_G(image_path_ini)) - path = strdup( LIBVIRT_G(image_path_ini) ); + path = strdup(LIBVIRT_G(image_path_ini)); if ((path == NULL) || (path[0] != '/')) { set_error("Invalid argument, path must be set and absolute (start by slash character [/])" TSRMLS_CC); @@ -3120,7 +3120,7 @@ PHP_FUNCTION(libvirt_connect_get_encrypted) GET_CONNECTION_FROM_ARGS("r", &zconn); - RETURN_LONG( virConnectIsEncrypted(conn->conn) ); + RETURN_LONG(virConnectIsEncrypted(conn->conn)); } @@ -3138,7 +3138,7 @@ PHP_FUNCTION(libvirt_connect_get_secure) GET_CONNECTION_FROM_ARGS("r", &zconn); - RETURN_LONG( virConnectIsSecure(conn->conn) ); + RETURN_LONG(virConnectIsSecure(conn->conn)); } @@ -3288,7 +3288,7 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int *retVal) if (!xpath || !xml) return NULL; - xp = xmlCreateDocParserCtxt( (xmlChar *)xml ); + xp = xmlCreateDocParserCtxt((xmlChar *)xml); if (!xp) { ret = -1; goto cleanup; @@ -3306,7 +3306,7 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int *retVal) goto cleanup; } - result = xmlXPathEvalExpression( (xmlChar *)xpath, context); + result = xmlXPathEvalExpression((xmlChar *)xpath, context); if (!result) { ret = -4; goto cleanup; @@ -3371,7 +3371,7 @@ char **get_array_from_xpath(char *xml, char *xpath, int *num) if ((xpath == NULL) || (xml == NULL)) return NULL; - xp = xmlCreateDocParserCtxt( (xmlChar *)xml ); + xp = xmlCreateDocParserCtxt((xmlChar *)xml); if (!xp) return NULL; @@ -3387,7 +3387,7 @@ char **get_array_from_xpath(char *xml, char *xpath, int *num) return NULL; } - result = xmlXPathEvalExpression( (xmlChar *)xpath, context); + result = xmlXPathEvalExpression((xmlChar *)xpath, context); if (!result) { xmlXPathFreeContext(context); xmlCleanupParser(); @@ -3415,7 +3415,7 @@ char **get_array_from_xpath(char *xml, char *xpath, int *num) } ret = 0; - val = (char **)malloc( nodeset->nodeNr * sizeof(char *) ); + val = (char **)malloc(nodeset->nodeNr * sizeof(char *)); for (i = 0; i < nodeset->nodeNr; i++) { if ((value = xmlNodeListGetString(doc, nodeset->nodeTab[i]->xmlChildrenNode, 1))) val[ret++] = value; @@ -3501,7 +3501,7 @@ int get_subnet_bits(char *ip) } retval += (atoi(tmp) * pow(256, 3 - part)); - binary = (char *)malloc( maxBits * sizeof(char) ); + binary = (char *)malloc(maxBits * sizeof(char)); dec_to_bin(retval, binary); for (i = 0; i < (int)strlen(binary); i++) { @@ -3544,9 +3544,9 @@ long get_next_free_numeric_value(virDomainPtr domain, char *xpath) long max_slot = -1; xml = virDomainGetXMLDesc(domain, VIR_DOMAIN_XML_INACTIVE); - output = (zval *)emalloc( sizeof(zval) ); + output = (zval *)emalloc(sizeof(zval)); array_init(output); - free( get_string_from_xpath(xml, xpath, &output, &retval) ); + free(get_string_from_xpath(xml, xpath, &output, &retval)); arr_hash = Z_ARRVAL_P(output); // array_count = zend_hash_num_elements(arr_hash); @@ -3735,7 +3735,7 @@ char *generate_uuid_any() a[i] = hexa[ rand() % strlen(hexa) ]; } - return strdup( a ); + return strdup(a); } /* @@ -3829,7 +3829,7 @@ char *get_disk_xml(unsigned long long size, char *path, char *driver, char *bus, (disk_flags & DOMAIN_DISK_FILE) ? "file" : ((disk_flags & DOMAIN_DISK_BLOCK) ? "block" : ""), driver, path, bus, dev); - return strdup( xml ); + return strdup(xml); } /* @@ -3862,7 +3862,7 @@ char *get_network_xml(char *mac, char *network, char *model) "\t\t</interface>\n", mac, network, model); - return strdup( xml ); + return strdup(xml); } /* @@ -4308,7 +4308,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_name) php_libvirt_domain *res_domain; GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); - if ( (name == NULL) || (name_len<1)) RETURN_FALSE; + if ((name == NULL) || (name_len<1)) RETURN_FALSE; domain=virDomainLookupByName(conn->conn, name); if (domain == NULL) RETURN_FALSE; @@ -4344,7 +4344,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid) GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); - if ( (uuid == NULL) || (uuid_len<1)) RETURN_FALSE; + if ((uuid == NULL) || (uuid_len<1)) RETURN_FALSE; domain=virDomainLookupByUUID(conn->conn, uuid); if (domain == NULL) RETURN_FALSE; @@ -4409,7 +4409,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string) GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); - if ( (uuid == NULL) || (uuid_len<1)) RETURN_FALSE; + if ((uuid == NULL) || (uuid_len<1)) RETURN_FALSE; domain=virDomainLookupByUUIDString(conn->conn, uuid); if (domain == NULL) RETURN_FALSE; @@ -4919,7 +4919,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) snprintf(tmpp, sizeof(tmpp), "%s:%d", hostname, port); retval = execlp(path, basename(pathDup), tmpp, file, NULL); - _exit( retval ); + _exit(retval); } else { do { @@ -4938,7 +4938,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) fd = open(file, O_RDONLY); fsize = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_SET); - buf = emalloc( (fsize + 1) * sizeof(char) ); + buf = emalloc((fsize + 1) * sizeof(char)); memset(buf, 0, fsize + 1); if (read(fd, buf, fsize) < 0) { close(fd); @@ -5566,13 +5566,13 @@ void parse_array(zval *arr, tVMDisk *disk, tVMNetwork *network) if (key.type == HASH_KEY_IS_STRING) { if (disk != NULL) { if ((Z_TYPE_P(data) == IS_STRING) && strcmp(key.name, "path") == 0) - disk->path = strdup( Z_STRVAL_P(data) ); + disk->path = strdup(Z_STRVAL_P(data)); else if ((Z_TYPE_P(data) == IS_STRING) && strcmp(key.name, "driver") == 0) - disk->driver = strdup( Z_STRVAL_P(data) ); + disk->driver = strdup(Z_STRVAL_P(data)); else if ((Z_TYPE_P(data) == IS_STRING) && strcmp(key.name, "bus") == 0) - disk->bus = strdup( Z_STRVAL_P(data) ); + disk->bus = strdup(Z_STRVAL_P(data)); else if ((Z_TYPE_P(data) == IS_STRING) && strcmp(key.name, "dev") == 0) - disk->dev = strdup( Z_STRVAL_P(data) ); + disk->dev = strdup(Z_STRVAL_P(data)); else if (strcmp(key.name, "size") == 0) { if (Z_TYPE_P(data) == IS_LONG) { disk->size = Z_LVAL_P(data); @@ -5585,11 +5585,11 @@ void parse_array(zval *arr, tVMDisk *disk, tVMNetwork *network) } else { if (network != NULL) { if ((Z_TYPE_P(data) == IS_STRING) && strcmp(key.name, "mac") == 0) - network->mac = strdup( Z_STRVAL_P(data) ); + network->mac = strdup(Z_STRVAL_P(data)); else if ((Z_TYPE_P(data) == IS_STRING) && strcmp(key.name, "network") == 0) - network->network = strdup( Z_STRVAL_P(data) ); + network->network = strdup(Z_STRVAL_P(data)); else if ((Z_TYPE_P(data) == IS_STRING) && strcmp(key.name, "model") == 0) - network->model = strdup( Z_STRVAL_P(data) ); + network->model = strdup(Z_STRVAL_P(data)); } } } @@ -5663,7 +5663,7 @@ PHP_FUNCTION(libvirt_domain_new) /* Parse all disks from array */ arr_hash = Z_ARRVAL_P(disks); numDisks = zend_hash_num_elements(arr_hash); - vmDisks = (tVMDisk *)malloc( numDisks * sizeof(tVMDisk) ); + vmDisks = (tVMDisk *)malloc(numDisks * sizeof(tVMDisk)); memset(vmDisks, 0, numDisks * sizeof(tVMDisk)); i = 0; VIRT_FOREACH(arr_hash, pointer, data) { @@ -5682,7 +5682,7 @@ PHP_FUNCTION(libvirt_domain_new) /* Parse all networks from array */ arr_hash = Z_ARRVAL_P(networks); numNets = zend_hash_num_elements(arr_hash); - vmNetworks = (tVMNetwork *)malloc( numNets * sizeof(tVMNetwork) ); + vmNetworks = (tVMNetwork *)malloc(numNets * sizeof(tVMNetwork)); memset(vmNetworks, 0, numNets * sizeof(tVMNetwork)); i = 0; VIRT_FOREACH(arr_hash, pointer, data) { @@ -5863,7 +5863,7 @@ PHP_FUNCTION(libvirt_domain_get_disk_devices) array_init(return_value); - free( get_string_from_xpath(xml, "//domain/devices/disk/target/@dev", &return_value, &retval) ); + free(get_string_from_xpath(xml, "//domain/devices/disk/target/@dev", &return_value, &retval)); free(xml); if (retval < 0) @@ -5898,7 +5898,7 @@ PHP_FUNCTION(libvirt_domain_get_interface_devices) array_init(return_value); - free( get_string_from_xpath(xml, "//domain/devices/interface/target/@dev", &return_value, &retval) ); + free(get_string_from_xpath(xml, "//domain/devices/interface/target/@dev", &return_value, &retval)); free(xml); if (retval < 0) @@ -5913,7 +5913,7 @@ PHP_FUNCTION(libvirt_domain_get_interface_devices) * Description: Function is used to change the VCPU count for the domain * Arguments: @res [resource]: libvirt domain resource * @numCpus [int]: number of VCPUs to be set for the guest - * @flags [int]: flags for virDomainSetVcpusFlags (available at http://libvirt.org/html/libvirt-libvirt.html#virDomainVcpuFlags ) + * @flags [int]: flags for virDomainSetVcpusFlags (available at http://libvirt.org/html/libvirt-libvirt.html#virDomainVcpuFlags) * Returns: true on success, false on error */ PHP_FUNCTION(libvirt_domain_change_vcpus) @@ -5985,12 +5985,12 @@ PHP_FUNCTION(libvirt_domain_change_memory) // pos = strlen(xml) - strlen(tmp1); len = strlen(xml) - strlen(tmpA); - tmp2 = (char *)emalloc( ( len + 1 )* sizeof(char) ); + tmp2 = (char *)emalloc((len + 1)* sizeof(char)); memset(tmp2, 0, len + 1); memcpy(tmp2, xml, len); new_len = strlen(tmp1) + strlen(tmp2) + strlen(newXml) + 2; - new_xml = (char *)emalloc( new_len * sizeof(char) ); + new_xml = (char *)emalloc(new_len * sizeof(char)); snprintf(new_xml, new_len, "%s\n%s%s", tmp2, newXml, tmp1); conn = domain->conn; @@ -6069,12 +6069,12 @@ PHP_FUNCTION(libvirt_domain_change_boot_devices) // pos = strlen(xml) - strlen(tmp1); len = strlen(xml) - strlen(tmpA); - tmp2 = (char *)emalloc( ( len + 1 )* sizeof(char) ); + tmp2 = (char *)emalloc((len + 1)* sizeof(char)); memset(tmp2, 0, len + 1); memcpy(tmp2, xml, len); new_len = strlen(tmp1) + strlen(tmp2) + strlen(newXml) + 2; - new_xml = (char *)emalloc( new_len * sizeof(char) ); + new_xml = (char *)emalloc(new_len * sizeof(char)); snprintf(new_xml, new_len, "%s\n%s%s", tmp2, newXml, tmp1); conn = domain->conn; @@ -7631,7 +7631,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name) GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &name, &name_len, &flags); - if ( (name == NULL) || (name_len<1)) RETURN_FALSE; + if ((name == NULL) || (name_len<1)) RETURN_FALSE; snapshot=virDomainSnapshotLookupByName(domain->domain, name, flags); if (snapshot == NULL) RETURN_FALSE; @@ -7776,8 +7776,8 @@ PHP_FUNCTION(libvirt_list_domain_snapshots) expectedcount=virDomainSnapshotNum(domain->domain, flags); DPRINTF("%s: virDomainSnapshotNum(%p, 0) returned %d\n", PHPFUNC, domain->domain, expectedcount); - if (expectedcount != -1 ) { - names=(char **)emalloc( expectedcount * sizeof(char *) ); + if (expectedcount != -1) { + names=(char **)emalloc(expectedcount * sizeof(char *)); count=virDomainSnapshotListNames(domain->domain, names, expectedcount, 0); } @@ -7815,7 +7815,7 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_name) GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); - if ( (name == NULL) || (name_len<1)) RETURN_FALSE; + if ((name == NULL) || (name_len<1)) RETURN_FALSE; pool=virStoragePoolLookupByName(conn->conn, name); DPRINTF("%s: virStoragePoolLookupByName(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, pool); if (pool == NULL) RETURN_FALSE; @@ -7955,7 +7955,7 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name) virStorageVolPtr volume=NULL; GET_STORAGEPOOL_FROM_ARGS("rs", &zpool, &name, &name_len); - if ( (name == NULL) || (name_len<1)) RETURN_FALSE; + if ((name == NULL) || (name_len<1)) RETURN_FALSE; volume=virStorageVolLookupByName(pool->pool, name); DPRINTF("%s: virStorageVolLookupByName(%p, %s) returned %p\n", PHPFUNC, pool->pool, name, volume); @@ -7992,7 +7992,7 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_path) virStorageVolPtr volume=NULL; GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); - if ( (name == NULL) || (name_len<1)) RETURN_FALSE; + if ((name == NULL) || (name_len<1)) RETURN_FALSE; volume=virStorageVolLookupByPath(conn->conn, name); DPRINTF("%s: virStorageVolLookupByPath(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, volume); @@ -10034,7 +10034,7 @@ PHP_FUNCTION(libvirt_get_iso_images) } if (LIBVIRT_G(iso_path_ini)) - path = strdup( LIBVIRT_G(iso_path_ini) ); + path = strdup(LIBVIRT_G(iso_path_ini)); if ((path == NULL) || (path[0] != '/')) { set_error("Invalid argument, path must be set and absolute (start by slash character [/])" TSRMLS_CC); -- 2.7.3

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 235157e..9ee72be 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -1153,7 +1153,7 @@ PHP_MINFO_FUNCTION(libvirt) } if (strlen(features_supported) > 0) { - features_supported[ strlen(features_supported) - 2 ] = 0; + features_supported[strlen(features_supported) - 2] = 0; php_info_print_table_row(2, "Features supported", features_supported); } @@ -3732,7 +3732,7 @@ char *generate_uuid_any() if ((i == 8) || (i == 13) || (i == 18) || (i == 23)) a[i] = '-'; else - a[i] = hexa[ rand() % strlen(hexa) ]; + a[i] = hexa[rand() % strlen(hexa)]; } return strdup(a); -- 2.7.3

Follow the following rules in if - then - else statements: 1) The opening brackets stays in the same line with the if statement 2) The closing brace is empty on a line of its own except in the cases where it is followed by a continuation of the same statement. Example: if (x == y) { ... } else { ... } 3) Do not unnecessarily use braces where a single statement will do. However, if one branch of a conditional statement is a single statement and the other multiline use braces in both branches. example: if (condition) { do_this(); do_that(); } else { otherwise(); } Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 315 +++++++++++++++++++----------------------------------- 1 file changed, 111 insertions(+), 204 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 9ee72be..770c7c1 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -1023,8 +1023,7 @@ int resource_change_counter(int type, virConnectPtr conn, void *mem, int inc TSR if (binding_resources == NULL) { binding_resources_count = 1; binding_resources = (resource_info *)malloc(sizeof(resource_info)); - } - else { + } else { binding_resources_count++; binding_resources = (resource_info *)realloc(binding_resources, binding_resources_count * sizeof(resource_info)); } @@ -1039,8 +1038,7 @@ int resource_change_counter(int type, virConnectPtr conn, void *mem, int inc TSR binding_resources[pos].mem = mem; binding_resources[pos].conn = conn; binding_resources[pos].overwrite = 0; - } - else { + } else { for (i = 0; i < binding_resources_count; i++) { if ((binding_resources[i].type == type) && (binding_resources[i].mem == mem)) binding_resources[i].overwrite = 1; @@ -1116,8 +1114,7 @@ PHP_MINFO_FUNCTION(libvirt) php_info_print_table_row(2, "Debug support", tmp); php_info_print_table_row(2, "Extension version", PHP_LIBVIRT_WORLD_VERSION); - if (virGetVersion(&libVer, NULL, NULL) == 0) - { + if (virGetVersion(&libVer, NULL, NULL) == 0) { char version[100]; snprintf(version, sizeof(version), "%i.%i.%i", (long)((libVer/1000000) % 1000), (long)((libVer/1000) % 1000), (long)(libVer % 1000)); php_info_print_table_row(2, "Libvirt version", version); @@ -1256,8 +1253,7 @@ void free_resource(int type, void *mem TSRMLS_DC) if (rv != 0) { DPRINTF("%s: virDomainFree(%p) returned %d (%s)\n", __FUNCTION__, (virDomainPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virDomainFree(%p) completed successfully\n", __FUNCTION__, (virDomainPtr)mem); resource_change_counter(INT_RESOURCE_DOMAIN, NULL, (virDomainPtr)mem, 0 TSRMLS_CC); } @@ -1268,8 +1264,7 @@ void free_resource(int type, void *mem TSRMLS_DC) if (rv != 0) { DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, (virStreamPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virStreamFree(%p) completed successfully\n", __FUNCTION__, (virStreamPtr)mem); resource_change_counter(INT_RESOURCE_STREAM, NULL, (virStreamPtr)mem, 0 TSRMLS_CC); } @@ -1280,8 +1275,7 @@ void free_resource(int type, void *mem TSRMLS_DC) if (rv != 0) { DPRINTF("%s: virNetworkFree(%p) returned %d (%s)\n", __FUNCTION__, (virNetworkPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNetworkFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virNetworkFree(%p) completed successfully\n", __FUNCTION__, (virNetworkPtr)mem); resource_change_counter(INT_RESOURCE_NETWORK, NULL, (virNetworkPtr)mem, 0 TSRMLS_CC); } @@ -1292,8 +1286,7 @@ void free_resource(int type, void *mem TSRMLS_DC) if (rv != 0) { DPRINTF("%s: virNodeDeviceFree(%p) returned %d (%s)\n", __FUNCTION__, (virNodeDevicePtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virNodeDeviceFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virNodeDeviceFree(%p) completed successfully\n", __FUNCTION__, (virNodeDevicePtr)mem); resource_change_counter(INT_RESOURCE_NODEDEV, NULL, (virNodeDevicePtr)mem, 0 TSRMLS_CC); } @@ -1304,8 +1297,7 @@ void free_resource(int type, void *mem TSRMLS_DC) if (rv != 0) { DPRINTF("%s: virStoragePoolFree(%p) returned %d (%s)\n", __FUNCTION__, (virStoragePoolPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virStoragePoolFree(%p) completed successfully\n", __FUNCTION__, (virStoragePoolPtr)mem); resource_change_counter(INT_RESOURCE_STORAGEPOOL, NULL, (virStoragePoolPtr)mem, 0 TSRMLS_CC); } @@ -1316,8 +1308,7 @@ void free_resource(int type, void *mem TSRMLS_DC) if (rv != 0) { DPRINTF("%s: virStorageVolFree(%p) returned %d (%s)\n", __FUNCTION__, (virStorageVolPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virStorageVolFree(%p) completed successfully\n", __FUNCTION__, (virStorageVolPtr)mem); resource_change_counter(INT_RESOURCE_VOLUME, NULL, (virStorageVolPtr)mem, 0 TSRMLS_CC); } @@ -1328,8 +1319,7 @@ void free_resource(int type, void *mem TSRMLS_DC) if (rv != 0) { DPRINTF("%s: virDomainSnapshotFree(%p) returned %d (%s)\n", __FUNCTION__, (virDomainSnapshotPtr)mem, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainSnapshotFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virDomainSnapshotFree(%p) completed successfully\n", __FUNCTION__, (virDomainSnapshotPtr)mem); resource_change_counter(INT_RESOURCE_SNAPSHOT, NULL, (virDomainSnapshotPtr)mem, 0 TSRMLS_CC); } @@ -1487,18 +1477,15 @@ static void php_libvirt_connection_dtor( php_libvirt_connection *conn = (php_libvirt_connection*)rsrc->ptr; int rv = 0; - if (conn != NULL) - { - if (conn->conn != NULL) - { + if (conn != NULL) { + if (conn->conn != NULL) { free_resources_on_connection(conn->conn TSRMLS_CC); rv = virConnectClose(conn->conn); if (rv == -1) { DPRINTF("%s: virConnectClose(%p) returned %d (%s)\n", __FUNCTION__, conn->conn, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virConnectClose failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virConnectClose(%p) completed successfully\n", __FUNCTION__, conn->conn); resource_change_counter(INT_RESOURCE_CONNECTION, NULL, conn->conn, 0 TSRMLS_CC); } @@ -1520,10 +1507,8 @@ static void php_libvirt_domain_dtor( php_libvirt_domain *domain = (php_libvirt_domain*)rsrc->ptr; int rv = 0; - if (domain != NULL) - { - if (domain->domain != NULL) - { + if (domain != NULL) { + if (domain->domain != NULL) { if (!check_resource_allocation(domain->conn->conn, INT_RESOURCE_DOMAIN, domain->domain TSRMLS_CC)) { domain->domain=NULL; efree(domain); @@ -1534,8 +1519,7 @@ static void php_libvirt_domain_dtor( if (rv != 0) { DPRINTF("%s: virDomainFree(%p) returned %d (%s)\n", __FUNCTION__, domain->domain, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virDomainFree(%p) completed successfully\n", __FUNCTION__, domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, domain->conn->conn, domain->domain, 0 TSRMLS_CC); } @@ -1557,10 +1541,8 @@ static void php_libvirt_stream_dtor( php_libvirt_stream *stream = (php_libvirt_stream*)rsrc->ptr; int rv = 0; - if (stream != NULL) - { - if (stream->stream != NULL) - { + if (stream != NULL) { + if (stream->stream != NULL) { if (!check_resource_allocation(NULL, INT_RESOURCE_STREAM, stream->stream TSRMLS_CC)) { stream->stream=NULL; efree(stream); @@ -1570,8 +1552,7 @@ static void php_libvirt_stream_dtor( if (rv != 0) { DPRINTF("%s: virStreamFree(%p) returned %d (%s)\n", __FUNCTION__, stream->stream, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStreamFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virStreamFree(%p) completed successfully\n", __FUNCTION__, stream->stream); resource_change_counter(INT_RESOURCE_STREAM, NULL, stream->stream, 0 TSRMLS_CC); } @@ -1593,10 +1574,8 @@ static void php_libvirt_storagepool_dtor( php_libvirt_storagepool *pool = (php_libvirt_storagepool*)rsrc->ptr; int rv = 0; - if (pool != NULL) - { - if (pool->pool != NULL) - { + if (pool != NULL) { + if (pool->pool != NULL) { if (!check_resource_allocation(NULL, INT_RESOURCE_STORAGEPOOL, pool->pool TSRMLS_CC)) { pool->pool=NULL; efree(pool); @@ -1606,8 +1585,7 @@ static void php_libvirt_storagepool_dtor( if (rv != 0) { DPRINTF("%s: virStoragePoolFree(%p) returned %d (%s)\n", __FUNCTION__, pool->pool, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStoragePoolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virStoragePoolFree(%p) completed successfully\n", __FUNCTION__, pool->pool); resource_change_counter(INT_RESOURCE_STORAGEPOOL, NULL, pool->pool, 0 TSRMLS_CC); } @@ -1629,10 +1607,8 @@ static void php_libvirt_volume_dtor( php_libvirt_volume *volume = (php_libvirt_volume*)rsrc->ptr; int rv = 0; - if (volume != NULL) - { - if (volume->volume != NULL) - { + if (volume != NULL) { + if (volume->volume != NULL) { if (!check_resource_allocation(NULL, INT_RESOURCE_VOLUME, volume->volume TSRMLS_CC)) { volume->volume=NULL; efree(volume); @@ -1642,8 +1618,7 @@ static void php_libvirt_volume_dtor( if (rv != 0) { DPRINTF("%s: virStorageVolFree(%p) returned %d (%s)\n", __FUNCTION__, volume->volume, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virStorageVolFree(%p) completed successfully\n", __FUNCTION__, volume->volume); resource_change_counter(INT_RESOURCE_VOLUME, NULL, volume->volume, 0 TSRMLS_CC); } @@ -1665,10 +1640,8 @@ static void php_libvirt_network_dtor( php_libvirt_network *network = (php_libvirt_network*)rsrc->ptr; int rv = 0; - if (network != NULL) - { - if (network->network != NULL) - { + if (network != NULL) { + if (network->network != NULL) { if (!check_resource_allocation(network->conn->conn, INT_RESOURCE_NETWORK, network->network TSRMLS_CC)) { network->network=NULL; efree(network); @@ -1678,8 +1651,7 @@ static void php_libvirt_network_dtor( if (rv != 0) { DPRINTF("%s: virNetworkFree(%p) returned %d (%s)\n", __FUNCTION__, network->network, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virNetworkFree(%p) completed successfully\n", __FUNCTION__, network->network); resource_change_counter(INT_RESOURCE_NETWORK, NULL, network->network, 0 TSRMLS_CC); } @@ -1701,10 +1673,8 @@ static void php_libvirt_nodedev_dtor( php_libvirt_nodedev *nodedev = (php_libvirt_nodedev*)rsrc->ptr; int rv = 0; - if (nodedev != NULL) - { - if (nodedev->device != NULL) - { + if (nodedev != NULL) { + if (nodedev->device != NULL) { if (!check_resource_allocation(nodedev->conn->conn, INT_RESOURCE_NODEDEV, nodedev->device TSRMLS_CC)) { nodedev->device=NULL; efree(nodedev); @@ -1714,8 +1684,7 @@ static void php_libvirt_nodedev_dtor( if (rv != 0) { DPRINTF("%s: virNodeDeviceFree(%p) returned %d (%s)\n", __FUNCTION__, nodedev->device, rv, LIBVIRT_G(last_error)); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virNodeDeviceFree(%p) completed successfully\n", __FUNCTION__, nodedev->device); resource_change_counter(INT_RESOURCE_NODEDEV, nodedev->conn->conn, nodedev->device, 0 TSRMLS_CC); } @@ -1737,10 +1706,8 @@ static void php_libvirt_snapshot_dtor( php_libvirt_snapshot *snapshot = (php_libvirt_snapshot*)rsrc->ptr; int rv = 0; - if (snapshot != NULL) - { - if (snapshot->snapshot != NULL) - { + if (snapshot != NULL) { + if (snapshot->snapshot != NULL) { if (!check_resource_allocation(NULL, INT_RESOURCE_SNAPSHOT, snapshot->snapshot TSRMLS_CC)) { snapshot->snapshot=NULL; efree(snapshot); @@ -1750,8 +1717,7 @@ static void php_libvirt_snapshot_dtor( if (rv != 0) { DPRINTF("%s: virDomainSnapshotFree(%p) returned %d\n", __FUNCTION__, snapshot->snapshot, rv); php_error_docref(NULL TSRMLS_CC, E_WARNING, "virStorageVolFree failed with %i on destructor: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { DPRINTF("%s: virDomainSnapshotFree(%p) completed successfully\n", __FUNCTION__, snapshot->snapshot); resource_change_counter(INT_RESOURCE_SNAPSHOT, snapshot->domain->conn->conn, snapshot->snapshot, 0 TSRMLS_CC); } @@ -2189,8 +2155,7 @@ static int libvirt_virConnectAuthCallback(virConnectCredentialPtr cred, unsigned if (creds != NULL) for (j = 0; j < (unsigned int)creds[0].count; j++) { - if (creds[j].type == cred[i].type) - { + if (creds[j].type == cred[i].type) { cred[i].resultlen=creds[j].resultlen; cred[i].result=(char *)malloc(creds[j].resultlen + 1); memset(cred[i].result, 0, creds[j].resultlen + 1); @@ -2266,8 +2231,7 @@ PHP_FUNCTION(libvirt_connect) if (virGetVersion(&libVer, NULL, NULL)!= 0) RETURN_FALSE; - if (libVer < 6002) - { + if (libVer<6002) { set_error("Only libvirt 0.6.2 and higher supported. Please upgrade your libvirt" TSRMLS_CC); RETURN_FALSE; } @@ -2283,15 +2247,14 @@ PHP_FUNCTION(libvirt_connect) url = NULL; conn=(php_libvirt_connection *)emalloc(sizeof(php_libvirt_connection)); - if (zcreds == NULL) - { /* connecting without providing authentication */ + if (zcreds == NULL) { + /* connecting without providing authentication */ if (readonly) conn->conn = virConnectOpenReadOnly(url); else conn->conn = virConnectOpen(url); - } - else - { /* connecting with authentication (using callback) */ + } else { + /* connecting with authentication (using callback) */ arr_hash = Z_ARRVAL_P(zcreds); array_count = zend_hash_num_elements(arr_hash); @@ -2326,8 +2289,7 @@ PHP_FUNCTION(libvirt_connect) efree(creds); } - if (conn->conn == NULL) - { + if (conn->conn == NULL) { DPRINTF("%s: Cannot establish connection to %s\n", PHPFUNC, url); efree(conn); RETURN_FALSE; @@ -2419,9 +2381,8 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats) RETURN_FALSE; } - if (nparams == 0) { + if (nparams == 0) RETURN_TRUE; - } DPRINTF("%s: Number of parameters got from virNodeGetCPUStats is %d\n", __FUNCTION__, nparams); @@ -2465,13 +2426,14 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats) } add_assoc_long(return_value, "cpus", numCpus); - if (cpuNum >= 0) + if (cpuNum >= 0) { add_assoc_long(return_value, "cpu", cpunr); - else + } else { if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS) VIRT_ADD_ASSOC_STRING(return_value, "cpu", "all"); else VIRT_ADD_ASSOC_STRING(return_value, "cpu", "unknown"); + } free(params); params = NULL; @@ -2514,9 +2476,8 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu) RETURN_FALSE; } - if (nparams == 0) { + if (nparams == 0) RETURN_TRUE; - } DPRINTF("%s: Number of parameters got from virNodeGetCPUStats is %d\n", __FUNCTION__, nparams); @@ -2620,9 +2581,8 @@ PHP_FUNCTION(libvirt_node_get_mem_stats) RETURN_FALSE; } - if (nparams == 0) { + if (nparams == 0) RETURN_TRUE; - } DPRINTF("%s: Number of parameters got from virNodeGetMemoryStats is %d\n", __FUNCTION__, nparams); @@ -2744,9 +2704,9 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) ret[i], ret3[k]); numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL); - if (numTmp == NULL) + if (numTmp == NULL) { VIRT_ADD_ASSOC_STRING(arr2, key, ret3[k]); - else { + } else { #if PHP_MAJOR_VERSION >= 7 zval *arr4, zarr4; arr4 = &zarr4; @@ -2784,9 +2744,9 @@ PHP_FUNCTION(libvirt_connect_get_machine_types) ret[i], ret2[j], ret3[k]); numTmp = get_string_from_xpath(caps, tmp3, NULL, NULL); - if (numTmp == NULL) + if (numTmp == NULL) { VIRT_ADD_ASSOC_STRING(arr3, key, ret3[k]); - else { + } else { #if PHP_MAJOR_VERSION >= 7 zval *arr4, zarr4; arr4 = &zarr4; @@ -2860,9 +2820,9 @@ PHP_FUNCTION(libvirt_connect_get_information) if (strcmp(type, "QEMU") == 0) { /* For QEMU the value is not reliable so we return -1 instead */ maxvcpus = -1; - } - else + } else { maxvcpus = virConnectGetMaxVcpus(conn->conn, type); + } add_assoc_long(return_value, "hypervisor_maxvcpus", maxvcpus); iTmp = virConnectIsEncrypted(conn->conn); @@ -3010,8 +2970,7 @@ PHP_FUNCTION(libvirt_image_create) if (WEXITSTATUS(cmdRet) == 0 && access(fpath, F_OK) == 0) { RETURN_TRUE; - } - else { + } else { snprintf(msg, sizeof(msg), "Cannot create image: %s", fpath); set_error(msg TSRMLS_CC); RETURN_FALSE; @@ -3063,8 +3022,7 @@ PHP_FUNCTION(libvirt_image_remove) snprintf(msg, sizeof(msg), "An error occured while unlinking %s: %d (%s)", image, errno, strerror(errno)); set_error(msg TSRMLS_CC); RETURN_FALSE; - } - else { + } else { RETURN_TRUE; } } @@ -3312,7 +3270,7 @@ char *get_string_from_xpath(char *xml, char *xpath, zval **val, int *retVal) goto cleanup; } - if(xmlXPathNodeSetIsEmpty(result->nodesetval)) + if (xmlXPathNodeSetIsEmpty(result->nodesetval)) goto cleanup; nodeset = result->nodesetval; @@ -3394,7 +3352,7 @@ char **get_array_from_xpath(char *xml, char *xpath, int *num) return NULL; } - if(xmlXPathNodeSetIsEmpty(result->nodesetval)){ + if (xmlXPathNodeSetIsEmpty(result->nodesetval)) { xmlXPathFreeObject(result); xmlXPathFreeContext(context); xmlCleanupParser(); @@ -3448,8 +3406,7 @@ void dec_to_bin(long long decimal, char *binary) // int old_decimal; char temp[128] = { 0 }; - if (decimal < 0) - { + if (decimal < 0) { decimal = -decimal; neg_flag = 1; } @@ -3494,8 +3451,7 @@ int get_subnet_bits(char *ip) retval += (atoi(tmp) * pow(256, 3 - part)); part++; memset(tmp, 0, 4); - } - else { + } else { tmp[ii++] = ip[i]; } } @@ -4075,9 +4031,8 @@ PHP_FUNCTION(libvirt_domain_is_persistent) GET_DOMAIN_FROM_ARGS("r", &zdomain); - if ((p = virDomainIsPersistent(domain->domain)) < 0) { + if ((p = virDomainIsPersistent(domain->domain)) < 0) RETURN_LONG(-1); - } if (p == 1) RETURN_TRUE; @@ -4168,8 +4123,7 @@ PHP_FUNCTION(libvirt_domain_get_autostart) GET_DOMAIN_FROM_ARGS("r", &zdomain); - if (virDomainGetAutostart (domain->domain, &flags) != 0) - { + if (virDomainGetAutostart (domain->domain, &flags) != 0) { RETURN_LONG(-1); } RETURN_LONG((long)flags); @@ -4191,8 +4145,7 @@ PHP_FUNCTION(libvirt_domain_set_autostart) GET_DOMAIN_FROM_ARGS("rb", &zdomain, &flags); - if (virDomainSetAutostart (domain->domain, flags) != 0) - { + if (virDomainSetAutostart (domain->domain, flags) != 0) { RETURN_FALSE; } RETURN_TRUE; @@ -4225,14 +4178,10 @@ PHP_FUNCTION(libvirt_domain_get_metadata) ret = virDomainGetMetadata(domain->domain, type, uri, flags); if (ret == NULL) { - if (strstr(LIBVIRT_G(last_error), "not supported") != NULL) { + if (strstr(LIBVIRT_G(last_error), "not supported") != NULL) RETURN_FALSE; - } - else { - RETURN_NULL(); - } - } - else { + RETURN_NULL(); + } else { VIRT_RETVAL_STRING(ret); free(ret); } @@ -4440,9 +4389,8 @@ PHP_FUNCTION(libvirt_stream_create) virStreamPtr stream = NULL; php_libvirt_stream *res_stream; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zconn) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zconn) == FAILURE) RETURN_FALSE; - } VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection); if ((conn == NULL)||(conn->conn == NULL))RETURN_FALSE; @@ -4477,9 +4425,8 @@ PHP_FUNCTION(libvirt_stream_close) php_libvirt_stream *stream=NULL; int retval = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) RETURN_LONG(retval); - } VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); @@ -4506,9 +4453,8 @@ PHP_FUNCTION(libvirt_stream_abort) php_libvirt_stream *stream=NULL; int retval = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) RETURN_LONG(retval); - } VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); @@ -4533,9 +4479,8 @@ PHP_FUNCTION(libvirt_stream_finish) php_libvirt_stream *stream=NULL; int retval = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) RETURN_LONG(retval); - } VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); @@ -4564,9 +4509,8 @@ PHP_FUNCTION(libvirt_stream_recv) int retval = -1; zend_long length = 0; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) RETURN_LONG(retval); - } VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); @@ -4614,9 +4558,8 @@ PHP_FUNCTION(libvirt_stream_send) char *cstr; //int cstrlen; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) RETURN_LONG(retval); - } VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); @@ -4904,8 +4847,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) set_error("Cannot use builtin approach to get VNC window contents" TSRMLS_CC); goto error; } - } - else { + } else { port = atoi(tmp)-5900; DPRINTF("%s: Getting screenshot of %s:%d to temporary file %s\n", PHPFUNC, hostname, port, file); @@ -4920,8 +4862,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) snprintf(tmpp, sizeof(tmpp), "%s:%d", hostname, port); retval = execlp(path, basename(pathDup), tmpp, file, NULL); _exit(retval); - } - else { + } else { do { w = waitpid(childpid, &retval, 0); if (w == -1) @@ -5498,8 +5439,7 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) if (strncmp(cmd, "Valid ", 6) == 0) { inFunc = 1; continue; - } - else + } else if (strlen(cmd) < 2) inFunc = 0; @@ -5529,8 +5469,7 @@ PHP_FUNCTION(libvirt_connect_get_soundhw_models) VIRT_ADD_ASSOC_STRING(arr, "name", t.tokens[0]); VIRT_ADD_ASSOC_STRING(arr, "description", desc); add_next_index_zval(return_value, arr); - } - else { + } else { char tmp2[16] = { 0 }; snprintf(tmp2, sizeof(tmp2), "%d", n++); VIRT_ADD_ASSOC_STRING(return_value, tmp2, t.tokens[0]); @@ -5579,8 +5518,7 @@ void parse_array(zval *arr, tVMDisk *disk, tVMNetwork *network) } else { disk->size = size_def_to_mbytes(Z_STRVAL_P(data)); } - } - else if ((Z_TYPE_P(data) == IS_LONG) && strcmp(key.name, "flags") == 0) + } else if ((Z_TYPE_P(data) == IS_LONG) && strcmp(key.name, "flags") == 0) disk->flags = Z_LVAL_P(data); } else { if (network != NULL) { @@ -5926,8 +5864,7 @@ PHP_FUNCTION(libvirt_domain_change_vcpus) if (virDomainSetVcpusFlags(domain->domain, numCpus, flags) == 0) { RETURN_TRUE; - } - else { + } else { RETURN_FALSE; } } @@ -6905,9 +6842,7 @@ PHP_FUNCTION(libvirt_domain_memory_stats) LONGLONG_INIT; array_init(return_value); for (i=0;i<retval;i++) - { LONGLONG_INDEX(return_value, stats[i].tag, stats[i].val) - } } /* @@ -7996,8 +7931,7 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_path) volume=virStorageVolLookupByPath(conn->conn, name); DPRINTF("%s: virStorageVolLookupByPath(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, volume); - if (volume == NULL) - { + if (volume == NULL) { set_error_if_unset("Cannot find storage volume on requested path" TSRMLS_CC); RETURN_FALSE; } @@ -8190,8 +8124,7 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) char *xml; strsize_t xml_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsr", &zpool, &xml, &xml_len, &zvolume) == FAILURE) - { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rsr", &zpool, &xml, &xml_len, &zvolume) == FAILURE) { set_error("Invalid pool resource, XML or volume resouce" TSRMLS_CC); RETURN_FALSE; } @@ -8297,9 +8230,8 @@ PHP_FUNCTION(libvirt_storagevolume_download) zend_long length = 0; int retval = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) RETURN_LONG(retval); - } VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); if ((volume == NULL)||(volume->volume == NULL))RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); @@ -8338,9 +8270,8 @@ PHP_FUNCTION(libvirt_storagevolume_upload) zend_long length = 0; int retval = -1; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) RETURN_LONG(retval); - } VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); if ((volume == NULL)||(volume->volume == NULL))RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); @@ -8472,8 +8403,7 @@ PHP_FUNCTION(libvirt_storagepool_get_xml_desc) DPRINTF("%s: pool = %p, flags = %ld, xpath = %s\n", PHPFUNC, pool->pool, flags, xpath); xml = virStoragePoolGetXMLDesc(pool->pool, flags); - if (xml == NULL) - { + if (xml == NULL) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); RETURN_FALSE; } @@ -8773,8 +8703,7 @@ PHP_FUNCTION(libvirt_list_storagepools) names=(char **)emalloc(expectedcount*sizeof(char *)); count=virConnectListStoragePools(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) - { + if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } @@ -8792,8 +8721,7 @@ PHP_FUNCTION(libvirt_list_storagepools) RETURN_FALSE; names = (char **)emalloc(expectedcount * sizeof(char *)); count = virConnectListDefinedStoragePools(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count < 0)) - { + if ((count != expectedcount) || (count < 0)) { efree(names); RETURN_FALSE; } @@ -8830,8 +8758,7 @@ PHP_FUNCTION(libvirt_list_active_storagepools) names=(char **)emalloc(expectedcount*sizeof(char *)); count=virConnectListStoragePools(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) - { + if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } @@ -8867,8 +8794,7 @@ PHP_FUNCTION(libvirt_list_inactive_storagepools) names= (char **)emalloc(expectedcount * sizeof(char *)); count = virConnectListDefinedStoragePools(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count < 0)) - { + if ((count != expectedcount) || (count < 0)) { efree(names); RETURN_FALSE; } @@ -8917,22 +8843,20 @@ PHP_FUNCTION(libvirt_list_domains) { domain=virDomainLookupByID(conn->conn, ids[i]); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, domain, 1 TSRMLS_CC); - if (domain != NULL) - { + if (domain != NULL) { name=virDomainGetName(domain); if (name != NULL) { DPRINTF("%s: Found running domain %s with ID = %d\n", PHPFUNC, name, ids[i]); VIRT_ADD_NEXT_INDEX_STRING(return_value, name); - } - else + } else { DPRINTF("%s: Cannot get ID for running domain %d\n", PHPFUNC, ids[i]); + } } rv = virDomainFree(domain); if (rv != 0) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "virDomainFree failed with %i on list_domain: %s", rv, LIBVIRT_G(last_error)); - } - else { + } else { resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, domain, 0 TSRMLS_CC); } domain = NULL; @@ -8995,8 +8919,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) ids=(int *)emalloc(sizeof(int)*expectedcount); count=virConnectListDomains(conn->conn, ids, expectedcount); - if ((count != expectedcount) || (count<0)) - { + if ((count != expectedcount) || (count<0)) { efree(ids); RETURN_FALSE; } @@ -9004,8 +8927,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) for (i=0;i<count;i++) { domain=virDomainLookupByID(conn->conn, ids[i]); - if (domain != NULL) - { + if (domain != NULL) { res_domain= (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -9028,17 +8950,15 @@ PHP_FUNCTION(libvirt_list_domain_resources) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedDomains(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) - { + count=virConnectListDefinedDomains(conn->conn, names , expectedcount); + if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } for (i=0;i<count;i++) { domain=virDomainLookupByName(conn->conn, names[i]); - if (domain != NULL) - { + if (domain != NULL) { res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -9082,8 +9002,7 @@ PHP_FUNCTION(libvirt_list_active_domain_ids) ids=(int *)emalloc(sizeof(int)*expectedcount); count=virConnectListDomains(conn->conn, ids, expectedcount); - if ((count != expectedcount) || (count<0)) - { + if ((count != expectedcount) || (count<0)) { efree(ids); RETURN_FALSE; } @@ -9120,8 +9039,7 @@ PHP_FUNCTION(libvirt_list_active_domains) ids=(int *)emalloc(sizeof(int)*expectedcount); count=virConnectListDomains(conn->conn, ids, expectedcount); - if ((count != expectedcount) || (count<0)) - { + if ((count != expectedcount) || (count<0)) { efree(ids); RETURN_FALSE; } @@ -9169,8 +9087,7 @@ PHP_FUNCTION(libvirt_list_inactive_domains) names=(char **)emalloc(expectedcount*sizeof(char *)); count=virConnectListDefinedDomains(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) - { + if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } @@ -9211,8 +9128,7 @@ PHP_FUNCTION(libvirt_list_networks) names=(char **)emalloc(expectedcount*sizeof(char *)); count=virConnectListNetworks(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) - { + if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } @@ -9232,8 +9148,7 @@ PHP_FUNCTION(libvirt_list_networks) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); count=virConnectListDefinedNetworks(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) - { + if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } @@ -9277,8 +9192,7 @@ PHP_FUNCTION(libvirt_list_nodedevs) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); count=virNodeListDevices(conn->conn, cap, names, expectedcount, 0); - if ((count != expectedcount) || (count<0)) - { + if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } @@ -9385,9 +9299,7 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc) GET_NODEDEV_FROM_ARGS("r|s", &znodedev, &xpath, &xpath_len); if (xpath_len < 1) - { xpath = NULL; - } xml = virNodeDeviceGetXMLDesc(nodedev->device, 0); if (!xml) { @@ -9396,11 +9308,10 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc) } tmp = get_string_from_xpath(xml, xpath, NULL, &retval); - if ((tmp == NULL) || (retval < 0)) { + if ((tmp == NULL) || (retval < 0)) VIRT_RETVAL_STRING(xml); - } else { + else VIRT_RETVAL_STRING(tmp); - } free(xml); free(tmp); @@ -9831,8 +9742,7 @@ PHP_FUNCTION(libvirt_network_set_active) if (virNetworkCreate(network->network) == 0) { // Network is up and running RETURN_TRUE; - } - else { + } else { // We don't have to set error since it's caught by libvirt error handler itself RETURN_FALSE; } @@ -9841,8 +9751,7 @@ PHP_FUNCTION(libvirt_network_set_active) if (virNetworkDestroy(network->network) == 0) { // Network is down RETURN_TRUE; - } - else { + } else { // Caught by libvirt error handler too RETURN_FALSE; } @@ -9868,9 +9777,7 @@ PHP_FUNCTION(libvirt_network_get_xml_desc) GET_NETWORK_FROM_ARGS("r|s", &znetwork, &xpath, &xpath_len); if (xpath_len < 1) - { xpath = NULL; - } xml=virNetworkGetXMLDesc(network->network, 0); @@ -9968,17 +9875,17 @@ PHP_FUNCTION(libvirt_check_version) ((VERSION_MAJOR == major) && (VERSION_MINOR == minor) && (VERSION_MICRO >= micro))) RETURN_TRUE; - } - else + } else { if (type == VIR_VERSION_LIBVIRT) { if ((((libVer/1000000) % 1000) > major) || ((((libVer/1000000) % 1000) == major) && (((libVer/1000) % 1000) > minor)) || ((((libVer/1000000) % 1000) == major) && (((libVer/1000) % 1000) == minor) && ((libVer %1000) >= micro))) RETURN_TRUE; - } - else + } else { set_error("Invalid version type" TSRMLS_CC); + } + } RETURN_FALSE; } @@ -10053,9 +9960,9 @@ PHP_FUNCTION(libvirt_get_iso_images) } } closedir(d); - } - else + } else { printf("Error: %d\n", errno); + } #endif if (num == 0) -- 2.7.3

Put the opening brace last on the line all non-function statement blocks (if, switch, for, while, do) Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 66 +++++++++++++++++++------------------------------------ 1 file changed, 22 insertions(+), 44 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 770c7c1..eb717fd 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2149,12 +2149,10 @@ static int libvirt_virConnectAuthCallback(virConnectCredentialPtr cred, unsigned unsigned int i, j; php_libvirt_cred_value *creds=(php_libvirt_cred_value*) cbdata; - for (i = 0; i < (unsigned int)ncred; i++) - { + for (i = 0; i < (unsigned int)ncred; i++) { DPRINTF("%s: cred %d, type %d, prompt %s challenge %s\n ", __FUNCTION__, i, cred[i].type, cred[i].prompt, cred[i].challenge); if (creds != NULL) - for (j = 0; j < (unsigned int)creds[0].count; j++) - { + for (j = 0; j < (unsigned int)creds[0].count; j++) { if (creds[j].type == cred[i].type) { cred[i].resultlen=creds[j].resultlen; cred[i].result=(char *)malloc(creds[j].resultlen + 1); @@ -2806,8 +2804,7 @@ PHP_FUNCTION(libvirt_connect_get_information) VIRT_ADD_ASSOC_STRING(return_value, "hostname", tmp ? tmp : "unknown"); free(tmp); - if ((virConnectGetVersion(conn->conn, &hvVer) == 0) && (type = virConnectGetType(conn->conn))) - { + if ((virConnectGetVersion(conn->conn, &hvVer) == 0) && (type = virConnectGetType(conn->conn))) { VIRT_ADD_ASSOC_STRING(return_value, "hypervisor", (char *)type); add_assoc_long(return_value, "hypervisor_major", (long)((hvVer/1000000) % 1000)); add_assoc_long(return_value, "hypervisor_minor", (long)((hvVer/1000) % 1000)); @@ -3410,8 +3407,7 @@ void dec_to_bin(long long decimal, char *binary) decimal = -decimal; neg_flag = 1; } - do - { + do { // old_decimal = decimal; remain = decimal % 2; decimal = decimal / 2; @@ -7720,8 +7716,7 @@ PHP_FUNCTION(libvirt_list_domain_snapshots) RETURN_FALSE; } else { array_init(return_value); - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -7833,8 +7828,7 @@ PHP_FUNCTION(libvirt_storagepool_list_volumes) array_init(return_value); if ((count != expectedcount) || (count<0)) RETURN_FALSE; - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -8709,8 +8703,7 @@ PHP_FUNCTION(libvirt_list_storagepools) } array_init(return_value); - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -8726,8 +8719,7 @@ PHP_FUNCTION(libvirt_list_storagepools) RETURN_FALSE; } - for (i = 0; i < count; i++) - { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -8763,8 +8755,7 @@ PHP_FUNCTION(libvirt_list_active_storagepools) RETURN_FALSE; } array_init(return_value); - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -8800,8 +8791,7 @@ PHP_FUNCTION(libvirt_list_inactive_storagepools) } array_init(return_value); - for (i = 0; i < count; i++) - { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -8839,8 +8829,7 @@ PHP_FUNCTION(libvirt_list_domains) DPRINTF("%s: virConnectListDomains returned %d domains\n", PHPFUNC, count); array_init(return_value); - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { domain=virDomainLookupByID(conn->conn, ids[i]); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, domain, 1 TSRMLS_CC); if (domain != NULL) { @@ -8878,8 +8867,7 @@ PHP_FUNCTION(libvirt_list_domains) RETURN_FALSE; } - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); DPRINTF("%s: Found inactive domain %s\n", PHPFUNC, names[i]); free(names[i]); @@ -8924,8 +8912,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) RETURN_FALSE; } array_init(return_value); - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { domain=virDomainLookupByID(conn->conn, ids[i]); if (domain != NULL) { res_domain= (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -8955,8 +8942,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) efree(names); RETURN_FALSE; } - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { domain=virDomainLookupByName(conn->conn, names[i]); if (domain != NULL) { res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -9007,8 +8993,7 @@ PHP_FUNCTION(libvirt_list_active_domain_ids) RETURN_FALSE; } array_init(return_value); - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { add_next_index_long(return_value, ids[i]); } efree(ids); @@ -9045,11 +9030,9 @@ PHP_FUNCTION(libvirt_list_active_domains) } array_init(return_value); - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { domain=virDomainLookupByID(conn->conn, ids[i]); - if (domain != NULL) - { + if (domain != NULL) { if (!(name = virDomainGetName(domain))) { efree(ids); RETURN_FALSE; @@ -9093,8 +9076,7 @@ PHP_FUNCTION(libvirt_list_inactive_domains) } array_init(return_value); - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9133,8 +9115,7 @@ PHP_FUNCTION(libvirt_list_networks) RETURN_FALSE; } - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9153,8 +9134,7 @@ PHP_FUNCTION(libvirt_list_networks) RETURN_FALSE; } - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9198,8 +9178,7 @@ PHP_FUNCTION(libvirt_list_nodedevs) } array_init(return_value); - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9270,8 +9249,7 @@ PHP_FUNCTION(libvirt_nodedev_capabilities) if ((count != expectedcount) || (count<0)) RETURN_FALSE; array_init(return_value); - for (i=0;i<count;i++) - { + for (i=0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } -- 2.7.3

Trailing statements after 'if' should be on next line Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 266 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 176 insertions(+), 90 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index eb717fd..e12c3ae 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -60,9 +60,9 @@ typedef size_t strsize_t; #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ - if ((_state = (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le)) == NULL) { \ - RETURN_FALSE; \ - } + if ((_state = (_type)zend_fetch_resource(Z_RES_P(*_zval), _name, _le)) == NULL) { \ + RETURN_FALSE; \ + } #define VIRT_RETVAL_STRING(_str) \ RETVAL_STRING(_str) @@ -104,7 +104,7 @@ typedef long zend_long; typedef unsigned long zend_ulong; #define VIRT_FETCH_RESOURCE(_state, _type, _zval, _name, _le) \ - ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le); + ZEND_FETCH_RESOURCE(_state, _type, _zval, -1, _name, _le); #define VIRT_RETVAL_STRING(_str) \ RETVAL_STRING(_str, 1) @@ -834,8 +834,10 @@ PHP_RINIT_FUNCTION(libvirt) /* PHP request destruction */ PHP_RSHUTDOWN_FUNCTION(libvirt) { - if (LIBVIRT_G(last_error) != NULL) efree(LIBVIRT_G(last_error)); - if (LIBVIRT_G(vnc_location) != NULL) efree(LIBVIRT_G(vnc_location)); + if (LIBVIRT_G(last_error) != NULL) + efree(LIBVIRT_G(last_error)); + if (LIBVIRT_G(vnc_location) != NULL) + efree(LIBVIRT_G(vnc_location)); return SUCCESS; } @@ -2052,7 +2054,8 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection);\ -if ((conn == NULL) || (conn->conn == NULL)) RETURN_FALSE;\ +if ((conn == NULL) || (conn->conn == NULL)) \ + RETURN_FALSE;\ #define GET_DOMAIN_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2062,7 +2065,8 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(domain, php_libvirt_domain*, &zdomain, PHP_LIBVIRT_DOMAIN_RES_NAME, le_libvirt_domain);\ -if ((domain == NULL) || (domain->domain == NULL)) RETURN_FALSE;\ +if ((domain == NULL) || (domain->domain == NULL)) \ + RETURN_FALSE;\ #define GET_NETWORK_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2072,7 +2076,8 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(network, php_libvirt_network*, &znetwork, PHP_LIBVIRT_NETWORK_RES_NAME, le_libvirt_network);\ -if ((network == NULL) || (network->network == NULL)) RETURN_FALSE;\ +if ((network == NULL) || (network->network == NULL)) \ + RETURN_FALSE;\ #define GET_NODEDEV_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2082,7 +2087,8 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(nodedev, php_libvirt_nodedev*, &znodedev, PHP_LIBVIRT_NODEDEV_RES_NAME, le_libvirt_nodedev);\ -if ((nodedev == NULL) || (nodedev->device == NULL)) RETURN_FALSE;\ +if ((nodedev == NULL) || (nodedev->device == NULL)) \ + RETURN_FALSE;\ #define GET_STORAGEPOOL_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2092,7 +2098,8 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool);\ -if ((pool == NULL) || (pool->pool == NULL)) RETURN_FALSE;\ +if ((pool == NULL) || (pool->pool == NULL)) \ + RETURN_FALSE;\ #define GET_VOLUME_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2102,7 +2109,8 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);\ -if ((volume == NULL) || (volume->volume == NULL)) RETURN_FALSE;\ +if ((volume == NULL) || (volume->volume == NULL)) \ + RETURN_FALSE;\ #define GET_SNAPSHOT_FROM_ARGS(args, ...) \ reset_error(TSRMLS_C); \ @@ -2112,7 +2120,8 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILU }\ \ VIRT_FETCH_RESOURCE(snapshot, php_libvirt_snapshot*, &zsnapshot, PHP_LIBVIRT_SNAPSHOT_RES_NAME, le_libvirt_snapshot);\ -if ((snapshot == NULL) || (snapshot->snapshot == NULL)) RETURN_FALSE;\ +if ((snapshot == NULL) || (snapshot->snapshot == NULL)) \ + RETURN_FALSE;\ #define LONGLONG_INIT \ char tmpnumber[64] @@ -2185,7 +2194,8 @@ static int libvirt_virConnectCredType[] = { */ PHP_FUNCTION(libvirt_get_last_error) { - if (LIBVIRT_G (last_error) == NULL) RETURN_NULL(); + if (LIBVIRT_G (last_error) == NULL) + RETURN_NULL(); VIRT_RETURN_STRING(LIBVIRT_G(last_error)); } @@ -2323,7 +2333,8 @@ PHP_FUNCTION(libvirt_node_get_info) retval=virNodeGetInfo (conn->conn, &info); DPRINTF("%s: virNodeGetInfo returned %d\n", PHPFUNC, retval); - if (retval == -1) RETURN_FALSE; + if (retval == -1) + RETURN_FALSE; array_init(return_value); VIRT_ADD_ASSOC_STRING(return_value, "model", info.model); @@ -2875,7 +2886,8 @@ PHP_FUNCTION(libvirt_connect_get_uri) GET_CONNECTION_FROM_ARGS("r", &zconn); uri = virConnectGetURI(conn->conn); DPRINTF("%s: virConnectGetURI returned %s\n", PHPFUNC, uri); - if (uri == NULL) RETURN_FALSE; + if (uri == NULL) + RETURN_FALSE; VIRT_RETVAL_STRING(uri); free(uri); @@ -2898,7 +2910,8 @@ PHP_FUNCTION(libvirt_connect_get_hostname) hostname=virConnectGetHostname(conn->conn); DPRINTF("%s: virConnectGetHostname returned %s\n", PHPFUNC, hostname); - if (hostname == NULL) RETURN_FALSE; + if (hostname == NULL) + RETURN_FALSE; VIRT_RETVAL_STRING(hostname); free(hostname); @@ -3213,7 +3226,8 @@ PHP_FUNCTION(libvirt_connect_get_sysinfo) GET_CONNECTION_FROM_ARGS("r", &zconn); sysinfo=virConnectGetSysinfo(conn->conn, 0); - if (sysinfo == NULL) RETURN_FALSE; + if (sysinfo == NULL) + RETURN_FALSE; VIRT_RETVAL_STRING(sysinfo); free(sysinfo); @@ -4253,9 +4267,11 @@ PHP_FUNCTION(libvirt_domain_lookup_by_name) php_libvirt_domain *res_domain; GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); - if ((name == NULL) || (name_len<1)) RETURN_FALSE; + if ((name == NULL) || (name_len<1)) + RETURN_FALSE; domain=virDomainLookupByName(conn->conn, name); - if (domain == NULL) RETURN_FALSE; + if (domain == NULL) + RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -4289,9 +4305,11 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid) GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); - if ((uuid == NULL) || (uuid_len<1)) RETURN_FALSE; + if ((uuid == NULL) || (uuid_len<1)) + RETURN_FALSE; domain=virDomainLookupByUUID(conn->conn, uuid); - if (domain == NULL) RETURN_FALSE; + if (domain == NULL) + RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -4329,7 +4347,8 @@ PHP_FUNCTION(libvirt_domain_qemu_agent_command) GET_DOMAIN_FROM_ARGS("rs|ll", &zdomain, &cmd, &cmd_len, &timeout, &flags); ret = virDomainQemuAgentCommand(domain->domain, cmd, timeout, flags); - if (ret == NULL) RETURN_FALSE; + if (ret == NULL) + RETURN_FALSE; VIRT_RETVAL_STRING(ret); free(ret); @@ -4354,9 +4373,11 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string) GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); - if ((uuid == NULL) || (uuid_len<1)) RETURN_FALSE; + if ((uuid == NULL) || (uuid_len<1)) + RETURN_FALSE; domain=virDomainLookupByUUIDString(conn->conn, uuid); - if (domain == NULL) RETURN_FALSE; + if (domain == NULL) + RETURN_FALSE; res_domain =(php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -4388,7 +4409,8 @@ PHP_FUNCTION(libvirt_stream_create) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zconn) == FAILURE) RETURN_FALSE; VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection); - if ((conn == NULL)||(conn->conn == NULL))RETURN_FALSE; + if ((conn == NULL)||(conn->conn == NULL)) + RETURN_FALSE; stream = virStreamNew(conn->conn, 0); if (stream == NULL) { @@ -4424,7 +4446,8 @@ PHP_FUNCTION(libvirt_stream_close) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL)) + RETURN_LONG(retval); retval = virStreamFree(stream->stream); if (retval != 0) { @@ -4452,7 +4475,8 @@ PHP_FUNCTION(libvirt_stream_abort) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL)) + RETURN_LONG(retval); retval = virStreamAbort(stream->stream); if (retval != 0) { @@ -4478,7 +4502,8 @@ PHP_FUNCTION(libvirt_stream_finish) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL)) + RETURN_LONG(retval); retval = virStreamFinish(stream->stream); if (retval != 0) { @@ -4508,7 +4533,8 @@ PHP_FUNCTION(libvirt_stream_recv) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL)) + RETURN_LONG(retval); recv_buf = emalloc(length + 1); memset(recv_buf, 0, length + 1); @@ -4557,7 +4583,8 @@ PHP_FUNCTION(libvirt_stream_send) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL)) + RETURN_LONG(retval); cstr = Z_STRVAL_P(zbuf); //cstrlen = Z_STRLEN_P(zbuf); @@ -4590,7 +4617,8 @@ PHP_FUNCTION(libvirt_domain_lookup_by_id) GET_CONNECTION_FROM_ARGS("rl", &zconn, &id); domain=virDomainLookupByID(conn->conn, (int)id); - if (domain == NULL) RETURN_FALSE; + if (domain == NULL) + RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -4625,7 +4653,8 @@ PHP_FUNCTION(libvirt_domain_get_name) name = virDomainGetName(domain->domain); DPRINTF("%s: virDomainGetName(%p) returned %s\n", PHPFUNC, domain->domain, name); - if (name == NULL) RETURN_FALSE; + if (name == NULL) + RETURN_FALSE; VIRT_RETURN_STRING(name); //we can use the copy mechanism as we need not to free name (we even can not!) } @@ -4649,7 +4678,8 @@ PHP_FUNCTION(libvirt_domain_get_uuid_string) uuid = (char *)emalloc(VIR_UUID_STRING_BUFLEN); retval=virDomainGetUUIDString(domain->domain, uuid); DPRINTF("%s: virDomainGetUUIDString(%p) returned %d (%s)\n", PHPFUNC, domain->domain, retval, uuid); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; VIRT_RETVAL_STRING(uuid); efree(uuid); @@ -5181,7 +5211,8 @@ PHP_FUNCTION(libvirt_domain_get_uuid) uuid=(char *)emalloc(VIR_UUID_BUFLEN); retval=virDomainGetUUID(domain->domain, (unsigned char *)uuid); DPRINTF("%s: virDomainGetUUID(%p, %p) returned %d\n", PHPFUNC, domain->domain, uuid, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; VIRT_RETVAL_STRING(uuid); efree(uuid); @@ -6439,7 +6470,8 @@ PHP_FUNCTION(libvirt_domain_get_info) retval=virDomainGetInfo(domain->domain, &domainInfo); DPRINTF("%s: virDomainGetInfo(%p) returned %d\n", PHPFUNC, domain->domain, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; array_init(return_value); add_assoc_long(return_value, "maxMem", domainInfo.maxMem); @@ -6466,7 +6498,8 @@ PHP_FUNCTION(libvirt_domain_create) retval=virDomainCreate(domain->domain); DPRINTF("%s: virDomainCreate(%p) returned %d\n", PHPFUNC, domain->domain, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; RETURN_TRUE; } @@ -6487,7 +6520,8 @@ PHP_FUNCTION(libvirt_domain_destroy) retval=virDomainDestroy(domain->domain); DPRINTF("%s: virDomainDestroy(%p) returned %d\n", PHPFUNC, domain->domain, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; RETURN_TRUE; } @@ -6508,7 +6542,8 @@ PHP_FUNCTION(libvirt_domain_resume) retval=virDomainResume(domain->domain); DPRINTF("%s: virDomainResume(%p) returned %d\n", PHPFUNC, domain->domain, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; RETURN_TRUE; } @@ -6532,7 +6567,8 @@ PHP_FUNCTION(libvirt_domain_core_dump) retval=virDomainCoreDump(domain->domain, to, 0); DPRINTF("%s: virDomainCoreDump(%p, %s, 0) returned %d\n", PHPFUNC, domain->domain, to, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; RETURN_TRUE; } @@ -6553,7 +6589,8 @@ PHP_FUNCTION(libvirt_domain_shutdown) retval=virDomainShutdown(domain->domain); DPRINTF("%s: virDomainShutdown(%p) returned %d\n", PHPFUNC, domain->domain, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; RETURN_TRUE; } @@ -6573,7 +6610,8 @@ PHP_FUNCTION(libvirt_domain_managedsave) GET_DOMAIN_FROM_ARGS("r", &zdomain); retval=virDomainManagedSave(domain->domain, 0); DPRINTF("%s: virDomainManagedSave(%p) returned %d\n", PHPFUNC, domain->domain, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; RETURN_TRUE; } @@ -6594,7 +6632,8 @@ PHP_FUNCTION(libvirt_domain_suspend) retval=virDomainSuspend(domain->domain); DPRINTF("%s: virDomainSuspend(%p) returned %d\n", PHPFUNC, domain->domain, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; RETURN_TRUE; } @@ -6615,7 +6654,8 @@ PHP_FUNCTION(libvirt_domain_undefine) retval=virDomainUndefine(domain->domain); DPRINTF("%s: virDomainUndefine(%p) returned %d\n", PHPFUNC, domain->domain, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; RETURN_TRUE; } @@ -6638,7 +6678,8 @@ PHP_FUNCTION(libvirt_domain_reboot) retval=virDomainReboot(domain->domain, flags); DPRINTF("%s: virDomainReboot(%p) returned %d\n", PHPFUNC, domain->domain, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; RETURN_TRUE; } @@ -6662,7 +6703,8 @@ PHP_FUNCTION(libvirt_domain_define_xml) GET_CONNECTION_FROM_ARGS("rs", &zconn, &xml, &xml_len); domain=virDomainDefineXML(conn->conn, xml); - if (domain == NULL) RETURN_FALSE; + if (domain == NULL) + RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -6699,7 +6741,8 @@ PHP_FUNCTION(libvirt_domain_create_xml) domain=virDomainCreateXML(conn->conn, xml, flags); DPRINTF("%s: virDomainCreateXML(%p, <xml>, 0) returned %p\n", PHPFUNC, conn->conn, domain); - if (domain == NULL) RETURN_FALSE; + if (domain == NULL) + RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; @@ -6807,7 +6850,8 @@ PHP_FUNCTION(libvirt_domain_memory_peek) } buff=(char *)emalloc(size); retval=virDomainMemoryPeek(domain->domain, start, size, buff, flags); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; VIRT_RETVAL_STRINGL(buff, size); efree(buff); } @@ -6834,7 +6878,8 @@ PHP_FUNCTION(libvirt_domain_memory_stats) retval=virDomainMemoryStats(domain->domain, stats, VIR_DOMAIN_MEMORY_STAT_NR, flags); DPRINTF("%s: virDomainMemoryStats(%p...) returned %d\n", PHPFUNC, domain->domain, retval); - if (retval == -1) RETURN_FALSE; + if (retval == -1) + RETURN_FALSE; LONGLONG_INIT; array_init(return_value); for (i=0;i<retval;i++) @@ -6891,7 +6936,8 @@ PHP_FUNCTION(libvirt_domain_block_stats) retval=virDomainBlockStats(domain->domain, path, &stats, sizeof stats); DPRINTF("%s: virDomainBlockStats(%p,%s,<stats>,<size>) returned %d\n", PHPFUNC, domain->domain, path, retval); - if (retval == -1) RETURN_FALSE; + if (retval == -1) + RETURN_FALSE; array_init(return_value); LONGLONG_INIT; @@ -6925,7 +6971,8 @@ PHP_FUNCTION(libvirt_domain_block_resize) GET_DOMAIN_FROM_ARGS("rsl|l", &zdomain, &path, &path_len, &size, &flags); retval=virDomainBlockResize(domain->domain, path, size, flags); - if (retval == -1) RETURN_FALSE; + if (retval == -1) + RETURN_FALSE; RETURN_TRUE; } @@ -6959,7 +7006,8 @@ PHP_FUNCTION(libvirt_domain_block_commit) GET_DOMAIN_FROM_ARGS("rsssll", &zdomain, &disk, &disk_len, &base, &base_len, &top, &top_len, &bandwidth, &flags); retval=virDomainBlockCommit(domain->domain, disk, base, top, bandwidth, flags); - if (retval == -1) RETURN_FALSE; + if (retval == -1) + RETURN_FALSE; RETURN_TRUE; } @@ -7018,7 +7066,8 @@ PHP_FUNCTION(libvirt_domain_block_job_abort) GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &path, &path_len, &flags); retval=virDomainBlockJobAbort(domain->domain, path, flags); - if (retval == -1) RETURN_FALSE; + if (retval == -1) + RETURN_FALSE; RETURN_TRUE; } @@ -7046,7 +7095,8 @@ PHP_FUNCTION(libvirt_domain_block_job_set_speed) GET_DOMAIN_FROM_ARGS("rsl|l", &zdomain, &path, &path_len, &bandwidth, &flags); retval=virDomainBlockJobSetSpeed(domain->domain, path, bandwidth, flags); - if (retval == -1) RETURN_FALSE; + if (retval == -1) + RETURN_FALSE; RETURN_TRUE; } @@ -7297,7 +7347,8 @@ PHP_FUNCTION(libvirt_domain_interface_stats) retval=virDomainInterfaceStats(domain->domain, path, &stats, sizeof stats); DPRINTF("%s: virDomainInterfaceStats(%p,%s,<stats>,<size>) returned %d\n", PHPFUNC, domain->domain, path, retval); - if (retval == -1) RETURN_FALSE; + if (retval == -1) + RETURN_FALSE; array_init(return_value); LONGLONG_INIT; @@ -7329,7 +7380,8 @@ PHP_FUNCTION(libvirt_domain_get_connect) GET_DOMAIN_FROM_ARGS("r", &zdomain); conn= domain->conn; - if (conn->conn == NULL) RETURN_FALSE; + if (conn->conn == NULL) + RETURN_FALSE; #if PHP_MAJOR_VERSION >= 7 ZVAL_RES(return_value, conn->resource_id); #else @@ -7368,7 +7420,8 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri) retval=virDomainMigrateToURI(domain->domain, duri, flags, dname, bandwidth); DPRINTF("%s: virDomainMigrateToURI() returned %d\n", PHPFUNC, retval); - if (retval == 0) RETURN_TRUE; + if (retval == 0) + RETURN_TRUE; RETURN_FALSE; } @@ -7413,15 +7466,20 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri2) GET_DOMAIN_FROM_ARGS("r|ssslsl", &zdomain, &dconnuri, &dconnuri_len, &miguri, &miguri_len, &dxml, &dxml_len, &flags, &dname, &dname_len, &bandwidth); // set to NULL if empty string - if (dconnuri_len == 0) dconnuri=NULL; - if (miguri_len == 0) miguri=NULL; - if (dxml_len == 0) dxml=NULL; - if (dname_len == 0) dname=NULL; + if (dconnuri_len == 0) + dconnuri=NULL; + if (miguri_len == 0) + miguri=NULL; + if (dxml_len == 0) + dxml=NULL; + if (dname_len == 0) + dname=NULL; retval=virDomainMigrateToURI2(domain->domain, dconnuri, miguri, dxml, flags, dname, bandwidth); DPRINTF("%s: virDomainMigrateToURI2() returned %d\n", PHPFUNC, retval); - if (retval == 0) RETURN_TRUE; + if (retval == 0) + RETURN_TRUE; RETURN_FALSE; } @@ -7468,7 +7526,8 @@ PHP_FUNCTION(libvirt_domain_migrate) } destdomain=virDomainMigrate(domain->domain, dconn->conn, flags, dname, NULL, bandwidth); - if (destdomain == NULL) RETURN_FALSE; + if (destdomain == NULL) + RETURN_FALSE; res_domain= (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = destdomain; @@ -7501,7 +7560,8 @@ PHP_FUNCTION(libvirt_domain_get_job_info) GET_DOMAIN_FROM_ARGS("r", &zdomain); retval=virDomainGetJobInfo(domain->domain, &jobinfo); - if (retval == -1) RETURN_FALSE; + if (retval == -1) + RETURN_FALSE; array_init(return_value); LONGLONG_INIT; @@ -7537,7 +7597,8 @@ PHP_FUNCTION(libvirt_domain_has_current_snapshot) GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags); retval=virDomainHasCurrentSnapshot(domain->domain, flags); - if (retval <= 0) RETURN_FALSE; + if (retval <= 0) + RETURN_FALSE; RETURN_TRUE; } @@ -7562,9 +7623,11 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name) GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &name, &name_len, &flags); - if ((name == NULL) || (name_len<1)) RETURN_FALSE; + if ((name == NULL) || (name_len<1)) + RETURN_FALSE; snapshot=virDomainSnapshotLookupByName(domain->domain, name, flags); - if (snapshot == NULL) RETURN_FALSE; + if (snapshot == NULL) + RETURN_FALSE; res_snapshot = (php_libvirt_snapshot *)emalloc(sizeof(php_libvirt_snapshot)); res_snapshot->domain = domain; @@ -7599,7 +7662,8 @@ PHP_FUNCTION(libvirt_domain_snapshot_create) snapshot=virDomainSnapshotCreateXML(domain->domain, "<domainsnapshot/>", flags); DPRINTF("%s: virDomainSnapshotCreateXML(%p, <xml>) returned %p\n", PHPFUNC, domain->domain, snapshot); - if (snapshot == NULL) RETURN_FALSE; + if (snapshot == NULL) + RETURN_FALSE; res_snapshot = (php_libvirt_snapshot *)emalloc(sizeof(php_libvirt_snapshot)); res_snapshot->domain = domain; @@ -7632,7 +7696,8 @@ PHP_FUNCTION(libvirt_domain_snapshot_get_xml) GET_SNAPSHOT_FROM_ARGS("r|l", &zsnapshot, &flags); xml = virDomainSnapshotGetXMLDesc(snapshot->snapshot, flags); - if (xml == NULL) RETURN_FALSE; + if (xml == NULL) + RETURN_FALSE; VIRT_RETVAL_STRING(xml); free(xml); @@ -7657,7 +7722,8 @@ PHP_FUNCTION(libvirt_domain_snapshot_revert) ret = virDomainRevertToSnapshot(snapshot->snapshot, flags); DPRINTF("%s: virDomainRevertToSnapshot(%p, 0) returned %d\n", PHPFUNC, snapshot->snapshot, ret); - if (ret == -1) RETURN_FALSE; + if (ret == -1) + RETURN_FALSE; RETURN_TRUE; } @@ -7680,7 +7746,8 @@ PHP_FUNCTION(libvirt_domain_snapshot_delete) retval = virDomainSnapshotDelete(snapshot->snapshot, flags); DPRINTF("%s: virDomainSnapshotDelete(%p, %d) returned %d\n", PHPFUNC, snapshot->snapshot, (int) flags, retval); - if (retval == -1) RETURN_FALSE; + if (retval == -1) + RETURN_FALSE; RETURN_TRUE; } @@ -7745,10 +7812,12 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_name) GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); - if ((name == NULL) || (name_len<1)) RETURN_FALSE; + if ((name == NULL) || (name_len<1)) + RETURN_FALSE; pool=virStoragePoolLookupByName(conn->conn, name); DPRINTF("%s: virStoragePoolLookupByName(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, pool); - if (pool == NULL) RETURN_FALSE; + if (pool == NULL) + RETURN_FALSE; res_pool = (php_libvirt_storagepool *)emalloc(sizeof(php_libvirt_storagepool)); res_pool->pool = pool; @@ -7827,7 +7896,8 @@ PHP_FUNCTION(libvirt_storagepool_list_volumes) DPRINTF("%s: virStoragePoolListVolumes(%p,%p,%d) returned %d\n", PHPFUNC, pool->pool, names, expectedcount, count); array_init(return_value); - if ((count != expectedcount) || (count<0)) RETURN_FALSE; + if ((count != expectedcount) || (count<0)) + RETURN_FALSE; for (i=0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); @@ -7854,7 +7924,8 @@ PHP_FUNCTION(libvirt_storagepool_get_info) retval=virStoragePoolGetInfo(pool->pool, &poolInfo); DPRINTF("%s: virStoragePoolGetInfo(%p, <info>) returned %d\n", PHPFUNC, pool->pool, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; array_init(return_value); @@ -7884,11 +7955,13 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name) virStorageVolPtr volume=NULL; GET_STORAGEPOOL_FROM_ARGS("rs", &zpool, &name, &name_len); - if ((name == NULL) || (name_len<1)) RETURN_FALSE; + if ((name == NULL) || (name_len<1)) + RETURN_FALSE; volume=virStorageVolLookupByName(pool->pool, name); DPRINTF("%s: virStorageVolLookupByName(%p, %s) returned %p\n", PHPFUNC, pool->pool, name, volume); - if (volume == NULL) RETURN_FALSE; + if (volume == NULL) + RETURN_FALSE; res_volume = (php_libvirt_volume *)emalloc(sizeof(php_libvirt_volume)); res_volume->volume = volume; @@ -7921,7 +7994,8 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_path) virStorageVolPtr volume=NULL; GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); - if ((name == NULL) || (name_len<1)) RETURN_FALSE; + if ((name == NULL) || (name_len<1)) + RETURN_FALSE; volume=virStorageVolLookupByPath(conn->conn, name); DPRINTF("%s: virStorageVolLookupByPath(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, volume); @@ -7960,7 +8034,8 @@ PHP_FUNCTION(libvirt_storagevolume_get_name) retval = virStorageVolGetName(volume->volume); DPRINTF("%s: virStorageVolGetName(%p) returned %s\n", PHPFUNC, volume->volume, retval); - if (retval == NULL) RETURN_FALSE; + if (retval == NULL) + RETURN_FALSE; VIRT_RETURN_STRING(retval); } @@ -7982,7 +8057,8 @@ PHP_FUNCTION(libvirt_storagevolume_get_path) retval = virStorageVolGetPath(volume->volume); DPRINTF("%s: virStorageVolGetPath(%p) returned %s\n", PHPFUNC, volume->volume, retval); - if (retval == NULL) RETURN_FALSE; + if (retval == NULL) + RETURN_FALSE; VIRT_RETVAL_STRING(retval); free(retval); @@ -8006,7 +8082,8 @@ PHP_FUNCTION(libvirt_storagevolume_get_info) retval=virStorageVolGetInfo(volume->volume, &volumeInfo); DPRINTF("%s: virStorageVolGetInfo(%p, <info>) returned %d\n", PHPFUNC, volume->volume, retval); - if (retval != 0) RETURN_FALSE; + if (retval != 0) + RETURN_FALSE; array_init(return_value); LONGLONG_INIT; @@ -8081,7 +8158,8 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml) volume=virStorageVolCreateXML(pool->pool, xml, flags); DPRINTF("%s: virStorageVolCreateXML(%p, <xml>, 0) returned %p\n", PHPFUNC, pool->pool, volume); - if (volume == NULL) RETURN_FALSE; + if (volume == NULL) + RETURN_FALSE; res_volume= (php_libvirt_volume *)emalloc(sizeof(php_libvirt_volume)); res_volume->volume = volume; @@ -8124,14 +8202,17 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) } VIRT_FETCH_RESOURCE(pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool); - if ((pool == NULL)||(pool->pool == NULL))RETURN_FALSE; + if ((pool == NULL)||(pool->pool == NULL)) + RETURN_FALSE; VIRT_FETCH_RESOURCE(pl_volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); - if ((pl_volume == NULL)||(pl_volume->volume == NULL))RETURN_FALSE; + if ((pl_volume == NULL)||(pl_volume->volume == NULL)) + RETURN_FALSE; resource_change_counter(INT_RESOURCE_VOLUME, NULL, pl_volume->volume, 1 TSRMLS_CC); volume=virStorageVolCreateXMLFrom(pool->pool, xml, pl_volume->volume, 0); DPRINTF("%s: virStorageVolCreateXMLFrom(%p, <xml>, %p, 0) returned %p\n", PHPFUNC, pool->pool, pl_volume->volume, volume); - if (volume == NULL) RETURN_FALSE; + if (volume == NULL) + RETURN_FALSE; res_volume = (php_libvirt_volume *)emalloc(sizeof(php_libvirt_volume)); res_volume->volume = volume; @@ -8227,9 +8308,11 @@ PHP_FUNCTION(libvirt_storagevolume_download) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); - if ((volume == NULL)||(volume->volume == NULL))RETURN_LONG(retval); + if ((volume == NULL)||(volume->volume == NULL)) + RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL)) + RETURN_LONG(retval); retval = virStorageVolDownload(volume->volume, stream->stream, offset, length, flags); DPRINTF("%s: virStorageVolDownload(%p, %p, %d, %d, %d) returned %d\n", PHPFUNC, volume->volume, stream->stream, (int) offset, (int) length, (int) flags, retval); @@ -8267,9 +8350,11 @@ PHP_FUNCTION(libvirt_storagevolume_upload) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); - if ((volume == NULL)||(volume->volume == NULL))RETURN_LONG(retval); + if ((volume == NULL)||(volume->volume == NULL)) + RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL))RETURN_LONG(retval); + if ((stream == NULL)||(stream->stream == NULL)) + RETURN_LONG(retval); retval = virStorageVolUpload(volume->volume, stream->stream, offset, length, flags); DPRINTF("%s: virStorageVolUpload(%p, %p, %d, %d, %d) returned %d\n", PHPFUNC, volume->volume, stream->stream, (int) offset, (int) length, (int) flags, retval); @@ -9246,7 +9331,8 @@ PHP_FUNCTION(libvirt_nodedev_capabilities) RETURN_FALSE; names=(char **)emalloc(expectedcount*sizeof(char *)); count=virNodeDeviceListCaps(nodedev->device, names, expectedcount); - if ((count != expectedcount) || (count<0)) RETURN_FALSE; + if ((count != expectedcount) || (count<0)) + RETURN_FALSE; array_init(return_value); for (i=0;i<count;i++) { -- 2.7.3

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 742 +++++++++++++++++++++++++++--------------------------- 1 file changed, 371 insertions(+), 371 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index e12c3ae..dea608e 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -1177,7 +1177,7 @@ void set_error(char *msg TSRMLS_DC) } php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", msg); - LIBVIRT_G(last_error)=estrndup(msg, strlen(msg)); + LIBVIRT_G(last_error) = estrndup(msg, strlen(msg)); } /* @@ -1197,7 +1197,7 @@ void set_vnc_location(char *msg TSRMLS_DC) return; } - LIBVIRT_G(vnc_location)=estrndup(msg, strlen(msg)); + LIBVIRT_G(vnc_location) = estrndup(msg, strlen(msg)); DPRINTF("set_vnc_location: VNC server location set to '%s'\n", LIBVIRT_G(vnc_location)); } @@ -1456,7 +1456,7 @@ int is_local_connection(virConnectPtr conn) char *hostname; char name[1024]; - hostname=virConnectGetHostname(conn); + hostname = virConnectGetHostname(conn); gethostname(name, 1024); ret = strcmp(name, hostname) == 0; free(hostname); @@ -1491,7 +1491,7 @@ static void php_libvirt_connection_dtor( DPRINTF("%s: virConnectClose(%p) completed successfully\n", __FUNCTION__, conn->conn); resource_change_counter(INT_RESOURCE_CONNECTION, NULL, conn->conn, 0 TSRMLS_CC); } - conn->conn=NULL; + conn->conn = NULL; } efree(conn); } @@ -1512,7 +1512,7 @@ static void php_libvirt_domain_dtor( if (domain != NULL) { if (domain->domain != NULL) { if (!check_resource_allocation(domain->conn->conn, INT_RESOURCE_DOMAIN, domain->domain TSRMLS_CC)) { - domain->domain=NULL; + domain->domain = NULL; efree(domain); return; } @@ -1525,7 +1525,7 @@ static void php_libvirt_domain_dtor( DPRINTF("%s: virDomainFree(%p) completed successfully\n", __FUNCTION__, domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, domain->conn->conn, domain->domain, 0 TSRMLS_CC); } - domain->domain=NULL; + domain->domain = NULL; } efree(domain); } @@ -1546,7 +1546,7 @@ static void php_libvirt_stream_dtor( if (stream != NULL) { if (stream->stream != NULL) { if (!check_resource_allocation(NULL, INT_RESOURCE_STREAM, stream->stream TSRMLS_CC)) { - stream->stream=NULL; + stream->stream = NULL; efree(stream); return; } @@ -1558,7 +1558,7 @@ static void php_libvirt_stream_dtor( DPRINTF("%s: virStreamFree(%p) completed successfully\n", __FUNCTION__, stream->stream); resource_change_counter(INT_RESOURCE_STREAM, NULL, stream->stream, 0 TSRMLS_CC); } - stream->stream=NULL; + stream->stream = NULL; } efree(stream); } @@ -1579,7 +1579,7 @@ static void php_libvirt_storagepool_dtor( if (pool != NULL) { if (pool->pool != NULL) { if (!check_resource_allocation(NULL, INT_RESOURCE_STORAGEPOOL, pool->pool TSRMLS_CC)) { - pool->pool=NULL; + pool->pool = NULL; efree(pool); return; } @@ -1591,7 +1591,7 @@ static void php_libvirt_storagepool_dtor( DPRINTF("%s: virStoragePoolFree(%p) completed successfully\n", __FUNCTION__, pool->pool); resource_change_counter(INT_RESOURCE_STORAGEPOOL, NULL, pool->pool, 0 TSRMLS_CC); } - pool->pool=NULL; + pool->pool = NULL; } efree(pool); } @@ -1612,7 +1612,7 @@ static void php_libvirt_volume_dtor( if (volume != NULL) { if (volume->volume != NULL) { if (!check_resource_allocation(NULL, INT_RESOURCE_VOLUME, volume->volume TSRMLS_CC)) { - volume->volume=NULL; + volume->volume = NULL; efree(volume); return; } @@ -1624,7 +1624,7 @@ static void php_libvirt_volume_dtor( DPRINTF("%s: virStorageVolFree(%p) completed successfully\n", __FUNCTION__, volume->volume); resource_change_counter(INT_RESOURCE_VOLUME, NULL, volume->volume, 0 TSRMLS_CC); } - volume->volume=NULL; + volume->volume = NULL; } efree(volume); } @@ -1645,7 +1645,7 @@ static void php_libvirt_network_dtor( if (network != NULL) { if (network->network != NULL) { if (!check_resource_allocation(network->conn->conn, INT_RESOURCE_NETWORK, network->network TSRMLS_CC)) { - network->network=NULL; + network->network = NULL; efree(network); return; } @@ -1657,7 +1657,7 @@ static void php_libvirt_network_dtor( DPRINTF("%s: virNetworkFree(%p) completed successfully\n", __FUNCTION__, network->network); resource_change_counter(INT_RESOURCE_NETWORK, NULL, network->network, 0 TSRMLS_CC); } - network->network=NULL; + network->network = NULL; } efree(network); } @@ -1678,7 +1678,7 @@ static void php_libvirt_nodedev_dtor( if (nodedev != NULL) { if (nodedev->device != NULL) { if (!check_resource_allocation(nodedev->conn->conn, INT_RESOURCE_NODEDEV, nodedev->device TSRMLS_CC)) { - nodedev->device=NULL; + nodedev->device = NULL; efree(nodedev); return; } @@ -1690,7 +1690,7 @@ static void php_libvirt_nodedev_dtor( DPRINTF("%s: virNodeDeviceFree(%p) completed successfully\n", __FUNCTION__, nodedev->device); resource_change_counter(INT_RESOURCE_NODEDEV, nodedev->conn->conn, nodedev->device, 0 TSRMLS_CC); } - nodedev->device=NULL; + nodedev->device = NULL; } efree(nodedev); } @@ -1711,7 +1711,7 @@ static void php_libvirt_snapshot_dtor( if (snapshot != NULL) { if (snapshot->snapshot != NULL) { if (!check_resource_allocation(NULL, INT_RESOURCE_SNAPSHOT, snapshot->snapshot TSRMLS_CC)) { - snapshot->snapshot=NULL; + snapshot->snapshot = NULL; efree(snapshot); return; } @@ -1723,7 +1723,7 @@ static void php_libvirt_snapshot_dtor( DPRINTF("%s: virDomainSnapshotFree(%p) completed successfully\n", __FUNCTION__, snapshot->snapshot); resource_change_counter(INT_RESOURCE_SNAPSHOT, snapshot->domain->conn->conn, snapshot->snapshot, 0 TSRMLS_CC); } - snapshot->snapshot=NULL; + snapshot->snapshot = NULL; } efree(snapshot); } @@ -2157,14 +2157,14 @@ static int libvirt_virConnectAuthCallback(virConnectCredentialPtr cred, unsigned TSRMLS_FETCH(); unsigned int i, j; - php_libvirt_cred_value *creds=(php_libvirt_cred_value*) cbdata; + php_libvirt_cred_value *creds = (php_libvirt_cred_value*) cbdata; for (i = 0; i < (unsigned int)ncred; i++) { DPRINTF("%s: cred %d, type %d, prompt %s challenge %s\n ", __FUNCTION__, i, cred[i].type, cred[i].prompt, cred[i].challenge); if (creds != NULL) for (j = 0; j < (unsigned int)creds[0].count; j++) { if (creds[j].type == cred[i].type) { - cred[i].resultlen=creds[j].resultlen; - cred[i].result=(char *)malloc(creds[j].resultlen + 1); + cred[i].resultlen = creds[j].resultlen; + cred[i].result = (char *)malloc(creds[j].resultlen + 1); memset(cred[i].result, 0, creds[j].resultlen + 1); strncpy(cred[i].result, creds[j].result, creds[j].resultlen); } @@ -2211,18 +2211,18 @@ PHP_FUNCTION(libvirt_get_last_error) PHP_FUNCTION(libvirt_connect) { php_libvirt_connection *conn; - php_libvirt_cred_value *creds=NULL; - zval* zcreds=NULL; + php_libvirt_cred_value *creds = NULL; + zval* zcreds = NULL; zval *data; int i; int j; - int credscount=0; + int credscount = 0; - virConnectAuth libvirt_virConnectAuth= { libvirt_virConnectCredType, sizeof(libvirt_virConnectCredType)/sizeof(int), libvirt_virConnectAuthCallback, NULL}; + virConnectAuth libvirt_virConnectAuth = { libvirt_virConnectCredType, sizeof(libvirt_virConnectCredType)/sizeof(int), libvirt_virConnectAuthCallback, NULL}; - char *url=NULL; - strsize_t url_len=0; - zend_bool readonly=1; + char *url = NULL; + strsize_t url_len = 0; + zend_bool readonly = 1; HashTable *arr_hash; HashPosition pointer; @@ -2254,7 +2254,7 @@ PHP_FUNCTION(libvirt_connect) if ((url == NULL) || (strcasecmp(url, "NULL") == 0)) url = NULL; - conn=(php_libvirt_connection *)emalloc(sizeof(php_libvirt_connection)); + conn = (php_libvirt_connection *)emalloc(sizeof(php_libvirt_connection)); if (zcreds == NULL) { /* connecting without providing authentication */ if (readonly) @@ -2266,9 +2266,9 @@ PHP_FUNCTION(libvirt_connect) arr_hash = Z_ARRVAL_P(zcreds); array_count = zend_hash_num_elements(arr_hash); - credscount=array_count; - creds=(php_libvirt_cred_value *)emalloc(credscount * sizeof(php_libvirt_cred_value)); - j=0; + credscount = array_count; + creds = (php_libvirt_cred_value *)emalloc(credscount * sizeof(php_libvirt_cred_value)); + j = 0; /* parse the input Array and create list of credentials. The list (array) is passed to callback function. */ VIRT_FOREACH(arr_hash, pointer, data) { if (Z_TYPE_P(data) == IS_STRING) { @@ -2279,7 +2279,7 @@ PHP_FUNCTION(libvirt_connect) PHPWRITE(info.name, info.length); } else { DPRINTF("%s: credentials index %d\n", PHPFUNC, (int)index); - creds[j].type=index; + creds[j].type = index; creds[j].result = (char *)emalloc(Z_STRLEN_P(data) + 1); memset(creds[j].result, 0, Z_STRLEN_P(data) + 1); creds[j].resultlen = Z_STRLEN_P(data); @@ -2289,10 +2289,10 @@ PHP_FUNCTION(libvirt_connect) } } VIRT_FOREACH_END(); DPRINTF("%s: Found %d elements for credentials\n", PHPFUNC, j); - creds[0].count=j; + creds[0].count = j; libvirt_virConnectAuth.cbdata = (void*)creds; conn->conn = virConnectOpenAuth(url, &libvirt_virConnectAuth, readonly ? VIR_CONNECT_RO : 0); - for (i=0;i < creds[0].count;i++) + for (i = 0;i < creds[0].count;i++) efree(creds[i].result); efree(creds); } @@ -2325,13 +2325,13 @@ PHP_FUNCTION(libvirt_connect) PHP_FUNCTION(libvirt_node_get_info) { virNodeInfo info; - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; int retval; GET_CONNECTION_FROM_ARGS("r", &zconn); - retval=virNodeGetInfo (conn->conn, &info); + retval = virNodeGetInfo (conn->conn, &info); DPRINTF("%s: virNodeGetInfo returned %d\n", PHPFUNC, retval); if (retval == -1) RETURN_FALSE; @@ -2357,7 +2357,7 @@ PHP_FUNCTION(libvirt_node_get_info) */ PHP_FUNCTION(libvirt_node_get_cpu_stats) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; int cpuNum = VIR_NODE_CPU_STATS_ALL_CPUS; virNodeCPUStatsPtr params; @@ -2458,7 +2458,7 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats) */ PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; virNodeCPUStatsPtr params; virNodeInfo info; @@ -2576,7 +2576,7 @@ PHP_FUNCTION(libvirt_node_get_cpu_stats_for_each_cpu) */ PHP_FUNCTION(libvirt_node_get_mem_stats) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; int memNum = VIR_NODE_MEMORY_STATS_ALL_CELLS; virNodeMemoryStatsPtr params; @@ -2902,13 +2902,13 @@ PHP_FUNCTION(libvirt_connect_get_uri) */ PHP_FUNCTION(libvirt_connect_get_hostname) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; char *hostname; GET_CONNECTION_FROM_ARGS("r", &zconn); - hostname=virConnectGetHostname(conn->conn); + hostname = virConnectGetHostname(conn->conn); DPRINTF("%s: virConnectGetHostname returned %s\n", PHPFUNC, hostname); if (hostname == NULL) RETURN_FALSE; @@ -2929,7 +2929,7 @@ PHP_FUNCTION(libvirt_connect_get_hostname) */ PHP_FUNCTION(libvirt_image_create) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; char msg[1024]; char cmd[4096] = { 0 }; @@ -2997,7 +2997,7 @@ PHP_FUNCTION(libvirt_image_create) */ PHP_FUNCTION(libvirt_image_remove) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; char *hostname; char name[1024]; @@ -3013,7 +3013,7 @@ PHP_FUNCTION(libvirt_image_remove) RETURN_FALSE; } - hostname=virConnectGetHostname(conn->conn); + hostname = virConnectGetHostname(conn->conn); #ifndef EXTWIN /* Code should never go there for Windows systems however we need to allow compilation */ @@ -3046,7 +3046,7 @@ PHP_FUNCTION(libvirt_image_remove) */ PHP_FUNCTION(libvirt_connect_get_hypervisor) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; unsigned long hvVer = 0; const char *type = NULL; @@ -3083,7 +3083,7 @@ PHP_FUNCTION(libvirt_connect_get_hypervisor) */ PHP_FUNCTION(libvirt_connect_get_encrypted) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; GET_CONNECTION_FROM_ARGS("r", &zconn); @@ -3101,7 +3101,7 @@ PHP_FUNCTION(libvirt_connect_get_encrypted) */ PHP_FUNCTION(libvirt_connect_get_secure) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; GET_CONNECTION_FROM_ARGS("r", &zconn); @@ -3140,7 +3140,7 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats) if (retval < 0) RETURN_FALSE; - for (i=0; i < retval; i++) { + for (i = 0; i < retval; i++) { #if PHP_MAJOR_VERSION >= 7 zval *arr2, zarr2; arr2 = &zarr2; @@ -3197,7 +3197,7 @@ PHP_FUNCTION(libvirt_connect_get_all_domain_stats) */ PHP_FUNCTION(libvirt_connect_get_maxvcpus) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; const char *type = NULL; @@ -3219,13 +3219,13 @@ PHP_FUNCTION(libvirt_connect_get_maxvcpus) */ PHP_FUNCTION(libvirt_connect_get_sysinfo) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; char *sysinfo; GET_CONNECTION_FROM_ARGS("r", &zconn); - sysinfo=virConnectGetSysinfo(conn->conn, 0); + sysinfo = virConnectGetSysinfo(conn->conn, 0); if (sysinfo == NULL) RETURN_FALSE; @@ -3691,7 +3691,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++) { @@ -3713,7 +3713,7 @@ char *generate_uuid_any() */ char *generate_uuid(virConnectPtr conn TSRMLS_DC) { - virDomainPtr domain=NULL; + virDomainPtr domain = NULL; char *uuid = NULL; int old_error_reporting = EG(error_reporting); EG(error_reporting) = 0; @@ -3768,7 +3768,7 @@ char *get_disk_xml(unsigned long long size, char *path, char *driver, char *bus, return NULL; } - // TODO: implement backing file handling: -o backing_file=RAW_IMG_FILE QCOW_IMG + // TODO: implement backing file handling: -o backing_file = RAW_IMG_FILE QCOW_IMG snprintf(cmd, sizeof(cmd), "%s create -f %s %s %ldM > /dev/null &2>/dev/null", qemu_img_cmd, driver, path, size); #ifndef EXTWIN @@ -4010,7 +4010,7 @@ char *installation_get_xml(int step, virConnectPtr conn, char *name, int memMB, */ PHP_FUNCTION(libvirt_domain_get_counts) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; int count_defined; int count_active; @@ -4259,17 +4259,17 @@ PHP_FUNCTION(libvirt_domain_is_active) */ PHP_FUNCTION(libvirt_domain_lookup_by_name) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; strsize_t name_len; - char *name=NULL; - virDomainPtr domain=NULL; + char *name = NULL; + virDomainPtr domain = NULL; php_libvirt_domain *res_domain; GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); if ((name == NULL) || (name_len<1)) RETURN_FALSE; - domain=virDomainLookupByName(conn->conn, name); + domain = virDomainLookupByName(conn->conn, name); if (domain == NULL) RETURN_FALSE; @@ -4296,24 +4296,24 @@ PHP_FUNCTION(libvirt_domain_lookup_by_name) */ PHP_FUNCTION(libvirt_domain_lookup_by_uuid) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; strsize_t uuid_len; - unsigned char *uuid=NULL; - virDomainPtr domain=NULL; + unsigned char *uuid = NULL; + virDomainPtr domain = NULL; php_libvirt_domain *res_domain; GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); if ((uuid == NULL) || (uuid_len<1)) RETURN_FALSE; - domain=virDomainLookupByUUID(conn->conn, uuid); + domain = virDomainLookupByUUID(conn->conn, uuid); if (domain == NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; - res_domain->conn=conn; + res_domain->conn = conn; DPRINTF("%s: domain UUID = '%s', returning %p\n", PHPFUNC, uuid, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); @@ -4336,7 +4336,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid) */ PHP_FUNCTION(libvirt_domain_qemu_agent_command) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; const char *cmd; strsize_t cmd_len; @@ -4364,22 +4364,22 @@ PHP_FUNCTION(libvirt_domain_qemu_agent_command) */ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; strsize_t uuid_len; - char *uuid=NULL; - virDomainPtr domain=NULL; + char *uuid = NULL; + virDomainPtr domain = NULL; php_libvirt_domain *res_domain; GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); if ((uuid == NULL) || (uuid_len<1)) RETURN_FALSE; - domain=virDomainLookupByUUIDString(conn->conn, uuid); + domain = virDomainLookupByUUIDString(conn->conn, uuid); if (domain == NULL) RETURN_FALSE; - res_domain =(php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); + res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; res_domain->conn = conn; @@ -4401,7 +4401,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string) */ PHP_FUNCTION(libvirt_stream_create) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; virStreamPtr stream = NULL; php_libvirt_stream *res_stream; @@ -4440,7 +4440,7 @@ PHP_FUNCTION(libvirt_stream_create) PHP_FUNCTION(libvirt_stream_close) { zval *zstream; - php_libvirt_stream *stream=NULL; + php_libvirt_stream *stream = NULL; int retval = -1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) @@ -4469,7 +4469,7 @@ PHP_FUNCTION(libvirt_stream_close) PHP_FUNCTION(libvirt_stream_abort) { zval *zstream; - php_libvirt_stream *stream=NULL; + php_libvirt_stream *stream = NULL; int retval = -1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) @@ -4496,7 +4496,7 @@ PHP_FUNCTION(libvirt_stream_abort) PHP_FUNCTION(libvirt_stream_finish) { zval *zstream; - php_libvirt_stream *stream=NULL; + php_libvirt_stream *stream = NULL; int retval = -1; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) @@ -4526,7 +4526,7 @@ PHP_FUNCTION(libvirt_stream_recv) { zval *zstream, *zbuf; char *recv_buf; - php_libvirt_stream *stream=NULL; + php_libvirt_stream *stream = NULL; int retval = -1; zend_long length = 0; @@ -4574,7 +4574,7 @@ PHP_FUNCTION(libvirt_stream_recv) PHP_FUNCTION(libvirt_stream_send) { zval *zstream, *zbuf; - php_libvirt_stream *stream=NULL; + php_libvirt_stream *stream = NULL; int retval = -1; zend_long length = 0; char *cstr; @@ -4608,21 +4608,21 @@ PHP_FUNCTION(libvirt_stream_send) */ PHP_FUNCTION(libvirt_domain_lookup_by_id) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; zend_long id; - virDomainPtr domain=NULL; + virDomainPtr domain = NULL; php_libvirt_domain *res_domain; GET_CONNECTION_FROM_ARGS("rl", &zconn, &id); - domain=virDomainLookupByID(conn->conn, (int)id); + domain = virDomainLookupByID(conn->conn, (int)id); if (domain == NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; - res_domain->conn=conn; + res_domain->conn = conn; DPRINTF("%s: domain id = '%d', returning %p\n", PHPFUNC, (int)id, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); @@ -4642,9 +4642,9 @@ PHP_FUNCTION(libvirt_domain_lookup_by_id) */ PHP_FUNCTION(libvirt_domain_get_name) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; - const char *name=NULL; + const char *name = NULL; GET_DOMAIN_FROM_ARGS("r", &zdomain); @@ -4668,7 +4668,7 @@ PHP_FUNCTION(libvirt_domain_get_name) */ PHP_FUNCTION(libvirt_domain_get_uuid_string) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *uuid; int retval; @@ -4676,7 +4676,7 @@ PHP_FUNCTION(libvirt_domain_get_uuid_string) GET_DOMAIN_FROM_ARGS("r", &zdomain); uuid = (char *)emalloc(VIR_UUID_STRING_BUFLEN); - retval=virDomainGetUUIDString(domain->domain, uuid); + retval = virDomainGetUUIDString(domain->domain, uuid); DPRINTF("%s: virDomainGetUUIDString(%p) returned %d (%s)\n", PHPFUNC, domain->domain, retval, uuid); if (retval != 0) RETURN_FALSE; @@ -4713,7 +4713,7 @@ static int streamSink(virStreamPtr st ATTRIBUTE_UNUSED, */ PHP_FUNCTION(libvirt_domain_get_screenshot_api) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; zend_long screen = 0; int fd = -1; @@ -4811,7 +4811,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot_api) PHP_FUNCTION(libvirt_domain_get_screenshot) { #ifndef EXTWIN - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; pid_t childpid = -1; pid_t w = -1; @@ -4951,7 +4951,7 @@ PHP_FUNCTION(libvirt_domain_get_screenshot) PHP_FUNCTION(libvirt_domain_get_screen_dimensions) { #ifndef EXTWIN - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval = -1; char *tmp = NULL; @@ -5020,7 +5020,7 @@ PHP_FUNCTION(libvirt_domain_get_screen_dimensions) PHP_FUNCTION(libvirt_domain_send_keys) { #ifndef EXTWIN - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval = -1; char *tmp = NULL; @@ -5137,7 +5137,7 @@ PHP_FUNCTION(libvirt_domain_send_key_api) PHP_FUNCTION(libvirt_domain_send_pointer_event) { #ifndef EXTWIN - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval = -1; char *tmp = NULL; @@ -5201,15 +5201,15 @@ PHP_FUNCTION(libvirt_domain_send_pointer_event) PHP_FUNCTION(libvirt_domain_get_uuid) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *uuid; int retval; GET_DOMAIN_FROM_ARGS("r", &zdomain); - uuid=(char *)emalloc(VIR_UUID_BUFLEN); - retval=virDomainGetUUID(domain->domain, (unsigned char *)uuid); + uuid = (char *)emalloc(VIR_UUID_BUFLEN); + retval = virDomainGetUUID(domain->domain, (unsigned char *)uuid); DPRINTF("%s: virDomainGetUUID(%p, %p) returned %d\n", PHPFUNC, domain->domain, uuid, retval); if (retval != 0) RETURN_FALSE; @@ -5228,13 +5228,13 @@ PHP_FUNCTION(libvirt_domain_get_uuid) PHP_FUNCTION(libvirt_domain_get_id) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainGetID(domain->domain); + retval = virDomainGetID(domain->domain); DPRINTF("%s: virDomainGetID(%p) returned %d\n", PHPFUNC, domain->domain, retval); RETURN_LONG(retval); @@ -5250,7 +5250,7 @@ PHP_FUNCTION(libvirt_domain_get_id) PHP_FUNCTION(libvirt_domain_get_next_dev_ids) { long dom, bus, slot, func; - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; GET_DOMAIN_FROM_ARGS("r", &zdomain); @@ -5279,7 +5279,7 @@ PHP_FUNCTION(libvirt_domain_get_next_dev_ids) */ PHP_FUNCTION(libvirt_connect_get_capabilities) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; char *caps; char *xpath = NULL; @@ -5314,7 +5314,7 @@ PHP_FUNCTION(libvirt_connect_get_capabilities) */ PHP_FUNCTION(libvirt_connect_get_emulator) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; char *arch = NULL; strsize_t arch_len; @@ -5345,7 +5345,7 @@ PHP_FUNCTION(libvirt_connect_get_emulator) */ PHP_FUNCTION(libvirt_connect_get_nic_models) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; char *arch = NULL; strsize_t arch_len; @@ -5416,7 +5416,7 @@ PHP_FUNCTION(libvirt_connect_get_nic_models) */ PHP_FUNCTION(libvirt_connect_get_soundhw_models) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; char *arch = NULL; strsize_t arch_len; @@ -5580,16 +5580,16 @@ void parse_array(zval *arr, tVMDisk *disk, tVMNetwork *network) */ PHP_FUNCTION(libvirt_domain_new) { - php_libvirt_connection *conn=NULL; - php_libvirt_domain *res_domain=NULL; - virDomainPtr domain2=NULL; - virDomainPtr domain=NULL; + php_libvirt_connection *conn = NULL; + php_libvirt_domain *res_domain = NULL; + virDomainPtr domain2 = NULL; + virDomainPtr domain = NULL; zval *zconn; char *arch = NULL; strsize_t arch_len; char *tmp; char *name; - strsize_t name_len=0; + strsize_t name_len = 0; // char *emulator; char *iso_image = NULL; strsize_t iso_image_len; @@ -5770,13 +5770,13 @@ PHP_FUNCTION(libvirt_domain_new_get_vnc) */ PHP_FUNCTION(libvirt_domain_get_xml_desc) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *tmp = NULL; char *xml; char *xpath = NULL; strsize_t xpath_len; - zend_long flags=0; + zend_long flags = 0; int retval = -1; GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &xpath, &xpath_len, &flags); @@ -5811,7 +5811,7 @@ PHP_FUNCTION(libvirt_domain_get_xml_desc) */ PHP_FUNCTION(libvirt_domain_get_disk_devices) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *xml; int retval = -1; @@ -5846,7 +5846,7 @@ PHP_FUNCTION(libvirt_domain_get_disk_devices) */ PHP_FUNCTION(libvirt_domain_get_interface_devices) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *xml; int retval = -1; @@ -5884,7 +5884,7 @@ PHP_FUNCTION(libvirt_domain_get_interface_devices) PHP_FUNCTION(libvirt_domain_change_vcpus) { zend_long numCpus, flags = 0; - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; GET_DOMAIN_FROM_ARGS("rl|l", &zdomain, &numCpus, &flags); @@ -5908,7 +5908,7 @@ PHP_FUNCTION(libvirt_domain_change_vcpus) */ PHP_FUNCTION(libvirt_domain_change_memory) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *tmpA = NULL; char *tmp1 = NULL; @@ -5959,7 +5959,7 @@ PHP_FUNCTION(libvirt_domain_change_memory) conn = domain->conn; - dom=virDomainDefineXML(conn->conn, new_xml); + dom = virDomainDefineXML(conn->conn, new_xml); if (dom == NULL) { free(xml); efree(new_xml); @@ -5993,7 +5993,7 @@ PHP_FUNCTION(libvirt_domain_change_memory) */ PHP_FUNCTION(libvirt_domain_change_boot_devices) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *tmpA = NULL; char *tmp1 = NULL; @@ -6043,7 +6043,7 @@ PHP_FUNCTION(libvirt_domain_change_boot_devices) conn = domain->conn; - dom=virDomainDefineXML(conn->conn, new_xml); + dom = virDomainDefineXML(conn->conn, new_xml); if (dom == NULL) { DPRINTF("%s: Function failed, restoring original XML\n", PHPFUNC); free(xml); @@ -6080,7 +6080,7 @@ PHP_FUNCTION(libvirt_domain_change_boot_devices) */ PHP_FUNCTION(libvirt_domain_disk_add) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *xml; char *img = NULL; @@ -6176,7 +6176,7 @@ PHP_FUNCTION(libvirt_domain_disk_add) */ PHP_FUNCTION(libvirt_domain_disk_remove) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *xml; char *dev = NULL; @@ -6249,7 +6249,7 @@ PHP_FUNCTION(libvirt_domain_disk_remove) */ PHP_FUNCTION(libvirt_domain_nic_add) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *xml; char *mac = NULL; @@ -6342,7 +6342,7 @@ PHP_FUNCTION(libvirt_domain_nic_add) */ PHP_FUNCTION(libvirt_domain_nic_remove) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *xml; char *mac = NULL; @@ -6461,14 +6461,14 @@ PHP_FUNCTION(libvirt_domain_detach_device) */ PHP_FUNCTION(libvirt_domain_get_info) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; virDomainInfo domainInfo; int retval; GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainGetInfo(domain->domain, &domainInfo); + retval = virDomainGetInfo(domain->domain, &domainInfo); DPRINTF("%s: virDomainGetInfo(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; @@ -6490,13 +6490,13 @@ PHP_FUNCTION(libvirt_domain_get_info) */ PHP_FUNCTION(libvirt_domain_create) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainCreate(domain->domain); + retval = virDomainCreate(domain->domain); DPRINTF("%s: virDomainCreate(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; @@ -6512,13 +6512,13 @@ PHP_FUNCTION(libvirt_domain_create) */ PHP_FUNCTION(libvirt_domain_destroy) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainDestroy(domain->domain); + retval = virDomainDestroy(domain->domain); DPRINTF("%s: virDomainDestroy(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; @@ -6534,13 +6534,13 @@ PHP_FUNCTION(libvirt_domain_destroy) */ PHP_FUNCTION(libvirt_domain_resume) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainResume(domain->domain); + retval = virDomainResume(domain->domain); DPRINTF("%s: virDomainResume(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; @@ -6557,7 +6557,7 @@ PHP_FUNCTION(libvirt_domain_resume) */ PHP_FUNCTION(libvirt_domain_core_dump) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; strsize_t to_len; @@ -6565,7 +6565,7 @@ PHP_FUNCTION(libvirt_domain_core_dump) GET_DOMAIN_FROM_ARGS("rs", &zdomain, &to, &to_len); - retval=virDomainCoreDump(domain->domain, to, 0); + retval = virDomainCoreDump(domain->domain, to, 0); DPRINTF("%s: virDomainCoreDump(%p, %s, 0) returned %d\n", PHPFUNC, domain->domain, to, retval); if (retval != 0) RETURN_FALSE; @@ -6581,13 +6581,13 @@ PHP_FUNCTION(libvirt_domain_core_dump) */ PHP_FUNCTION(libvirt_domain_shutdown) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainShutdown(domain->domain); + retval = virDomainShutdown(domain->domain); DPRINTF("%s: virDomainShutdown(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; @@ -6603,12 +6603,12 @@ PHP_FUNCTION(libvirt_domain_shutdown) */ PHP_FUNCTION(libvirt_domain_managedsave) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainManagedSave(domain->domain, 0); + retval = virDomainManagedSave(domain->domain, 0); DPRINTF("%s: virDomainManagedSave(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; @@ -6624,13 +6624,13 @@ PHP_FUNCTION(libvirt_domain_managedsave) */ PHP_FUNCTION(libvirt_domain_suspend) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainSuspend(domain->domain); + retval = virDomainSuspend(domain->domain); DPRINTF("%s: virDomainSuspend(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; @@ -6646,13 +6646,13 @@ PHP_FUNCTION(libvirt_domain_suspend) */ PHP_FUNCTION(libvirt_domain_undefine) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainUndefine(domain->domain); + retval = virDomainUndefine(domain->domain); DPRINTF("%s: virDomainUndefine(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; @@ -6669,14 +6669,14 @@ PHP_FUNCTION(libvirt_domain_undefine) */ PHP_FUNCTION(libvirt_domain_reboot) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; - zend_long flags=0; + zend_long flags = 0; GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags); - retval=virDomainReboot(domain->domain, flags); + retval = virDomainReboot(domain->domain, flags); DPRINTF("%s: virDomainReboot(%p) returned %d\n", PHPFUNC, domain->domain, retval); if (retval != 0) RETURN_FALSE; @@ -6693,22 +6693,22 @@ PHP_FUNCTION(libvirt_domain_reboot) */ PHP_FUNCTION(libvirt_domain_define_xml) { - php_libvirt_domain *res_domain=NULL; - php_libvirt_connection *conn=NULL; + php_libvirt_domain *res_domain = NULL; + php_libvirt_connection *conn = NULL; zval *zconn; - virDomainPtr domain=NULL; + virDomainPtr domain = NULL; char *xml; strsize_t xml_len; GET_CONNECTION_FROM_ARGS("rs", &zconn, &xml, &xml_len); - domain=virDomainDefineXML(conn->conn, xml); + domain = virDomainDefineXML(conn->conn, xml); if (domain == NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; - res_domain->conn=conn; + res_domain->conn = conn; DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); @@ -6729,24 +6729,24 @@ PHP_FUNCTION(libvirt_domain_define_xml) */ PHP_FUNCTION(libvirt_domain_create_xml) { - php_libvirt_domain *res_domain=NULL; - php_libvirt_connection *conn=NULL; + php_libvirt_domain *res_domain = NULL; + php_libvirt_connection *conn = NULL; zval *zconn; - virDomainPtr domain=NULL; + virDomainPtr domain = NULL; char *xml; strsize_t xml_len; - zend_long flags=0; + zend_long flags = 0; GET_CONNECTION_FROM_ARGS("rs|l", &zconn, &xml, &xml_len, &flags); - domain=virDomainCreateXML(conn->conn, xml, flags); + domain = virDomainCreateXML(conn->conn, xml, flags); DPRINTF("%s: virDomainCreateXML(%p, <xml>, 0) returned %p\n", PHPFUNC, conn->conn, domain); if (domain == NULL) RETURN_FALSE; res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; - res_domain->conn=conn; + res_domain->conn = conn; DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); @@ -6835,10 +6835,10 @@ PHP_FUNCTION(libvirt_domain_xml_to_native) */ PHP_FUNCTION(libvirt_domain_memory_peek) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; - zend_long flags=0; + zend_long flags = 0; zend_long start; zend_long size; char *buff; @@ -6848,8 +6848,8 @@ PHP_FUNCTION(libvirt_domain_memory_peek) set_error("Negative argument start" TSRMLS_CC); RETURN_FALSE; } - buff=(char *)emalloc(size); - retval=virDomainMemoryPeek(domain->domain, start, size, buff, flags); + buff = (char *)emalloc(size); + retval = virDomainMemoryPeek(domain->domain, start, size, buff, flags); if (retval != 0) RETURN_FALSE; VIRT_RETVAL_STRINGL(buff, size); @@ -6866,23 +6866,23 @@ PHP_FUNCTION(libvirt_domain_memory_peek) */ PHP_FUNCTION(libvirt_domain_memory_stats) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; - zend_long flags=0; + zend_long flags = 0; int i; struct _virDomainMemoryStat stats[VIR_DOMAIN_MEMORY_STAT_NR]; GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags); - retval=virDomainMemoryStats(domain->domain, stats, VIR_DOMAIN_MEMORY_STAT_NR, flags); + retval = virDomainMemoryStats(domain->domain, stats, VIR_DOMAIN_MEMORY_STAT_NR, flags); DPRINTF("%s: virDomainMemoryStats(%p...) returned %d\n", PHPFUNC, domain->domain, retval); if (retval == -1) RETURN_FALSE; LONGLONG_INIT; array_init(return_value); - for (i=0;i<retval;i++) + for (i = 0;i<retval;i++) LONGLONG_INDEX(return_value, stats[i].tag, stats[i].val) } @@ -6897,7 +6897,7 @@ PHP_FUNCTION(libvirt_domain_memory_stats) */ PHP_FUNCTION(libvirt_domain_update_device) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; char *xml; strsize_t xml_len; @@ -6906,7 +6906,7 @@ PHP_FUNCTION(libvirt_domain_update_device) GET_DOMAIN_FROM_ARGS("rsl", &zdomain, &xml, &xml_len, &flags); - res=virDomainUpdateDeviceFlags(domain->domain, xml, flags); + res = virDomainUpdateDeviceFlags(domain->domain, xml, flags); DPRINTF("%s: virDomainUpdateDeviceFlags(%p) returned %d\n", PHPFUNC, domain->domain, res); if (res != 0) RETURN_FALSE; @@ -6924,7 +6924,7 @@ PHP_FUNCTION(libvirt_domain_update_device) */ PHP_FUNCTION(libvirt_domain_block_stats) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; char *path; @@ -6934,7 +6934,7 @@ PHP_FUNCTION(libvirt_domain_block_stats) GET_DOMAIN_FROM_ARGS("rs", &zdomain, &path, &path_len); - retval=virDomainBlockStats(domain->domain, path, &stats, sizeof stats); + retval = virDomainBlockStats(domain->domain, path, &stats, sizeof stats); DPRINTF("%s: virDomainBlockStats(%p,%s,<stats>,<size>) returned %d\n", PHPFUNC, domain->domain, path, retval); if (retval == -1) RETURN_FALSE; @@ -6960,7 +6960,7 @@ PHP_FUNCTION(libvirt_domain_block_stats) */ PHP_FUNCTION(libvirt_domain_block_resize) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; char *path; @@ -6970,7 +6970,7 @@ PHP_FUNCTION(libvirt_domain_block_resize) GET_DOMAIN_FROM_ARGS("rsl|l", &zdomain, &path, &path_len, &size, &flags); - retval=virDomainBlockResize(domain->domain, path, size, flags); + retval = virDomainBlockResize(domain->domain, path, size, flags); if (retval == -1) RETURN_FALSE; @@ -6991,7 +6991,7 @@ PHP_FUNCTION(libvirt_domain_block_resize) */ PHP_FUNCTION(libvirt_domain_block_commit) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; char *disk; @@ -7005,7 +7005,7 @@ PHP_FUNCTION(libvirt_domain_block_commit) GET_DOMAIN_FROM_ARGS("rsssll", &zdomain, &disk, &disk_len, &base, &base_len, &top, &top_len, &bandwidth, &flags); - retval=virDomainBlockCommit(domain->domain, disk, base, top, bandwidth, flags); + retval = virDomainBlockCommit(domain->domain, disk, base, top, bandwidth, flags); if (retval == -1) RETURN_FALSE; @@ -7024,7 +7024,7 @@ PHP_FUNCTION(libvirt_domain_block_commit) */ PHP_FUNCTION(libvirt_domain_block_job_info) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; char *disk; @@ -7034,7 +7034,7 @@ PHP_FUNCTION(libvirt_domain_block_job_info) GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &disk, &disk_len, &flags); - retval=virDomainGetBlockJobInfo(domain->domain, disk, &info, flags); + retval = virDomainGetBlockJobInfo(domain->domain, disk, &info, flags); array_init(return_value); add_assoc_long(return_value, "status", (int)retval); @@ -7056,7 +7056,7 @@ PHP_FUNCTION(libvirt_domain_block_job_info) */ PHP_FUNCTION(libvirt_domain_block_job_abort) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; char *path; @@ -7065,7 +7065,7 @@ PHP_FUNCTION(libvirt_domain_block_job_abort) GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &path, &path_len, &flags); - retval=virDomainBlockJobAbort(domain->domain, path, flags); + retval = virDomainBlockJobAbort(domain->domain, path, flags); if (retval == -1) RETURN_FALSE; @@ -7084,7 +7084,7 @@ PHP_FUNCTION(libvirt_domain_block_job_abort) */ PHP_FUNCTION(libvirt_domain_block_job_set_speed) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; char *path; @@ -7094,7 +7094,7 @@ PHP_FUNCTION(libvirt_domain_block_job_set_speed) GET_DOMAIN_FROM_ARGS("rsl|l", &zdomain, &path, &path_len, &bandwidth, &flags); - retval=virDomainBlockJobSetSpeed(domain->domain, path, bandwidth, flags); + retval = virDomainBlockJobSetSpeed(domain->domain, path, bandwidth, flags); if (retval == -1) RETURN_FALSE; @@ -7113,7 +7113,7 @@ PHP_FUNCTION(libvirt_domain_block_job_set_speed) */ PHP_FUNCTION(libvirt_domain_get_network_info) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; char *mac; @@ -7186,7 +7186,7 @@ PHP_FUNCTION(libvirt_domain_get_network_info) */ PHP_FUNCTION(libvirt_domain_get_block_info) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; char *dev; @@ -7291,7 +7291,7 @@ PHP_FUNCTION(libvirt_domain_get_block_info) */ PHP_FUNCTION(libvirt_domain_xml_xpath) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; zval *zpath; char *xml; @@ -7335,7 +7335,7 @@ PHP_FUNCTION(libvirt_domain_xml_xpath) */ PHP_FUNCTION(libvirt_domain_interface_stats) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; char *path; @@ -7345,7 +7345,7 @@ PHP_FUNCTION(libvirt_domain_interface_stats) GET_DOMAIN_FROM_ARGS("rs", &zdomain, &path, &path_len); - retval=virDomainInterfaceStats(domain->domain, path, &stats, sizeof stats); + retval = virDomainInterfaceStats(domain->domain, path, &stats, sizeof stats); DPRINTF("%s: virDomainInterfaceStats(%p,%s,<stats>,<size>) returned %d\n", PHPFUNC, domain->domain, path, retval); if (retval == -1) RETURN_FALSE; @@ -7371,7 +7371,7 @@ PHP_FUNCTION(libvirt_domain_interface_stats) */ PHP_FUNCTION(libvirt_domain_get_connect) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; php_libvirt_connection *conn; @@ -7379,7 +7379,7 @@ PHP_FUNCTION(libvirt_domain_get_connect) GET_DOMAIN_FROM_ARGS("r", &zdomain); - conn= domain->conn; + conn = domain->conn; if (conn->conn == NULL) RETURN_FALSE; #if PHP_MAJOR_VERSION >= 7 @@ -7402,22 +7402,22 @@ PHP_FUNCTION(libvirt_domain_get_connect) */ PHP_FUNCTION(libvirt_domain_migrate_to_uri) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; - long flags=0; + long flags = 0; char *duri; strsize_t duri_len; char *dname; strsize_t dname_len; zend_long bandwidth; - dname=NULL; - dname_len=0; - bandwidth=0; + dname = NULL; + dname_len = 0; + bandwidth = 0; GET_DOMAIN_FROM_ARGS("rsl|sl", &zdomain, &duri, &duri_len, &flags, &dname, &dname_len, &bandwidth); - retval=virDomainMigrateToURI(domain->domain, duri, flags, dname, bandwidth); + retval = virDomainMigrateToURI(domain->domain, duri, flags, dname, bandwidth); DPRINTF("%s: virDomainMigrateToURI() returned %d\n", PHPFUNC, retval); if (retval == 0) @@ -7440,7 +7440,7 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri) */ PHP_FUNCTION(libvirt_domain_migrate_to_uri2) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; char *dconnuri; @@ -7449,20 +7449,20 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri2) strsize_t miguri_len; char *dxml; strsize_t dxml_len; - zend_long flags=0; + zend_long flags = 0; char *dname; strsize_t dname_len; zend_long bandwidth; - dconnuri=NULL; - dconnuri_len=0; - miguri=NULL; - miguri_len=0; - dxml=NULL; - dxml_len=0; - dname=NULL; - dname_len=0; - bandwidth=0; + dconnuri = NULL; + dconnuri_len = 0; + miguri = NULL; + miguri_len = 0; + dxml = NULL; + dxml_len = 0; + dname = NULL; + dname_len = 0; + bandwidth = 0; GET_DOMAIN_FROM_ARGS("r|ssslsl", &zdomain, &dconnuri, &dconnuri_len, &miguri, &miguri_len, &dxml, &dxml_len, &flags, &dname, &dname_len, &bandwidth); // set to NULL if empty string @@ -7475,7 +7475,7 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri2) if (dname_len == 0) dname=NULL; - retval=virDomainMigrateToURI2(domain->domain, dconnuri, miguri, dxml, flags, dname, bandwidth); + retval = virDomainMigrateToURI2(domain->domain, dconnuri, miguri, dxml, flags, dname, bandwidth); DPRINTF("%s: virDomainMigrateToURI2() returned %d\n", PHPFUNC, retval); if (retval == 0) @@ -7496,21 +7496,21 @@ PHP_FUNCTION(libvirt_domain_migrate_to_uri2) */ PHP_FUNCTION(libvirt_domain_migrate) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; - php_libvirt_connection *dconn=NULL; + php_libvirt_connection *dconn = NULL; zval *zdconn; - virDomainPtr destdomain=NULL; + virDomainPtr destdomain = NULL; php_libvirt_domain *res_domain; - zend_long flags=0; + zend_long flags = 0; char *dname; strsize_t dname_len; zend_long bandwidth; - dname=NULL; - dname_len=0; - bandwidth=0; + dname = NULL; + dname_len = 0; + bandwidth = 0; GET_DOMAIN_FROM_ARGS("rrl|sl", &zdomain, &zdconn, &flags, &dname, &dname_len, &bandwidth); @@ -7525,13 +7525,13 @@ PHP_FUNCTION(libvirt_domain_migrate) RETURN_FALSE; } - destdomain=virDomainMigrate(domain->domain, dconn->conn, flags, dname, NULL, bandwidth); + destdomain = virDomainMigrate(domain->domain, dconn->conn, flags, dname, NULL, bandwidth); if (destdomain == NULL) RETURN_FALSE; - res_domain= (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); + res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = destdomain; - res_domain->conn=dconn; + res_domain->conn = dconn; DPRINTF("%s: returning %p\n", PHPFUNC, res_domain->domain); resource_change_counter(INT_RESOURCE_DOMAIN, dconn->conn, res_domain->domain, 1 TSRMLS_CC); @@ -7551,7 +7551,7 @@ PHP_FUNCTION(libvirt_domain_migrate) */ PHP_FUNCTION(libvirt_domain_get_job_info) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; @@ -7559,7 +7559,7 @@ PHP_FUNCTION(libvirt_domain_get_job_info) GET_DOMAIN_FROM_ARGS("r", &zdomain); - retval=virDomainGetJobInfo(domain->domain, &jobinfo); + retval = virDomainGetJobInfo(domain->domain, &jobinfo); if (retval == -1) RETURN_FALSE; @@ -7589,14 +7589,14 @@ PHP_FUNCTION(libvirt_domain_get_job_info) */ PHP_FUNCTION(libvirt_domain_has_current_snapshot) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; int retval; zend_long flags = 0; GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags); - retval=virDomainHasCurrentSnapshot(domain->domain, flags); + retval = virDomainHasCurrentSnapshot(domain->domain, flags); if (retval <= 0) RETURN_FALSE; RETURN_TRUE; @@ -7613,10 +7613,10 @@ PHP_FUNCTION(libvirt_domain_has_current_snapshot) */ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; strsize_t name_len; - char *name=NULL; + char *name = NULL; zend_long flags = 0; php_libvirt_snapshot *res_snapshot; virDomainSnapshotPtr snapshot = NULL; @@ -7652,7 +7652,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name) */ PHP_FUNCTION(libvirt_domain_snapshot_create) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; php_libvirt_snapshot *res_snapshot; zval *zdomain; virDomainSnapshotPtr snapshot = NULL; @@ -7660,7 +7660,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_create) GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags); - snapshot=virDomainSnapshotCreateXML(domain->domain, "<domainsnapshot/>", flags); + snapshot = virDomainSnapshotCreateXML(domain->domain, "<domainsnapshot/>", flags); DPRINTF("%s: virDomainSnapshotCreateXML(%p, <xml>) returned %p\n", PHPFUNC, domain->domain, snapshot); if (snapshot == NULL) RETURN_FALSE; @@ -7761,29 +7761,29 @@ PHP_FUNCTION(libvirt_domain_snapshot_delete) */ PHP_FUNCTION(libvirt_list_domain_snapshots) { - php_libvirt_domain *domain=NULL; + php_libvirt_domain *domain = NULL; zval *zdomain; - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; char **names; zend_long flags = 0; int i; GET_DOMAIN_FROM_ARGS("r|l", &zdomain, &flags); - expectedcount=virDomainSnapshotNum(domain->domain, flags); + expectedcount = virDomainSnapshotNum(domain->domain, flags); DPRINTF("%s: virDomainSnapshotNum(%p, 0) returned %d\n", PHPFUNC, domain->domain, expectedcount); if (expectedcount != -1) { - names=(char **)emalloc(expectedcount * sizeof(char *)); - count=virDomainSnapshotListNames(domain->domain, names, expectedcount, 0); + names = (char **)emalloc(expectedcount * sizeof(char *)); + count = virDomainSnapshotListNames(domain->domain, names, expectedcount, 0); } if ((count != expectedcount) || (count<0)) { RETURN_FALSE; } else { array_init(return_value); - for (i=0;i<count;i++) { + for (i = 0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -7803,18 +7803,18 @@ PHP_FUNCTION(libvirt_list_domain_snapshots) */ PHP_FUNCTION(libvirt_storagepool_lookup_by_name) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; strsize_t name_len; - char *name=NULL; - virStoragePoolPtr pool=NULL; + char *name = NULL; + virStoragePoolPtr pool = NULL; php_libvirt_storagepool *res_pool; GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); if ((name == NULL) || (name_len<1)) RETURN_FALSE; - pool=virStoragePoolLookupByName(conn->conn, name); + pool = virStoragePoolLookupByName(conn->conn, name); DPRINTF("%s: virStoragePoolLookupByName(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, pool); if (pool == NULL) RETURN_FALSE; @@ -7845,7 +7845,7 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_volume) { php_libvirt_volume *volume; zval *zvolume; - virStoragePoolPtr pool=NULL; + virStoragePoolPtr pool = NULL; php_libvirt_storagepool *res_pool; GET_VOLUME_FROM_ARGS("r", &zvolume); @@ -7877,28 +7877,28 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_volume) */ PHP_FUNCTION(libvirt_storagepool_list_volumes) { - php_libvirt_storagepool *pool=NULL; + php_libvirt_storagepool *pool = NULL; zval *zpool; - char **names=NULL; - int expectedcount=-1; + char **names = NULL; + int expectedcount = -1; int i; - int count=-1; + int count = -1; GET_STORAGEPOOL_FROM_ARGS("r", &zpool); - if ((expectedcount=virStoragePoolNumOfVolumes(pool->pool)) < 0) + if ((expectedcount = virStoragePoolNumOfVolumes(pool->pool)) < 0) RETURN_FALSE; DPRINTF("%s: virStoragePoolNumOfVolumes(%p) returned %d\n", PHPFUNC, pool->pool, expectedcount); - names=(char **)emalloc(expectedcount*sizeof(char *)); + names = (char **)emalloc(expectedcount*sizeof(char *)); - count=virStoragePoolListVolumes(pool->pool, names, expectedcount); + count = virStoragePoolListVolumes(pool->pool, names, expectedcount); DPRINTF("%s: virStoragePoolListVolumes(%p,%p,%d) returned %d\n", PHPFUNC, pool->pool, names, expectedcount, count); array_init(return_value); if ((count != expectedcount) || (count<0)) - RETURN_FALSE; - for (i=0;i<count;i++) { + RETURN_FALSE; + for (i = 0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -7915,14 +7915,14 @@ PHP_FUNCTION(libvirt_storagepool_list_volumes) */ PHP_FUNCTION(libvirt_storagepool_get_info) { - php_libvirt_storagepool *pool=NULL; + php_libvirt_storagepool *pool = NULL; zval *zpool; virStoragePoolInfo poolInfo; int retval; GET_STORAGEPOOL_FROM_ARGS("r", &zpool); - retval=virStoragePoolGetInfo(pool->pool, &poolInfo); + retval = virStoragePoolGetInfo(pool->pool, &poolInfo); DPRINTF("%s: virStoragePoolGetInfo(%p, <info>) returned %d\n", PHPFUNC, pool->pool, retval); if (retval != 0) RETURN_FALSE; @@ -7947,18 +7947,18 @@ PHP_FUNCTION(libvirt_storagepool_get_info) */ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name) { - php_libvirt_storagepool *pool=NULL; + php_libvirt_storagepool *pool = NULL; php_libvirt_volume *res_volume; zval *zpool; strsize_t name_len; - char *name=NULL; - virStorageVolPtr volume=NULL; + char *name = NULL; + virStorageVolPtr volume = NULL; GET_STORAGEPOOL_FROM_ARGS("rs", &zpool, &name, &name_len); if ((name == NULL) || (name_len<1)) RETURN_FALSE; - volume=virStorageVolLookupByName(pool->pool, name); + volume = virStorageVolLookupByName(pool->pool, name); DPRINTF("%s: virStorageVolLookupByName(%p, %s) returned %p\n", PHPFUNC, pool->pool, name, volume); if (volume == NULL) RETURN_FALSE; @@ -7986,18 +7986,18 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name) */ PHP_FUNCTION(libvirt_storagevolume_lookup_by_path) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; php_libvirt_volume *res_volume; zval *zconn; strsize_t name_len; - char *name=NULL; - virStorageVolPtr volume=NULL; + char *name = NULL; + virStorageVolPtr volume = NULL; GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); if ((name == NULL) || (name_len<1)) RETURN_FALSE; - volume=virStorageVolLookupByPath(conn->conn, name); + volume = virStorageVolLookupByPath(conn->conn, name); DPRINTF("%s: virStorageVolLookupByPath(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, volume); if (volume == NULL) { set_error_if_unset("Cannot find storage volume on requested path" TSRMLS_CC); @@ -8073,14 +8073,14 @@ PHP_FUNCTION(libvirt_storagevolume_get_path) */ PHP_FUNCTION(libvirt_storagevolume_get_info) { - php_libvirt_volume *volume=NULL; + php_libvirt_volume *volume = NULL; zval *zvolume; virStorageVolInfo volumeInfo; int retval; GET_VOLUME_FROM_ARGS("r", &zvolume); - retval=virStorageVolGetInfo(volume->volume, &volumeInfo); + retval = virStorageVolGetInfo(volume->volume, &volumeInfo); DPRINTF("%s: virStorageVolGetInfo(%p, <info>) returned %d\n", PHPFUNC, volume->volume, retval); if (retval != 0) RETURN_FALSE; @@ -8103,13 +8103,13 @@ PHP_FUNCTION(libvirt_storagevolume_get_info) */ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc) { - php_libvirt_volume *volume=NULL; + php_libvirt_volume *volume = NULL; zval *zvolume; char *tmp = NULL; char *xml; char *xpath = NULL; strsize_t xpath_len; - zend_long flags=0; + zend_long flags = 0; int retval = -1; GET_VOLUME_FROM_ARGS("rs|l", &zvolume, &xpath, &xpath_len, &flags); @@ -8118,7 +8118,7 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc) DPRINTF("%s: volume = %p, xpath = %s, flags = %ld\n", PHPFUNC, volume->volume, xpath, flags); - xml=virStorageVolGetXMLDesc(volume->volume, flags); + xml = virStorageVolGetXMLDesc(volume->volume, flags); if (xml == NULL) { set_error_if_unset("Cannot get the XML description" TSRMLS_CC); RETURN_FALSE; @@ -8146,22 +8146,22 @@ PHP_FUNCTION(libvirt_storagevolume_get_xml_desc) */ PHP_FUNCTION(libvirt_storagevolume_create_xml) { - php_libvirt_volume *res_volume=NULL; - php_libvirt_storagepool *pool=NULL; + php_libvirt_volume *res_volume = NULL; + php_libvirt_storagepool *pool = NULL; zval *zpool; - virStorageVolPtr volume=NULL; + virStorageVolPtr volume = NULL; char *xml; zend_long flags = 0; strsize_t xml_len; GET_STORAGEPOOL_FROM_ARGS("rs|l", &zpool, &xml, &xml_len, &flags); - volume=virStorageVolCreateXML(pool->pool, xml, flags); + volume = virStorageVolCreateXML(pool->pool, xml, flags); DPRINTF("%s: virStorageVolCreateXML(%p, <xml>, 0) returned %p\n", PHPFUNC, pool->pool, volume); if (volume == NULL) RETURN_FALSE; - res_volume= (php_libvirt_volume *)emalloc(sizeof(php_libvirt_volume)); + res_volume = (php_libvirt_volume *)emalloc(sizeof(php_libvirt_volume)); res_volume->volume = volume; res_volume->conn = pool->conn; @@ -8185,14 +8185,14 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml) */ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) { - php_libvirt_volume *res_volume=NULL; - php_libvirt_storagepool *pool=NULL; + php_libvirt_volume *res_volume = NULL; + php_libvirt_storagepool *pool = NULL; zval *zpool; - php_libvirt_volume *pl_volume=NULL; + php_libvirt_volume *pl_volume = NULL; zval *zvolume; - virStorageVolPtr volume=NULL; + virStorageVolPtr volume = NULL; char *xml; strsize_t xml_len; @@ -8209,7 +8209,7 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) RETURN_FALSE; resource_change_counter(INT_RESOURCE_VOLUME, NULL, pl_volume->volume, 1 TSRMLS_CC); - volume=virStorageVolCreateXMLFrom(pool->pool, xml, pl_volume->volume, 0); + volume = virStorageVolCreateXMLFrom(pool->pool, xml, pl_volume->volume, 0); DPRINTF("%s: virStorageVolCreateXMLFrom(%p, <xml>, %p, 0) returned %p\n", PHPFUNC, pool->pool, pl_volume->volume, volume); if (volume == NULL) RETURN_FALSE; @@ -8237,7 +8237,7 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) */ PHP_FUNCTION(libvirt_storagevolume_delete) { - php_libvirt_volume *volume=NULL; + php_libvirt_volume *volume = NULL; zval *zvolume; zend_long flags = 0; int retval = 0; @@ -8265,7 +8265,7 @@ PHP_FUNCTION(libvirt_storagevolume_delete) */ PHP_FUNCTION(libvirt_storagevolume_resize) { - php_libvirt_volume *volume=NULL; + php_libvirt_volume *volume = NULL; zval *zvolume; zend_long flags = 0; zend_long capacity = 0; @@ -8296,8 +8296,8 @@ PHP_FUNCTION(libvirt_storagevolume_resize) */ PHP_FUNCTION(libvirt_storagevolume_download) { - php_libvirt_volume *volume=NULL; - php_libvirt_stream *stream=NULL; + php_libvirt_volume *volume = NULL; + php_libvirt_stream *stream = NULL; zval *zvolume; zval *zstream; zend_long flags = 0; @@ -8338,8 +8338,8 @@ PHP_FUNCTION(libvirt_storagevolume_download) */ PHP_FUNCTION(libvirt_storagevolume_upload) { - php_libvirt_volume *volume=NULL; - php_libvirt_stream *stream=NULL; + php_libvirt_volume *volume = NULL; + php_libvirt_stream *stream = NULL; zval *zvolume; zval *zstream; zend_long flags = 0; @@ -8376,7 +8376,7 @@ PHP_FUNCTION(libvirt_storagevolume_upload) */ PHP_FUNCTION(libvirt_storagepool_get_uuid_string) { - php_libvirt_storagepool *pool=NULL; + php_libvirt_storagepool *pool = NULL; zval *zpool; char *uuid; int retval; @@ -8404,7 +8404,7 @@ PHP_FUNCTION(libvirt_storagepool_get_name) { php_libvirt_storagepool *pool = NULL; zval *zpool; - const char *name=NULL; + const char *name = NULL; GET_STORAGEPOOL_FROM_ARGS("r", &zpool); @@ -8430,7 +8430,7 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_uuid_string) zval *zconn; char *uuid = NULL; strsize_t uuid_len; - virStoragePoolPtr storage=NULL; + virStoragePoolPtr storage = NULL; php_libvirt_storagepool *res_pool; GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); @@ -8767,20 +8767,20 @@ PHP_FUNCTION(libvirt_storagepool_delete) */ PHP_FUNCTION(libvirt_list_storagepools) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; char **names; int i; GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfStoragePools(conn->conn)) < 0) + if ((expectedcount = virConnectNumOfStoragePools(conn->conn)) < 0) RETURN_FALSE; - names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListStoragePools(conn->conn, names, expectedcount); + names = (char **)emalloc(expectedcount*sizeof(char *)); + count = virConnectListStoragePools(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { efree(names); @@ -8788,7 +8788,7 @@ PHP_FUNCTION(libvirt_list_storagepools) } array_init(return_value); - for (i=0;i<count;i++) { + for (i = 0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -8820,27 +8820,27 @@ PHP_FUNCTION(libvirt_list_storagepools) */ PHP_FUNCTION(libvirt_list_active_storagepools) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; char **names; int i; GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfStoragePools(conn->conn)) < 0) + if ((expectedcount = virConnectNumOfStoragePools(conn->conn)) < 0) RETURN_FALSE; - names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListStoragePools(conn->conn, names, expectedcount); + names = (char **)emalloc(expectedcount*sizeof(char *)); + count = virConnectListStoragePools(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } array_init(return_value); - for (i=0;i<count;i++) { + for (i = 0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -8856,10 +8856,10 @@ PHP_FUNCTION(libvirt_list_active_storagepools) */ PHP_FUNCTION(libvirt_list_inactive_storagepools) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; char **names; int i; @@ -8868,7 +8868,7 @@ PHP_FUNCTION(libvirt_list_inactive_storagepools) if ((expectedcount = virConnectNumOfDefinedStoragePools(conn->conn)) < 0) RETURN_FALSE; - names= (char **)emalloc(expectedcount * sizeof(char *)); + names = (char **)emalloc(expectedcount * sizeof(char *)); count = virConnectListDefinedStoragePools(conn->conn, names, expectedcount); if ((count != expectedcount) || (count < 0)) { efree(names); @@ -8892,33 +8892,33 @@ PHP_FUNCTION(libvirt_list_inactive_storagepools) */ PHP_FUNCTION(libvirt_list_domains) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; int *ids; char **names; const char *name; int i, rv; - virDomainPtr domain=NULL; + virDomainPtr domain = NULL; GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfDomains(conn->conn)) < 0) + if ((expectedcount = virConnectNumOfDomains(conn->conn)) < 0) RETURN_FALSE; DPRINTF("%s: Found %d domains\n", PHPFUNC, expectedcount); - ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains(conn->conn, ids, expectedcount); + ids = (int *)emalloc(sizeof(int)*expectedcount); + count = virConnectListDomains(conn->conn, ids, expectedcount); DPRINTF("%s: virConnectListDomains returned %d domains\n", PHPFUNC, count); array_init(return_value); - for (i=0;i<count;i++) { - domain=virDomainLookupByID(conn->conn, ids[i]); + for (i = 0;i<count;i++) { + domain = virDomainLookupByID(conn->conn, ids[i]); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, domain, 1 TSRMLS_CC); if (domain != NULL) { - name=virDomainGetName(domain); + name = virDomainGetName(domain); if (name != NULL) { DPRINTF("%s: Found running domain %s with ID = %d\n", PHPFUNC, name, ids[i]); VIRT_ADD_NEXT_INDEX_STRING(return_value, name); @@ -8937,22 +8937,22 @@ PHP_FUNCTION(libvirt_list_domains) } efree(ids); - expectedcount=virConnectNumOfDefinedDomains(conn->conn); + expectedcount = virConnectNumOfDefinedDomains(conn->conn); DPRINTF("%s: virConnectNumOfDefinedDomains returned %d domains\n", PHPFUNC, expectedcount); if (expectedcount < 0) { DPRINTF("%s: virConnectNumOfDefinedDomains failed with error code %d\n", PHPFUNC, expectedcount); RETURN_FALSE; } - names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedDomains(conn->conn, names, expectedcount); + names = (char **)emalloc(expectedcount*sizeof(char *)); + count = virConnectListDefinedDomains(conn->conn, names, expectedcount); DPRINTF("%s: virConnectListDefinedDomains returned %d domains\n", PHPFUNC, count); if (count < 0) { DPRINTF("%s: virConnectListDefinedDomains failed with error code %d\n", PHPFUNC, count); RETURN_FALSE; } - for (i=0;i<count;i++) { + for (i = 0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); DPRINTF("%s: Found inactive domain %s\n", PHPFUNC, names[i]); free(names[i]); @@ -8969,41 +8969,41 @@ PHP_FUNCTION(libvirt_list_domains) */ PHP_FUNCTION(libvirt_list_domain_resources) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; #if PHP_MAJOR_VERSION >= 7 zval zdomain; #else zval *zdomain; #endif - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; int *ids; char **names; int i; - virDomainPtr domain=NULL; + virDomainPtr domain = NULL; php_libvirt_domain *res_domain; GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfDomains(conn->conn)) < 0) + if ((expectedcount = virConnectNumOfDomains(conn->conn)) < 0) RETURN_FALSE; - ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains(conn->conn, ids, expectedcount); + ids = (int *)emalloc(sizeof(int)*expectedcount); + count = virConnectListDomains(conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { efree(ids); RETURN_FALSE; } array_init(return_value); - for (i=0;i<count;i++) { - domain=virDomainLookupByID(conn->conn, ids[i]); + for (i = 0;i<count;i++) { + domain = virDomainLookupByID(conn->conn, ids[i]); if (domain != NULL) { - res_domain= (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); + res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; - res_domain->conn=conn; + res_domain->conn = conn; resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, res_domain->domain, 1 TSRMLS_CC); #if PHP_MAJOR_VERSION >= 7 @@ -9018,22 +9018,22 @@ PHP_FUNCTION(libvirt_list_domain_resources) } efree(ids); - if ((expectedcount=virConnectNumOfDefinedDomains(conn->conn)) < 0) + if ((expectedcount = virConnectNumOfDefinedDomains(conn->conn)) < 0) RETURN_FALSE; - names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedDomains(conn->conn, names , expectedcount); + names = (char **)emalloc(expectedcount*sizeof(char *)); + count = virConnectListDefinedDomains(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } - for (i=0;i<count;i++) { - domain=virDomainLookupByName(conn->conn, names[i]); + for (i = 0;i<count;i++) { + domain = virDomainLookupByName(conn->conn, names[i]); if (domain != NULL) { res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); res_domain->domain = domain; - res_domain->conn=conn; + res_domain->conn = conn; #if PHP_MAJOR_VERSION >= 7 ZVAL_RES(&zdomain, zend_register_resource(res_domain, le_libvirt_domain)); @@ -9059,26 +9059,26 @@ PHP_FUNCTION(libvirt_list_domain_resources) */ PHP_FUNCTION(libvirt_list_active_domain_ids) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; int *ids; int i; GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfDomains(conn->conn)) < 0) + if ((expectedcount = virConnectNumOfDomains (conn->conn)) < 0) RETURN_FALSE; - ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains(conn->conn, ids, expectedcount); + ids = (int *)emalloc(sizeof(int)*expectedcount); + count = virConnectListDomains(conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { efree(ids); RETURN_FALSE; } array_init(return_value); - for (i=0;i<count;i++) { + for (i = 0;i<count;i++) { add_next_index_long(return_value, ids[i]); } efree(ids); @@ -9093,10 +9093,10 @@ PHP_FUNCTION(libvirt_list_active_domain_ids) */ PHP_FUNCTION(libvirt_list_active_domains) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; int *ids; int i; virDomainPtr domain = NULL; @@ -9104,19 +9104,19 @@ PHP_FUNCTION(libvirt_list_active_domains) GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfDomains(conn->conn)) < 0) + if ((expectedcount = virConnectNumOfDomains (conn->conn)) < 0) RETURN_FALSE; - ids=(int *)emalloc(sizeof(int)*expectedcount); - count=virConnectListDomains(conn->conn, ids, expectedcount); + ids = (int *)emalloc(sizeof(int)*expectedcount); + count = virConnectListDomains(conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { efree(ids); RETURN_FALSE; } array_init(return_value); - for (i=0;i<count;i++) { - domain=virDomainLookupByID(conn->conn, ids[i]); + for (i = 0;i<count;i++) { + domain = virDomainLookupByID(conn->conn, ids[i]); if (domain != NULL) { if (!(name = virDomainGetName(domain))) { efree(ids); @@ -9141,27 +9141,27 @@ PHP_FUNCTION(libvirt_list_active_domains) */ PHP_FUNCTION(libvirt_list_inactive_domains) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; char **names; int i; GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount=virConnectNumOfDefinedDomains(conn->conn)) < 0) + if ((expectedcount = virConnectNumOfDefinedDomains(conn->conn)) < 0) RETURN_FALSE; - names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedDomains(conn->conn, names, expectedcount); + names = (char **)emalloc(expectedcount*sizeof(char *)); + count = virConnectListDefinedDomains(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } array_init(return_value); - for (i=0;i<count;i++) { + for (i = 0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9178,11 +9178,11 @@ PHP_FUNCTION(libvirt_list_inactive_domains) */ PHP_FUNCTION(libvirt_list_networks) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; zend_long flags = VIR_NETWORKS_ACTIVE | VIR_NETWORKS_INACTIVE; - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; char **names; int i, done = 0; @@ -9190,17 +9190,17 @@ PHP_FUNCTION(libvirt_list_networks) array_init(return_value); if (flags & VIR_NETWORKS_ACTIVE) { - if ((expectedcount=virConnectNumOfNetworks(conn->conn)) < 0) + if ((expectedcount = virConnectNumOfNetworks(conn->conn)) < 0) RETURN_FALSE; - names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListNetworks(conn->conn, names, expectedcount); + names = (char **)emalloc(expectedcount*sizeof(char *)); + count = virConnectListNetworks(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } - for (i=0;i<count;i++) { + for (i = 0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9210,16 +9210,16 @@ PHP_FUNCTION(libvirt_list_networks) } if (flags & VIR_NETWORKS_INACTIVE) { - if ((expectedcount=virConnectNumOfDefinedNetworks(conn->conn)) < 0) + if ((expectedcount = virConnectNumOfDefinedNetworks(conn->conn)) < 0) RETURN_FALSE; - names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virConnectListDefinedNetworks(conn->conn, names, expectedcount); + names = (char **)emalloc(expectedcount*sizeof(char *)); + count = virConnectListDefinedNetworks(conn->conn, names, expectedcount); if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } - for (i=0;i<count;i++) { + for (i = 0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9242,10 +9242,10 @@ PHP_FUNCTION(libvirt_list_networks) */ PHP_FUNCTION(libvirt_list_nodedevs) { - php_libvirt_connection *conn=NULL; + php_libvirt_connection *conn = NULL; zval *zconn; - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; char *cap = NULL; char **names; int i; @@ -9253,17 +9253,17 @@ PHP_FUNCTION(libvirt_list_nodedevs) GET_CONNECTION_FROM_ARGS("r|s", &zconn, &cap, &cap_len); - if ((expectedcount=virNodeNumOfDevices(conn->conn, cap, 0)) < 0) + if ((expectedcount = virNodeNumOfDevices(conn->conn, cap, 0)) < 0) RETURN_FALSE; - names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virNodeListDevices(conn->conn, cap, names, expectedcount, 0); + names = (char **)emalloc(expectedcount*sizeof(char *)); + count = virNodeListDevices(conn->conn, cap, names, expectedcount, 0); if ((count != expectedcount) || (count<0)) { efree(names); RETURN_FALSE; } array_init(return_value); - for (i=0;i<count;i++) { + for (i = 0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9318,24 +9318,24 @@ PHP_FUNCTION(libvirt_nodedev_get) */ PHP_FUNCTION(libvirt_nodedev_capabilities) { - php_libvirt_nodedev *nodedev=NULL; + php_libvirt_nodedev *nodedev = NULL; zval *znodedev; - int count=-1; - int expectedcount=-1; + int count = -1; + int expectedcount = -1; char **names; int i; GET_NODEDEV_FROM_ARGS("r", &znodedev); - if ((expectedcount=virNodeDeviceNumOfCaps(nodedev->device)) < 0) + if ((expectedcount = virNodeDeviceNumOfCaps(nodedev->device)) < 0) RETURN_FALSE; - names=(char **)emalloc(expectedcount*sizeof(char *)); - count=virNodeDeviceListCaps(nodedev->device, names, expectedcount); + names = (char **)emalloc(expectedcount*sizeof(char *)); + count = virNodeDeviceListCaps(nodedev->device, names, expectedcount); if ((count != expectedcount) || (count<0)) RETURN_FALSE; array_init(return_value); - for (i=0;i<count;i++) { + for (i = 0;i<count;i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9353,7 +9353,7 @@ PHP_FUNCTION(libvirt_nodedev_capabilities) */ PHP_FUNCTION(libvirt_nodedev_get_xml_desc) { - php_libvirt_nodedev *nodedev=NULL; + php_libvirt_nodedev *nodedev = NULL; zval *znodedev; char *tmp = NULL; char *xml = NULL; @@ -9390,7 +9390,7 @@ PHP_FUNCTION(libvirt_nodedev_get_xml_desc) */ PHP_FUNCTION(libvirt_nodedev_get_information) { - php_libvirt_nodedev *nodedev=NULL; + php_libvirt_nodedev *nodedev = NULL; zval *znodedev; int retval = -1; char *xml = NULL; @@ -9708,7 +9708,7 @@ PHP_FUNCTION(libvirt_network_get_information) GET_NETWORK_FROM_ARGS("r", &znetwork); - xml=virNetworkGetXMLDesc(network->network, 0); + xml = virNetworkGetXMLDesc(network->network, 0); if (xml == NULL) { set_error_if_unset("Cannot get network XML" TSRMLS_CC); @@ -9843,7 +9843,7 @@ PHP_FUNCTION(libvirt_network_get_xml_desc) if (xpath_len < 1) xpath = NULL; - xml=virNetworkGetXMLDesc(network->network, 0); + xml = virNetworkGetXMLDesc(network->network, 0); if (xml == NULL) { set_error_if_unset("Cannot get network XML" TSRMLS_CC); @@ -9873,7 +9873,7 @@ PHP_FUNCTION(libvirt_version) unsigned long libVer; unsigned long typeVer; strsize_t type_len; - char *type=NULL; + char *type = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &type, &type_len) == FAILURE) { set_error("Invalid arguments" TSRMLS_CC); RETURN_FALSE; -- 2.7.3

for loop should be written with spaces ex: for (i = 0; i < MAX; i++) { ... } Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index dea608e..ced4031 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2292,7 +2292,7 @@ PHP_FUNCTION(libvirt_connect) creds[0].count = j; libvirt_virConnectAuth.cbdata = (void*)creds; conn->conn = virConnectOpenAuth(url, &libvirt_virConnectAuth, readonly ? VIR_CONNECT_RO : 0); - for (i = 0;i < creds[0].count;i++) + for (i = 0; i < creds[0].count; i++) efree(creds[i].result); efree(creds); } @@ -6882,7 +6882,7 @@ PHP_FUNCTION(libvirt_domain_memory_stats) RETURN_FALSE; LONGLONG_INIT; array_init(return_value); - for (i = 0;i<retval;i++) + for (i = 0; i < retval; i++) LONGLONG_INDEX(return_value, stats[i].tag, stats[i].val) } @@ -7783,7 +7783,7 @@ PHP_FUNCTION(libvirt_list_domain_snapshots) RETURN_FALSE; } else { array_init(return_value); - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -7898,7 +7898,7 @@ PHP_FUNCTION(libvirt_storagepool_list_volumes) if ((count != expectedcount) || (count<0)) RETURN_FALSE; - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -8788,7 +8788,7 @@ PHP_FUNCTION(libvirt_list_storagepools) } array_init(return_value); - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -8840,7 +8840,7 @@ PHP_FUNCTION(libvirt_list_active_storagepools) RETURN_FALSE; } array_init(return_value); - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -8914,7 +8914,7 @@ PHP_FUNCTION(libvirt_list_domains) DPRINTF("%s: virConnectListDomains returned %d domains\n", PHPFUNC, count); array_init(return_value); - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { domain = virDomainLookupByID(conn->conn, ids[i]); resource_change_counter(INT_RESOURCE_DOMAIN, conn->conn, domain, 1 TSRMLS_CC); if (domain != NULL) { @@ -8952,7 +8952,7 @@ PHP_FUNCTION(libvirt_list_domains) RETURN_FALSE; } - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); DPRINTF("%s: Found inactive domain %s\n", PHPFUNC, names[i]); free(names[i]); @@ -8997,7 +8997,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) RETURN_FALSE; } array_init(return_value); - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { domain = virDomainLookupByID(conn->conn, ids[i]); if (domain != NULL) { res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -9027,7 +9027,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) efree(names); RETURN_FALSE; } - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { domain = virDomainLookupByName(conn->conn, names[i]); if (domain != NULL) { res_domain = (php_libvirt_domain *)emalloc(sizeof(php_libvirt_domain)); @@ -9078,9 +9078,8 @@ PHP_FUNCTION(libvirt_list_active_domain_ids) RETURN_FALSE; } array_init(return_value); - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) add_next_index_long(return_value, ids[i]); - } efree(ids); } @@ -9115,7 +9114,7 @@ PHP_FUNCTION(libvirt_list_active_domains) } array_init(return_value); - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { domain = virDomainLookupByID(conn->conn, ids[i]); if (domain != NULL) { if (!(name = virDomainGetName(domain))) { @@ -9161,7 +9160,7 @@ PHP_FUNCTION(libvirt_list_inactive_domains) } array_init(return_value); - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9200,7 +9199,7 @@ PHP_FUNCTION(libvirt_list_networks) RETURN_FALSE; } - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9219,7 +9218,7 @@ PHP_FUNCTION(libvirt_list_networks) RETURN_FALSE; } - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9263,7 +9262,7 @@ PHP_FUNCTION(libvirt_list_nodedevs) } array_init(return_value); - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } @@ -9335,7 +9334,7 @@ PHP_FUNCTION(libvirt_nodedev_capabilities) RETURN_FALSE; array_init(return_value); - for (i = 0;i<count;i++) { + for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); } -- 2.7.3

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index ced4031..1f1209f 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -1476,7 +1476,7 @@ static void php_libvirt_connection_dtor( #endif TSRMLS_DC) { - php_libvirt_connection *conn = (php_libvirt_connection*)rsrc->ptr; + php_libvirt_connection *conn = (php_libvirt_connection *)rsrc->ptr; int rv = 0; if (conn != NULL) { @@ -1506,7 +1506,7 @@ static void php_libvirt_domain_dtor( #endif TSRMLS_DC) { - php_libvirt_domain *domain = (php_libvirt_domain*)rsrc->ptr; + php_libvirt_domain *domain = (php_libvirt_domain *)rsrc->ptr; int rv = 0; if (domain != NULL) { @@ -1540,7 +1540,7 @@ static void php_libvirt_stream_dtor( #endif TSRMLS_DC) { - php_libvirt_stream *stream = (php_libvirt_stream*)rsrc->ptr; + php_libvirt_stream *stream = (php_libvirt_stream *)rsrc->ptr; int rv = 0; if (stream != NULL) { @@ -1573,7 +1573,7 @@ static void php_libvirt_storagepool_dtor( #endif TSRMLS_DC) { - php_libvirt_storagepool *pool = (php_libvirt_storagepool*)rsrc->ptr; + php_libvirt_storagepool *pool = (php_libvirt_storagepool *)rsrc->ptr; int rv = 0; if (pool != NULL) { @@ -1606,7 +1606,7 @@ static void php_libvirt_volume_dtor( #endif TSRMLS_DC) { - php_libvirt_volume *volume = (php_libvirt_volume*)rsrc->ptr; + php_libvirt_volume *volume = (php_libvirt_volume *)rsrc->ptr; int rv = 0; if (volume != NULL) { @@ -1639,7 +1639,7 @@ static void php_libvirt_network_dtor( #endif TSRMLS_DC) { - php_libvirt_network *network = (php_libvirt_network*)rsrc->ptr; + php_libvirt_network *network = (php_libvirt_network *)rsrc->ptr; int rv = 0; if (network != NULL) { @@ -1672,7 +1672,7 @@ static void php_libvirt_nodedev_dtor( #endif TSRMLS_DC) { - php_libvirt_nodedev *nodedev = (php_libvirt_nodedev*)rsrc->ptr; + php_libvirt_nodedev *nodedev = (php_libvirt_nodedev *)rsrc->ptr; int rv = 0; if (nodedev != NULL) { @@ -1705,7 +1705,7 @@ static void php_libvirt_snapshot_dtor( #endif TSRMLS_DC) { - php_libvirt_snapshot *snapshot = (php_libvirt_snapshot*)rsrc->ptr; + php_libvirt_snapshot *snapshot = (php_libvirt_snapshot *)rsrc->ptr; int rv = 0; if (snapshot != NULL) { @@ -2157,7 +2157,7 @@ static int libvirt_virConnectAuthCallback(virConnectCredentialPtr cred, unsigned TSRMLS_FETCH(); unsigned int i, j; - php_libvirt_cred_value *creds = (php_libvirt_cred_value*) cbdata; + php_libvirt_cred_value *creds = (php_libvirt_cred_value *) cbdata; for (i = 0; i < (unsigned int)ncred; i++) { DPRINTF("%s: cred %d, type %d, prompt %s challenge %s\n ", __FUNCTION__, i, cred[i].type, cred[i].prompt, cred[i].challenge); if (creds != NULL) @@ -2212,7 +2212,7 @@ PHP_FUNCTION(libvirt_connect) { php_libvirt_connection *conn; php_libvirt_cred_value *creds = NULL; - zval* zcreds = NULL; + zval *zcreds = NULL; zval *data; int i; int j; @@ -2290,7 +2290,7 @@ PHP_FUNCTION(libvirt_connect) } VIRT_FOREACH_END(); DPRINTF("%s: Found %d elements for credentials\n", PHPFUNC, j); creds[0].count = j; - libvirt_virConnectAuth.cbdata = (void*)creds; + libvirt_virConnectAuth.cbdata = (void *)creds; conn->conn = virConnectOpenAuth(url, &libvirt_virConnectAuth, readonly ? VIR_CONNECT_RO : 0); for (i = 0; i < creds[0].count; i++) efree(creds[i].result); -- 2.7.3

Space required around arithmetic and logical operators Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 1f1209f..24e7f5d 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2819,9 +2819,9 @@ PHP_FUNCTION(libvirt_connect_get_information) VIRT_ADD_ASSOC_STRING(return_value, "hypervisor", (char *)type); add_assoc_long(return_value, "hypervisor_major", (long)((hvVer/1000000) % 1000)); add_assoc_long(return_value, "hypervisor_minor", (long)((hvVer/1000) % 1000)); - add_assoc_long(return_value, "hypervisor_release", (long)(hvVer %1000)); + add_assoc_long(return_value, "hypervisor_release", (long)(hvVer % 1000)); snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type, - (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000)); + (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer % 1000)); VIRT_ADD_ASSOC_STRING(return_value, "hypervisor_string", hvStr); } @@ -3067,10 +3067,10 @@ PHP_FUNCTION(libvirt_connect_get_hypervisor) VIRT_ADD_ASSOC_STRING(return_value, "hypervisor", (char *)type); add_assoc_long(return_value, "major", (long)((hvVer/1000000) % 1000)); add_assoc_long(return_value, "minor", (long)((hvVer/1000) % 1000)); - add_assoc_long(return_value, "release", (long)(hvVer %1000)); + add_assoc_long(return_value, "release", (long)(hvVer % 1000)); snprintf(hvStr, sizeof(hvStr), "%s %d.%d.%d", type, - (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer %1000)); + (long)((hvVer/1000000) % 1000), (long)((hvVer/1000) % 1000), (long)(hvVer % 1000)); VIRT_ADD_ASSOC_STRING(return_value, "hypervisor_string", hvStr); } @@ -4409,7 +4409,7 @@ PHP_FUNCTION(libvirt_stream_create) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zconn) == FAILURE) RETURN_FALSE; VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection); - if ((conn == NULL)||(conn->conn == NULL)) + if ((conn == NULL) || (conn->conn == NULL)) RETURN_FALSE; stream = virStreamNew(conn->conn, 0); @@ -4446,7 +4446,7 @@ PHP_FUNCTION(libvirt_stream_close) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL)) + if ((stream == NULL) || (stream->stream == NULL)) RETURN_LONG(retval); retval = virStreamFree(stream->stream); @@ -4475,7 +4475,7 @@ PHP_FUNCTION(libvirt_stream_abort) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL)) + if ((stream == NULL) || (stream->stream == NULL)) RETURN_LONG(retval); retval = virStreamAbort(stream->stream); @@ -4502,7 +4502,7 @@ PHP_FUNCTION(libvirt_stream_finish) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstream) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL)) + if ((stream == NULL) || (stream->stream == NULL)) RETURN_LONG(retval); retval = virStreamFinish(stream->stream); @@ -4533,7 +4533,7 @@ PHP_FUNCTION(libvirt_stream_recv) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL)) + if ((stream == NULL) || (stream->stream == NULL)) RETURN_LONG(retval); recv_buf = emalloc(length + 1); @@ -4583,7 +4583,7 @@ PHP_FUNCTION(libvirt_stream_send) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rz|l", &zstream, &zbuf, &length) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL)) + if ((stream == NULL) || (stream->stream == NULL)) RETURN_LONG(retval); cstr = Z_STRVAL_P(zbuf); @@ -5949,7 +5949,7 @@ PHP_FUNCTION(libvirt_domain_change_memory) // pos = strlen(xml) - strlen(tmp1); len = strlen(xml) - strlen(tmpA); - tmp2 = (char *)emalloc((len + 1)* sizeof(char)); + tmp2 = (char *)emalloc((len + 1) * sizeof(char)); memset(tmp2, 0, len + 1); memcpy(tmp2, xml, len); @@ -6033,7 +6033,7 @@ PHP_FUNCTION(libvirt_domain_change_boot_devices) // pos = strlen(xml) - strlen(tmp1); len = strlen(xml) - strlen(tmpA); - tmp2 = (char *)emalloc((len + 1)* sizeof(char)); + tmp2 = (char *)emalloc((len + 1) * sizeof(char)); memset(tmp2, 0, len + 1); memcpy(tmp2, xml, len); @@ -8202,10 +8202,10 @@ PHP_FUNCTION(libvirt_storagevolume_create_xml_from) } VIRT_FETCH_RESOURCE(pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool); - if ((pool == NULL)||(pool->pool == NULL)) + if ((pool == NULL) || (pool->pool == NULL)) RETURN_FALSE; VIRT_FETCH_RESOURCE(pl_volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); - if ((pl_volume == NULL)||(pl_volume->volume == NULL)) + if ((pl_volume == NULL) || (pl_volume->volume == NULL)) RETURN_FALSE; resource_change_counter(INT_RESOURCE_VOLUME, NULL, pl_volume->volume, 1 TSRMLS_CC); @@ -8308,10 +8308,10 @@ PHP_FUNCTION(libvirt_storagevolume_download) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); - if ((volume == NULL)||(volume->volume == NULL)) + if ((volume == NULL) || (volume->volume == NULL)) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL)) + if ((stream == NULL) || (stream->stream == NULL)) RETURN_LONG(retval); retval = virStorageVolDownload(volume->volume, stream->stream, offset, length, flags); @@ -8350,10 +8350,10 @@ PHP_FUNCTION(libvirt_storagevolume_upload) if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr|l|l|l", &zvolume, &zstream, &offset, &length, &flags) == FAILURE) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume); - if ((volume == NULL)||(volume->volume == NULL)) + if ((volume == NULL) || (volume->volume == NULL)) RETURN_LONG(retval); VIRT_FETCH_RESOURCE(stream, php_libvirt_stream*, &zstream, PHP_LIBVIRT_STREAM_RES_NAME, le_libvirt_stream); - if ((stream == NULL)||(stream->stream == NULL)) + if ((stream == NULL) || (stream->stream == NULL)) RETURN_LONG(retval); retval = virStorageVolUpload(volume->volume, stream->stream, offset, length, flags); @@ -8909,7 +8909,7 @@ PHP_FUNCTION(libvirt_list_domains) DPRINTF("%s: Found %d domains\n", PHPFUNC, expectedcount); - ids = (int *)emalloc(sizeof(int)*expectedcount); + ids = (int *)emalloc(sizeof(int) * expectedcount); count = virConnectListDomains(conn->conn, ids, expectedcount); DPRINTF("%s: virConnectListDomains returned %d domains\n", PHPFUNC, count); @@ -8990,7 +8990,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) if ((expectedcount = virConnectNumOfDomains(conn->conn)) < 0) RETURN_FALSE; - ids = (int *)emalloc(sizeof(int)*expectedcount); + ids = (int *)emalloc(sizeof(int) * expectedcount); count = virConnectListDomains(conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { efree(ids); @@ -9071,7 +9071,7 @@ PHP_FUNCTION(libvirt_list_active_domain_ids) if ((expectedcount = virConnectNumOfDomains (conn->conn)) < 0) RETURN_FALSE; - ids = (int *)emalloc(sizeof(int)*expectedcount); + ids = (int *)emalloc(sizeof(int) * expectedcount); count = virConnectListDomains(conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { efree(ids); @@ -9106,7 +9106,7 @@ PHP_FUNCTION(libvirt_list_active_domains) if ((expectedcount = virConnectNumOfDomains (conn->conn)) < 0) RETURN_FALSE; - ids = (int *)emalloc(sizeof(int)*expectedcount); + ids = (int *)emalloc(sizeof(int) * expectedcount); count = virConnectListDomains(conn->conn, ids, expectedcount); if ((count != expectedcount) || (count<0)) { efree(ids); @@ -9889,7 +9889,7 @@ PHP_FUNCTION(libvirt_version) /* The version is returned as: major * 1,000,000 + minor * 1,000 + release. */ array_init(return_value); - add_assoc_long(return_value, "libvirt.release", (long)(libVer %1000)); + add_assoc_long(return_value, "libvirt.release", (long)(libVer % 1000)); add_assoc_long(return_value, "libvirt.minor", (long)((libVer/1000) % 1000)); add_assoc_long(return_value, "libvirt.major", (long)((libVer/1000000) % 1000)); @@ -9899,7 +9899,7 @@ PHP_FUNCTION(libvirt_version) add_assoc_long(return_value, "connector.release", VERSION_MICRO); if (ZEND_NUM_ARGS() > 0) { - add_assoc_long(return_value, "type.release", (long)(typeVer %1000)); + add_assoc_long(return_value, "type.release", (long)(typeVer % 1000)); add_assoc_long(return_value, "type.minor", (long)((typeVer/1000) % 1000)); add_assoc_long(return_value, "type.major", (long)((typeVer/1000000) % 1000)); } @@ -9943,7 +9943,7 @@ PHP_FUNCTION(libvirt_check_version) if ((((libVer/1000000) % 1000) > major) || ((((libVer/1000000) % 1000) == major) && (((libVer/1000) % 1000) > minor)) || ((((libVer/1000000) % 1000) == major) && (((libVer/1000) % 1000) == minor) && - ((libVer %1000) >= micro))) + ((libVer % 1000) >= micro))) RETURN_TRUE; } else { set_error("Invalid version type" TSRMLS_CC); -- 2.7.3

Fix some remaining issues about missing spaces around comparison operators and remove extra spaces Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 24e7f5d..2fb8d60 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2239,7 +2239,7 @@ PHP_FUNCTION(libvirt_connect) if (virGetVersion(&libVer, NULL, NULL)!= 0) RETURN_FALSE; - if (libVer<6002) { + if (libVer < 6002) { set_error("Only libvirt 0.6.2 and higher supported. Please upgrade your libvirt" TSRMLS_CC); RETURN_FALSE; } @@ -4267,7 +4267,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_name) php_libvirt_domain *res_domain; GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); - if ((name == NULL) || (name_len<1)) + if ((name == NULL) || (name_len < 1)) RETURN_FALSE; domain = virDomainLookupByName(conn->conn, name); if (domain == NULL) @@ -4305,7 +4305,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid) GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); - if ((uuid == NULL) || (uuid_len<1)) + if ((uuid == NULL) || (uuid_len < 1)) RETURN_FALSE; domain = virDomainLookupByUUID(conn->conn, uuid); if (domain == NULL) @@ -4373,7 +4373,7 @@ PHP_FUNCTION(libvirt_domain_lookup_by_uuid_string) GET_CONNECTION_FROM_ARGS("rs", &zconn, &uuid, &uuid_len); - if ((uuid == NULL) || (uuid_len<1)) + if ((uuid == NULL) || (uuid_len < 1)) RETURN_FALSE; domain = virDomainLookupByUUIDString(conn->conn, uuid); if (domain == NULL) @@ -7623,7 +7623,7 @@ PHP_FUNCTION(libvirt_domain_snapshot_lookup_by_name) GET_DOMAIN_FROM_ARGS("rs|l", &zdomain, &name, &name_len, &flags); - if ((name == NULL) || (name_len<1)) + if ((name == NULL) || (name_len < 1)) RETURN_FALSE; snapshot=virDomainSnapshotLookupByName(domain->domain, name, flags); if (snapshot == NULL) @@ -7779,7 +7779,7 @@ PHP_FUNCTION(libvirt_list_domain_snapshots) count = virDomainSnapshotListNames(domain->domain, names, expectedcount, 0); } - if ((count != expectedcount) || (count<0)) { + if ((count != expectedcount) || (count < 0)) { RETURN_FALSE; } else { array_init(return_value); @@ -7812,7 +7812,7 @@ PHP_FUNCTION(libvirt_storagepool_lookup_by_name) GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); - if ((name == NULL) || (name_len<1)) + if ((name == NULL) || (name_len < 1)) RETURN_FALSE; pool = virStoragePoolLookupByName(conn->conn, name); DPRINTF("%s: virStoragePoolLookupByName(%p, %s) returned %p\n", PHPFUNC, conn->conn, name, pool); @@ -7896,7 +7896,7 @@ PHP_FUNCTION(libvirt_storagepool_list_volumes) DPRINTF("%s: virStoragePoolListVolumes(%p,%p,%d) returned %d\n", PHPFUNC, pool->pool, names, expectedcount, count); array_init(return_value); - if ((count != expectedcount) || (count<0)) + if ((count != expectedcount) || (count < 0)) RETURN_FALSE; for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); @@ -7955,7 +7955,7 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_name) virStorageVolPtr volume = NULL; GET_STORAGEPOOL_FROM_ARGS("rs", &zpool, &name, &name_len); - if ((name == NULL) || (name_len<1)) + if ((name == NULL) || (name_len < 1)) RETURN_FALSE; volume = virStorageVolLookupByName(pool->pool, name); @@ -7994,7 +7994,7 @@ PHP_FUNCTION(libvirt_storagevolume_lookup_by_path) virStorageVolPtr volume = NULL; GET_CONNECTION_FROM_ARGS("rs", &zconn, &name, &name_len); - if ((name == NULL) || (name_len<1)) + if ((name == NULL) || (name_len < 1)) RETURN_FALSE; volume = virStorageVolLookupByPath(conn->conn, name); @@ -8576,7 +8576,7 @@ PHP_FUNCTION(libvirt_storagepool_create) GET_STORAGEPOOL_FROM_ARGS("r", &zpool); - retval = virStoragePoolCreate (pool->pool, 0); + retval = virStoragePoolCreate(pool->pool, 0); DPRINTF("%s: virStoragePoolCreate(%p, 0) returned %d\n", PHPFUNC, pool->pool, retval); if (retval != 0) RETURN_FALSE; @@ -8782,7 +8782,7 @@ PHP_FUNCTION(libvirt_list_storagepools) names = (char **)emalloc(expectedcount*sizeof(char *)); count = virConnectListStoragePools(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) { + if ((count != expectedcount) || (count < 0)) { efree(names); RETURN_FALSE; } @@ -8835,7 +8835,7 @@ PHP_FUNCTION(libvirt_list_active_storagepools) names = (char **)emalloc(expectedcount*sizeof(char *)); count = virConnectListStoragePools(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) { + if ((count != expectedcount) || (count < 0)) { efree(names); RETURN_FALSE; } @@ -8992,7 +8992,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) ids = (int *)emalloc(sizeof(int) * expectedcount); count = virConnectListDomains(conn->conn, ids, expectedcount); - if ((count != expectedcount) || (count<0)) { + if ((count != expectedcount) || (count < 0)) { efree(ids); RETURN_FALSE; } @@ -9023,7 +9023,7 @@ PHP_FUNCTION(libvirt_list_domain_resources) names = (char **)emalloc(expectedcount*sizeof(char *)); count = virConnectListDefinedDomains(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) { + if ((count != expectedcount) || (count < 0)) { efree(names); RETURN_FALSE; } @@ -9068,12 +9068,12 @@ PHP_FUNCTION(libvirt_list_active_domain_ids) GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount = virConnectNumOfDomains (conn->conn)) < 0) + if ((expectedcount = virConnectNumOfDomains(conn->conn)) < 0) RETURN_FALSE; ids = (int *)emalloc(sizeof(int) * expectedcount); count = virConnectListDomains(conn->conn, ids, expectedcount); - if ((count != expectedcount) || (count<0)) { + if ((count != expectedcount) || (count < 0)) { efree(ids); RETURN_FALSE; } @@ -9103,12 +9103,12 @@ PHP_FUNCTION(libvirt_list_active_domains) GET_CONNECTION_FROM_ARGS("r", &zconn); - if ((expectedcount = virConnectNumOfDomains (conn->conn)) < 0) + if ((expectedcount = virConnectNumOfDomains(conn->conn)) < 0) RETURN_FALSE; ids = (int *)emalloc(sizeof(int) * expectedcount); count = virConnectListDomains(conn->conn, ids, expectedcount); - if ((count != expectedcount) || (count<0)) { + if ((count != expectedcount) || (count < 0)) { efree(ids); RETURN_FALSE; } @@ -9154,7 +9154,7 @@ PHP_FUNCTION(libvirt_list_inactive_domains) names = (char **)emalloc(expectedcount*sizeof(char *)); count = virConnectListDefinedDomains(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) { + if ((count != expectedcount) || (count < 0)) { efree(names); RETURN_FALSE; } @@ -9194,7 +9194,7 @@ PHP_FUNCTION(libvirt_list_networks) names = (char **)emalloc(expectedcount*sizeof(char *)); count = virConnectListNetworks(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) { + if ((count != expectedcount) || (count < 0)) { efree(names); RETURN_FALSE; } @@ -9213,7 +9213,7 @@ PHP_FUNCTION(libvirt_list_networks) RETURN_FALSE; names = (char **)emalloc(expectedcount*sizeof(char *)); count = virConnectListDefinedNetworks(conn->conn, names, expectedcount); - if ((count != expectedcount) || (count<0)) { + if ((count != expectedcount) || (count < 0)) { efree(names); RETURN_FALSE; } @@ -9256,7 +9256,7 @@ PHP_FUNCTION(libvirt_list_nodedevs) RETURN_FALSE; names = (char **)emalloc(expectedcount*sizeof(char *)); count = virNodeListDevices(conn->conn, cap, names, expectedcount, 0); - if ((count != expectedcount) || (count<0)) { + if ((count != expectedcount) || (count < 0)) { efree(names); RETURN_FALSE; } @@ -9330,7 +9330,7 @@ PHP_FUNCTION(libvirt_nodedev_capabilities) RETURN_FALSE; names = (char **)emalloc(expectedcount*sizeof(char *)); count = virNodeDeviceListCaps(nodedev->device, names, expectedcount); - if ((count != expectedcount) || (count<0)) + if ((count != expectedcount) || (count < 0)) RETURN_FALSE; array_init(return_value); -- 2.7.3

Signed-off-by: Katerina Koukiou <k.koukiou@gmail.com> --- src/libvirt-php.c | 208 +++++++++++++++++++++++++++++------------------------- 1 file changed, 110 insertions(+), 98 deletions(-) diff --git a/src/libvirt-php.c b/src/libvirt-php.c index 2fb8d60..b0bbd8f 100644 --- a/src/libvirt-php.c +++ b/src/libvirt-php.c @@ -2046,109 +2046,121 @@ PHP_MSHUTDOWN_FUNCTION(libvirt) } /* Macros for obtaining resources from arguments */ -#define GET_CONNECTION_FROM_ARGS(args, ...) \ - reset_error(TSRMLS_C); \ -if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) {\ - set_error("Invalid arguments" TSRMLS_CC); \ - RETURN_FALSE;\ -}\ -\ -VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection);\ -if ((conn == NULL) || (conn->conn == NULL)) \ - RETURN_FALSE;\ - -#define GET_DOMAIN_FROM_ARGS(args, ...) \ - reset_error(TSRMLS_C); \ -if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) {\ - set_error("Invalid arguments" TSRMLS_CC); \ - RETURN_FALSE;\ -}\ -\ -VIRT_FETCH_RESOURCE(domain, php_libvirt_domain*, &zdomain, PHP_LIBVIRT_DOMAIN_RES_NAME, le_libvirt_domain);\ -if ((domain == NULL) || (domain->domain == NULL)) \ - RETURN_FALSE;\ - -#define GET_NETWORK_FROM_ARGS(args, ...) \ - reset_error(TSRMLS_C); \ -if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) {\ - set_error("Invalid arguments" TSRMLS_CC);\ - RETURN_FALSE;\ -}\ -\ -VIRT_FETCH_RESOURCE(network, php_libvirt_network*, &znetwork, PHP_LIBVIRT_NETWORK_RES_NAME, le_libvirt_network);\ -if ((network == NULL) || (network->network == NULL)) \ - RETURN_FALSE;\ - -#define GET_NODEDEV_FROM_ARGS(args, ...) \ - reset_error(TSRMLS_C); \ -if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) {\ - set_error("Invalid arguments" TSRMLS_CC);\ - RETURN_FALSE;\ -}\ -\ -VIRT_FETCH_RESOURCE(nodedev, php_libvirt_nodedev*, &znodedev, PHP_LIBVIRT_NODEDEV_RES_NAME, le_libvirt_nodedev);\ -if ((nodedev == NULL) || (nodedev->device == NULL)) \ - RETURN_FALSE;\ - -#define GET_STORAGEPOOL_FROM_ARGS(args, ...) \ - reset_error(TSRMLS_C); \ -if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) {\ - set_error("Invalid arguments" TSRMLS_CC);\ - RETURN_FALSE;\ -}\ -\ -VIRT_FETCH_RESOURCE(pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool);\ -if ((pool == NULL) || (pool->pool == NULL)) \ - RETURN_FALSE;\ - -#define GET_VOLUME_FROM_ARGS(args, ...) \ - reset_error(TSRMLS_C); \ -if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) {\ - set_error("Invalid arguments" TSRMLS_CC);\ - RETURN_FALSE;\ -}\ -\ -VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);\ -if ((volume == NULL) || (volume->volume == NULL)) \ - RETURN_FALSE;\ - -#define GET_SNAPSHOT_FROM_ARGS(args, ...) \ - reset_error(TSRMLS_C); \ -if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) {\ - set_error("Invalid arguments" TSRMLS_CC);\ - RETURN_FALSE;\ -}\ -\ -VIRT_FETCH_RESOURCE(snapshot, php_libvirt_snapshot*, &zsnapshot, PHP_LIBVIRT_SNAPSHOT_RES_NAME, le_libvirt_snapshot);\ -if ((snapshot == NULL) || (snapshot->snapshot == NULL)) \ - RETURN_FALSE;\ +#define GET_CONNECTION_FROM_ARGS(args, ...) \ + do { \ + reset_error(TSRMLS_C); \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) { \ + set_error("Invalid arguments" TSRMLS_CC); \ + RETURN_FALSE; \ + } \ + \ + VIRT_FETCH_RESOURCE(conn, php_libvirt_connection*, &zconn, PHP_LIBVIRT_CONNECTION_RES_NAME, le_libvirt_connection);\ + if ((conn == NULL) || (conn->conn == NULL)) \ + RETURN_FALSE; \ + } while (0) \ + +#define GET_DOMAIN_FROM_ARGS(args, ...) \ + do { \ + reset_error(TSRMLS_C); \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) { \ + set_error("Invalid arguments" TSRMLS_CC); \ + RETURN_FALSE; \ + } \ + \ + VIRT_FETCH_RESOURCE(domain, php_libvirt_domain*, &zdomain, PHP_LIBVIRT_DOMAIN_RES_NAME, le_libvirt_domain);\ + if ((domain == NULL) || (domain->domain == NULL)) \ + RETURN_FALSE; \ + } while (0) \ + +#define GET_NETWORK_FROM_ARGS(args, ...) \ + do { \ + reset_error(TSRMLS_C); \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) { \ + set_error("Invalid arguments" TSRMLS_CC); \ + RETURN_FALSE; \ + } \ + \ + VIRT_FETCH_RESOURCE(network, php_libvirt_network*, &znetwork, PHP_LIBVIRT_NETWORK_RES_NAME, le_libvirt_network);\ + if ((network == NULL) || (network->network == NULL)) \ + RETURN_FALSE; \ + } while (0) \ + +#define GET_NODEDEV_FROM_ARGS(args, ...) \ + do { \ + reset_error(TSRMLS_C); \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) { \ + set_error("Invalid arguments" TSRMLS_CC); \ + RETURN_FALSE; \ + } \ + \ + VIRT_FETCH_RESOURCE(nodedev, php_libvirt_nodedev*, &znodedev, PHP_LIBVIRT_NODEDEV_RES_NAME, le_libvirt_nodedev);\ + if ((nodedev == NULL) || (nodedev->device == NULL)) \ + RETURN_FALSE; \ + } while (0) + +#define GET_STORAGEPOOL_FROM_ARGS(args, ...) \ + do { \ + reset_error(TSRMLS_C); \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) { \ + set_error("Invalid arguments" TSRMLS_CC); \ + RETURN_FALSE; \ + } \ + \ + VIRT_FETCH_RESOURCE(pool, php_libvirt_storagepool*, &zpool, PHP_LIBVIRT_STORAGEPOOL_RES_NAME, le_libvirt_storagepool);\ + if ((pool == NULL) || (pool->pool == NULL)) \ + RETURN_FALSE; \ + } while (0) \ + +#define GET_VOLUME_FROM_ARGS(args, ...) \ + do { \ + reset_error(TSRMLS_C); \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) { \ + set_error("Invalid arguments" TSRMLS_CC); \ + RETURN_FALSE; \ + } \ + \ + VIRT_FETCH_RESOURCE(volume, php_libvirt_volume*, &zvolume, PHP_LIBVIRT_VOLUME_RES_NAME, le_libvirt_volume);\ + if ((volume == NULL) || (volume->volume == NULL)) \ + RETURN_FALSE; \ + } while (0) \ + +#define GET_SNAPSHOT_FROM_ARGS(args, ...) \ + do { \ + reset_error(TSRMLS_C); \ + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, args, __VA_ARGS__) == FAILURE) { \ + set_error("Invalid arguments" TSRMLS_CC); \ + RETURN_FALSE; \ + } \ + \ + VIRT_FETCH_RESOURCE(snapshot, php_libvirt_snapshot*, &zsnapshot, PHP_LIBVIRT_SNAPSHOT_RES_NAME, le_libvirt_snapshot);\ + if ((snapshot == NULL) || (snapshot->snapshot == NULL)) \ + RETURN_FALSE; \ +} while (0) \ #define LONGLONG_INIT \ char tmpnumber[64] -#define LONGLONG_ASSOC(out, key, in) \ - if (LIBVIRT_G(longlong_to_string_ini)) { \ - snprintf(tmpnumber, 63, "%llu", in); \ - VIRT_ADD_ASSOC_STRING(out, key, tmpnumber); \ - } \ -else \ -{ \ - add_assoc_long(out, key, in); \ -} +#define LONGLONG_ASSOC(out, key, in) \ + if (LIBVIRT_G(longlong_to_string_ini)) { \ + snprintf(tmpnumber, 63, "%llu", in); \ + VIRT_ADD_ASSOC_STRING(out, key, tmpnumber); \ + } else { \ + add_assoc_long(out, key, in); \ + } -#define LONGLONG_INDEX(out, key, in) \ - if (LIBVIRT_G(longlong_to_string_ini)) { \ - snprintf(tmpnumber, 63, "%llu", in); \ - VIRT_ADD_INDEX_STRING(out, key, tmpnumber); \ - } \ -else \ -{ \ - add_index_long(out, key, in); \ -} +#define LONGLONG_INDEX(out, key, in) \ + if (LIBVIRT_G(longlong_to_string_ini)) { \ + snprintf(tmpnumber, 63, "%llu", in); \ + VIRT_ADD_INDEX_STRING(out, key, tmpnumber); \ + } else { \ + add_index_long(out, key, in); \ + } -#define LONGLONG_RETURN_AS_STRING(in) \ - snprintf(tmpnumber, 63, "%llu", in); \ - VIRT_RETURN_STRING(tmpnumber); +#define LONGLONG_RETURN_AS_STRING(in) \ + do { \ + snprintf(tmpnumber, 63, "%llu", in); \ + VIRT_RETURN_STRING(tmpnumber); \ + } while (0) /* Authentication callback function. Should receive list of credentials via cbdata and pass the requested one to libvirt */ @@ -7897,7 +7909,7 @@ PHP_FUNCTION(libvirt_storagepool_list_volumes) array_init(return_value); if ((count != expectedcount) || (count < 0)) - RETURN_FALSE; + RETURN_FALSE; for (i = 0; i < count; i++) { VIRT_ADD_NEXT_INDEX_STRING(return_value, names[i]); free(names[i]); -- 2.7.3

On 23.09.2016 20:49, Katerina Koukiou wrote:
Fixed some basic code styling issues in libvirt-php.c that made the code hard to read.
Katerina Koukiou (14): libvirt-php.c: Fix coding style issues: space required after ',' libvirt-php.c: Fix coding style issues: spaces required around '==', '>=', '<=' etc. libvirt-php.c: Fix coding style issues: space prohibited between function name and open parenthesis '(' libvirt-php.c: Fix coding style issues: remove unwanted spaces after '(' and before ')' libvirt-php.c: Fix code styling issues: no space needed after '[' and before ']' libvirt-php.c: Fix code styling issues: if then else statement style issues libvirt-php.c: Fix coding style issues with braces libvirt-php.c Fix coding style issues with if statements libvirt-php.c: Fix coding style issues: space required around '=' in assignments libvirt-php.c: Fix code styling issues with for loops libvirt-php.c: Fix coding style issues: "(foo*)" should be "(foo *)" libvirt-php.c: Fix coding style issues with operators libvirt-php.c: Fix coding style issues with extra/less spaces libvirt-php.c: Fix coding style issues in macros
src/libvirt-php.c | 2220 ++++++++++++++++++++++++++--------------------------- 1 file changed, 1101 insertions(+), 1119 deletions(-)
Hey, this is very awesome! Thank you for your patches. I reviewed them (thank God for 'git diff -w'). I've tried to check if fixed all the places, but it looks like you did (at least in some randomly picked patches :-)). But then there are other files in our source tree which suffer the same problems :-( ACKed and pushed. Michal
participants (2)
-
Katerina Koukiou
-
Michal Privoznik