[libvirt] [libvirt-php][PATCH 03/10] get_next_free_numeric_value: Use correct format for sscanf()

Michal Privoznik mprivozn at redhat.com
Tue May 5 09:59:54 UTC 2015


To parse a string, sscanf() is used. However, with wrong format:

libvirt-php.c: In function ‘get_next_free_numeric_value’:
libvirt-php.c:2719:6: warning: format ‘%x’ expects argument of type ‘unsigned int *’, but argument 3 has type ‘long int *’ [-Wformat=]
      sscanf(Z_STRVAL_PP(data), "%x", &num);
      ^

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/libvirt-php.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/libvirt-php.c b/src/libvirt-php.c
index 0adc4be..c35fa5b 100644
--- a/src/libvirt-php.c
+++ b/src/libvirt-php.c
@@ -2777,7 +2777,7 @@ long get_next_free_numeric_value(virDomainPtr domain, char *xpath)
 				if (zend_hash_get_current_key_ex(arr_hash, &key, &key_len, &index, 0, &pointer) != HASH_KEY_IS_STRING) {
 					long num = -1;
 
-					sscanf(Z_STRVAL_PP(data), "%x", &num);
+					sscanf(Z_STRVAL_PP(data), "%lx", &num);
 					if (num > max_slot)
 						max_slot = num;
 				}
-- 
2.3.6




More information about the libvir-list mailing list