Glib implementation follows the ISO C99 standard so it's safe to replace
the gnulib implementation.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
changes in v2:
- don't replace snprintf in tools/virt-login-shell.c
src/hyperv/hyperv_driver.c | 4 +-
src/libxl/libxl_conf.c | 22 +++++------
src/libxl/libxl_migration.c | 4 +-
src/lxc/lxc_process.c | 6 +--
src/nwfilter/nwfilter_ebiptables_driver.c | 36 +++++++++---------
src/nwfilter/nwfilter_learnipaddr.c | 2 +-
src/openvz/openvz_driver.c | 6 +--
src/qemu/qemu_agent.c | 46 +++++++++++------------
src/qemu/qemu_driver.c | 8 ++--
src/security/security_dac.c | 8 ++--
src/security/virt-aa-helper.c | 2 +-
src/storage/storage_util.c | 2 +-
src/util/virhostcpu.c | 2 +-
src/util/viriptables.c | 6 +--
src/util/virmacaddr.c | 8 ++--
src/util/virnetdevbridge.c | 4 +-
src/util/virnetdevmacvlan.c | 12 +++---
src/util/virpci.c | 4 +-
src/util/virpidfile.c | 4 +-
src/util/virtime.c | 10 ++---
src/util/virusb.c | 8 ++--
src/util/viruuid.c | 12 +++---
src/vbox/vbox_common.c | 24 ++++++------
src/vbox/vbox_tmpl.c | 2 +-
src/vmx/vmx.c | 18 ++++-----
src/vz/vz_driver.c | 22 +++++------
src/vz/vz_sdk.c | 8 ++--
tests/libxlmock.c | 2 +-
tests/qemuagenttest.c | 12 +++---
tests/testutils.c | 2 +-
tests/virnetsockettest.c | 2 +-
tests/virpcimock.c | 28 +++++++-------
tests/virsystemdtest.c | 4 +-
tools/virsh-domain-monitor.c | 2 +-
tools/virsh-domain.c | 2 +-
tools/virt-host-validate-common.c | 2 +-
tools/vsh-table.c | 6 +--
tools/vsh.c | 22 +++++------
tools/wireshark/src/packet-libvirt.c | 2 +-
39 files changed, 188 insertions(+), 188 deletions(-)
diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
index ac10f86b82..3a2f6602bc 100644
--- a/src/hyperv/hyperv_driver.c
+++ b/src/hyperv/hyperv_driver.c
@@ -1381,7 +1381,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset,
/* press the keys */
for (i = 0; i < nkeycodes; i++) {
- snprintf(keycodeStr, sizeof(keycodeStr), "%d", translatedKeycodes[i]);
+ g_snprintf(keycodeStr, sizeof(keycodeStr), "%d",
translatedKeycodes[i]);
params = hypervCreateInvokeParamsList(priv, "PressKey", selector,
Msvm_Keyboard_WmiInfo);
@@ -1409,7 +1409,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset,
/* release the keys */
for (i = 0; i < nkeycodes; i++) {
- snprintf(keycodeStr, sizeof(keycodeStr), "%d", translatedKeycodes[i]);
+ g_snprintf(keycodeStr, sizeof(keycodeStr), "%d",
translatedKeycodes[i]);
params = hypervCreateInvokeParamsList(priv, "ReleaseKey", selector,
Msvm_Keyboard_WmiInfo);
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 920f228d6a..71a503c0f7 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -419,12 +419,12 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
continue;
}
- snprintf(xlCPU,
- sizeof(xlCPU),
- "%s=0",
- xenTranslateCPUFeature(
- def->cpu->features[i].name,
- false));
+ g_snprintf(xlCPU,
+ sizeof(xlCPU),
+ "%s=0",
+ xenTranslateCPUFeature(
+ def->cpu->features[i].name,
+ false));
if (libxl_cpuid_parse_config(&b_info->cpuid, xlCPU))
{
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported cpu feature
'%s'"),
@@ -441,11 +441,11 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
continue;
}
- snprintf(xlCPU,
- sizeof(xlCPU),
- "%s=1",
- xenTranslateCPUFeature(
- def->cpu->features[i].name, false));
+ g_snprintf(xlCPU,
+ sizeof(xlCPU),
+ "%s=1",
+ xenTranslateCPUFeature(
+ def->cpu->features[i].name, false));
if (libxl_cpuid_parse_config(&b_info->cpuid, xlCPU))
{
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unsupported cpu feature
'%s'"),
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index b223916647..287772be73 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -745,7 +745,7 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn,
*uri_out = g_strdup_printf("tcp://%s:%d", hostname, port);
}
- snprintf(portstr, sizeof(portstr), "%d", port);
+ g_snprintf(portstr, sizeof(portstr), "%d", port);
if (virNetSocketNewListenTCP(hostname, portstr,
AF_UNSPEC,
@@ -1221,7 +1221,7 @@ libxlDomainMigrationSrcPerform(libxlDriverPrivatePtr driver,
hostname = uri->server;
port = uri->port;
- snprintf(portstr, sizeof(portstr), "%d", port);
+ g_snprintf(portstr, sizeof(portstr), "%d", port);
/* socket connect to dst host:port */
if (virNetSocketNewConnectTCP(hostname, portstr,
diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c
index 8ca3710436..012d482337 100644
--- a/src/lxc/lxc_process.c
+++ b/src/lxc/lxc_process.c
@@ -1415,10 +1415,10 @@ int virLXCProcessStart(virConnectPtr conn,
if (virLXCProcessReadLogOutput(vm, logfile, pos, ebuf,
sizeof(ebuf)) <= 0) {
if (WIFEXITED(status))
- snprintf(ebuf, sizeof(ebuf), _("unexpected exit status %d"),
- WEXITSTATUS(status));
+ g_snprintf(ebuf, sizeof(ebuf), _("unexpected exit status %d"),
+ WEXITSTATUS(status));
else
- snprintf(ebuf, sizeof(ebuf), "%s", _("terminated
abnormally"));
+ g_snprintf(ebuf, sizeof(ebuf), "%s", _("terminated
abnormally"));
}
virReportError(VIR_ERR_INTERNAL_ERROR,
_("guest failed to start: %s"), ebuf);
diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c
b/src/nwfilter/nwfilter_ebiptables_driver.c
index 6f1887977b..0cf8149193 100644
--- a/src/nwfilter/nwfilter_ebiptables_driver.c
+++ b/src/nwfilter/nwfilter_ebiptables_driver.c
@@ -76,9 +76,9 @@ enum ctdirStatus {
static enum ctdirStatus iptables_ctdir_corrected;
#define PRINT_ROOT_CHAIN(buf, prefix, ifname) \
- snprintf(buf, sizeof(buf), "libvirt-%c-%s", prefix, ifname)
+ g_snprintf(buf, sizeof(buf), "libvirt-%c-%s", prefix, ifname)
#define PRINT_CHAIN(buf, prefix, ifname, suffix) \
- snprintf(buf, sizeof(buf), "%c-%s-%s", prefix, ifname, suffix)
+ g_snprintf(buf, sizeof(buf), "%c-%s-%s", prefix, ifname, suffix)
#define VIRT_IN_CHAIN "libvirt-in"
#define VIRT_OUT_CHAIN "libvirt-out"
@@ -86,7 +86,7 @@ static enum ctdirStatus iptables_ctdir_corrected;
#define HOST_IN_CHAIN "libvirt-host-in"
#define PRINT_IPT_ROOT_CHAIN(buf, prefix, ifname) \
- snprintf(buf, sizeof(buf), "%c%c-%s", prefix[0], prefix[1], ifname)
+ g_snprintf(buf, sizeof(buf), "%c%c-%s", prefix[0], prefix[1], ifname)
static bool newMatchState;
@@ -204,7 +204,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
data = virSocketAddrFormat(&item->u.ipaddr);
if (!data)
return -1;
- if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
+ if (g_snprintf(buf, bufsize, "%s", data) >= bufsize) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("buffer too small for IP address"));
VIR_FREE(data);
@@ -218,7 +218,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
if (!data)
return -1;
- if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
+ if (g_snprintf(buf, bufsize, "%s", data) >= bufsize) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("buffer too small for IPv6 address"));
VIR_FREE(data);
@@ -240,8 +240,8 @@ _printDataType(virNWFilterVarCombIterPtr vars,
case DATATYPE_IPV6MASK:
case DATATYPE_IPMASK:
- if (snprintf(buf, bufsize, "%d",
- item->u.u8) >= bufsize) {
+ if (g_snprintf(buf, bufsize, "%d",
+ item->u.u8) >= bufsize) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint8 type"));
return -1;
@@ -250,8 +250,8 @@ _printDataType(virNWFilterVarCombIterPtr vars,
case DATATYPE_UINT32:
case DATATYPE_UINT32_HEX:
- if (snprintf(buf, bufsize, asHex ? "0x%x" : "%u",
- item->u.u32) >= bufsize) {
+ if (g_snprintf(buf, bufsize, asHex ? "0x%x" : "%u",
+ item->u.u32) >= bufsize) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint32 type"));
return -1;
@@ -260,8 +260,8 @@ _printDataType(virNWFilterVarCombIterPtr vars,
case DATATYPE_UINT16:
case DATATYPE_UINT16_HEX:
- if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
- item->u.u16) >= bufsize) {
+ if (g_snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
+ item->u.u16) >= bufsize) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint16 type"));
return -1;
@@ -270,8 +270,8 @@ _printDataType(virNWFilterVarCombIterPtr vars,
case DATATYPE_UINT8:
case DATATYPE_UINT8_HEX:
- if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
- item->u.u8) >= bufsize) {
+ if (g_snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
+ item->u.u8) >= bufsize) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("Buffer too small for uint8 type"));
return -1;
@@ -3192,11 +3192,11 @@ iptablesCheckBridgeNFCallEnabled(bool isIPv6)
if (read(fd, buffer, 1) == 1) {
if (buffer[0] == '0') {
char msg[256];
- snprintf(msg, sizeof(msg),
- _("To enable ip%stables filtering for the VM do "
- "'echo 1 > %s'"),
- isIPv6 ? "6" : "",
- pathname);
+ g_snprintf(msg, sizeof(msg),
+ _("To enable ip%stables filtering for the VM do
"
+ "'echo 1 > %s'"),
+ isIPv6 ? "6" : "",
+ pathname);
VIR_WARN("%s", msg);
if (isIPv6)
lastReportIPv6 = now;
diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c
index 293007300a..08ef02be7c 100644
--- a/src/nwfilter/nwfilter_learnipaddr.c
+++ b/src/nwfilter/nwfilter_learnipaddr.c
@@ -61,7 +61,7 @@ VIR_LOG_INIT("nwfilter.nwfilter_learnipaddr");
#define IFINDEX2STR(VARNAME, ifindex) \
char VARNAME[INT_BUFSIZE_BOUND(ifindex)]; \
- snprintf(VARNAME, sizeof(VARNAME), "%d", ifindex);
+ g_snprintf(VARNAME, sizeof(VARNAME), "%d", ifindex);
#define PKT_TIMEOUT_MS 500 /* ms */
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index 8a24c9265f..e07b3b302d 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -1248,7 +1248,7 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
if (pcpus > 0 && pcpus < nvcpus)
nvcpus = pcpus;
- snprintf(str_vcpus, sizeof(str_vcpus), "%d", nvcpus);
+ g_snprintf(str_vcpus, sizeof(str_vcpus), "%d", nvcpus);
openvzSetProgramSentinal(prog, vm->def->name);
if (virRun(prog, NULL) < 0)
@@ -1503,7 +1503,7 @@ static int openvzConnectListDefinedDomains(virConnectPtr conn
G_GNUC_UNUSED,
_("Could not parse VPS ID %s"), buf);
continue;
}
- snprintf(vpsname, sizeof(vpsname), "%d", veid);
+ g_snprintf(vpsname, sizeof(vpsname), "%d", veid);
names[got] = g_strdup(vpsname);
got ++;
}
@@ -1600,7 +1600,7 @@ openvzDomainSetMemoryInternal(virDomainObjPtr vm,
};
/* memory has to be changed its format from kbyte to byte */
- snprintf(str_mem, sizeof(str_mem), "%llu", mem * 1024);
+ g_snprintf(str_mem, sizeof(str_mem), "%llu", mem * 1024);
openvzSetProgramSentinal(prog, vm->def->name);
if (virRun(prog, NULL) < 0)
diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index 5a50f7f3be..7c0d8b83f7 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -2227,61 +2227,61 @@ qemuAgentGetFSInfoParams(qemuAgentPtr mon,
for (i = 0; i < nfs; i++) {
char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.name", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.name", i);
if (virTypedParamsAddString(params, nparams, maxparams,
param_name, fsinfo[i]->name) < 0)
goto cleanup;
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.mountpoint", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.mountpoint", i);
if (virTypedParamsAddString(params, nparams, maxparams,
param_name, fsinfo[i]->mountpoint) < 0)
goto cleanup;
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.fstype", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.fstype", i);
if (virTypedParamsAddString(params, nparams, maxparams,
param_name, fsinfo[i]->fstype) < 0)
goto cleanup;
/* disk usage values are not returned by older guest agents, so
* only add the params if the value is set */
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.total-bytes", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.total-bytes", i);
if (fsinfo[i]->total_bytes != -1 &&
virTypedParamsAddULLong(params, nparams, maxparams,
param_name, fsinfo[i]->total_bytes) < 0)
goto cleanup;
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.used-bytes", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.used-bytes", i);
if (fsinfo[i]->used_bytes != -1 &&
virTypedParamsAddULLong(params, nparams, maxparams,
param_name, fsinfo[i]->used_bytes) < 0)
goto cleanup;
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.disk.count", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.disk.count", i);
if (virTypedParamsAddUInt(params, nparams, maxparams,
param_name, fsinfo[i]->ndisks) < 0)
goto cleanup;
for (j = 0; j < fsinfo[i]->ndisks; j++) {
qemuAgentDiskInfoPtr d = fsinfo[i]->disks[j];
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.disk.%zu.alias", i, j);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.disk.%zu.alias", i, j);
if (d->alias &&
virTypedParamsAddString(params, nparams, maxparams,
param_name, d->alias) < 0)
goto cleanup;
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.disk.%zu.serial", i, j);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.disk.%zu.serial", i, j);
if (d->serial &&
virTypedParamsAddString(params, nparams, maxparams,
param_name, d->serial) < 0)
goto cleanup;
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "fs.%zu.disk.%zu.device", i, j);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "fs.%zu.disk.%zu.device", i, j);
if (d->devnode &&
virTypedParamsAddString(params, nparams, maxparams,
param_name, d->devnode) < 0)
@@ -2587,15 +2587,15 @@ qemuAgentGetUsers(qemuAgentPtr mon,
return -1;
}
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "user.%zu.name",
i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "user.%zu.name",
i);
if (virTypedParamsAddString(params, nparams, maxparams,
param_name, strvalue) < 0)
return -1;
/* 'domain' is only present for windows guests */
if ((strvalue = virJSONValueObjectGetString(entry, "domain"))) {
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "user.%zu.domain", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "user.%zu.domain", i);
if (virTypedParamsAddString(params, nparams, maxparams,
param_name, strvalue) < 0)
return -1;
@@ -2606,8 +2606,8 @@ qemuAgentGetUsers(qemuAgentPtr mon,
_("'login-time' missing in reply of
guest-get-users"));
return -1;
}
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "user.%zu.login-time", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "user.%zu.login-time", i);
if (virTypedParamsAddULLong(params, nparams, maxparams,
param_name, logintime * 1000) < 0)
return -1;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c969a3d463..6bb8dd27b2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -5107,8 +5107,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps)
< 0)
goto cleanup;
- if (snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
- VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) {
+ if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
+ VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) {
goto cleanup;
}
@@ -5802,8 +5802,8 @@ qemuDomainPinIOThread(virDomainPtr dom,
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps)
< 0)
goto endjob;
- if (snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
- VIR_DOMAIN_TUNABLE_CPU_IOTHREADSPIN, iothread_id) < 0) {
+ if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
+ VIR_DOMAIN_TUNABLE_CPU_IOTHREADSPIN, iothread_id) < 0) {
goto endjob;
}
diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index 56cca6cf9c..a9a1fad5d7 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -2342,8 +2342,8 @@ virSecurityDACGetProcessLabelInternal(pid_t pid,
goto cleanup;
}
- snprintf(seclabel->label, VIR_SECURITY_LABEL_BUFLEN,
- "+%u:+%u", (unsigned int)sb.st_uid, (unsigned int)sb.st_gid);
+ g_snprintf(seclabel->label, VIR_SECURITY_LABEL_BUFLEN,
+ "+%u:+%u", (unsigned int)sb.st_uid, (unsigned int)sb.st_gid);
ret = 0;
cleanup:
@@ -2371,8 +2371,8 @@ virSecurityDACGetProcessLabelInternal(pid_t pid,
return -1;
}
- snprintf(seclabel->label, VIR_SECURITY_LABEL_BUFLEN,
- "+%u:+%u", (unsigned int)p.ki_uid, (unsigned int)p.ki_groups[0]);
+ g_snprintf(seclabel->label, VIR_SECURITY_LABEL_BUFLEN,
+ "+%u:+%u", (unsigned int)p.ki_uid, (unsigned
int)p.ki_groups[0]);
return 0;
}
diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c
index 5ac9a9eeb8..bdb7f93a29 100644
--- a/src/security/virt-aa-helper.c
+++ b/src/security/virt-aa-helper.c
@@ -155,7 +155,7 @@ parserCommand(const char *profile_name, const char cmd)
return -1;
}
- snprintf(flag, 3, "-%c", cmd);
+ g_snprintf(flag, 3, "-%c", cmd);
profile = g_strdup_printf("%s/%s", APPARMOR_DIR "/libvirt",
profile_name);
diff --git a/src/storage/storage_util.c b/src/storage/storage_util.c
index f91c2c64ee..4d282fbda5 100644
--- a/src/storage/storage_util.c
+++ b/src/storage/storage_util.c
@@ -3962,7 +3962,7 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
if (virDirOpen(&devicedir, device_path) < 0)
return -1;
- snprintf(devicepattern, sizeof(devicepattern), "%u:%%u:%%u:%%u\n",
scanhost);
+ g_snprintf(devicepattern, sizeof(devicepattern), "%u:%%u:%%u:%%u\n",
scanhost);
while ((retval = virDirRead(devicedir, &lun_dirent, device_path)) > 0) {
int rc;
diff --git a/src/util/virhostcpu.c b/src/util/virhostcpu.c
index 1e685de386..a3ef067f41 100644
--- a/src/util/virhostcpu.c
+++ b/src/util/virhostcpu.c
@@ -794,7 +794,7 @@ virHostCPUGetStatsLinux(FILE *procstat,
if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS) {
strcpy(cpu_header, "cpu ");
} else {
- snprintf(cpu_header, sizeof(cpu_header), "cpu%d ", cpuNum);
+ g_snprintf(cpu_header, sizeof(cpu_header), "cpu%d ", cpuNum);
}
while (fgets(line, sizeof(line), procstat) != NULL) {
diff --git a/src/util/viriptables.c b/src/util/viriptables.c
index b7cce40d37..6b3a025880 100644
--- a/src/util/viriptables.c
+++ b/src/util/viriptables.c
@@ -192,7 +192,7 @@ iptablesInput(virFirewallPtr fw,
{
char portstr[32];
- snprintf(portstr, sizeof(portstr), "%d", port);
+ g_snprintf(portstr, sizeof(portstr), "%d", port);
portstr[sizeof(portstr) - 1] = '\0';
virFirewallAddRule(fw, layer,
@@ -217,7 +217,7 @@ iptablesOutput(virFirewallPtr fw,
{
char portstr[32];
- snprintf(portstr, sizeof(portstr), "%d", port);
+ g_snprintf(portstr, sizeof(portstr), "%d", port);
portstr[sizeof(portstr) - 1] = '\0';
virFirewallAddRule(fw, layer,
@@ -1100,7 +1100,7 @@ iptablesOutputFixUdpChecksum(virFirewallPtr fw,
{
char portstr[32];
- snprintf(portstr, sizeof(portstr), "%d", port);
+ g_snprintf(portstr, sizeof(portstr), "%d", port);
portstr[sizeof(portstr) - 1] = '\0';
virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4,
diff --git a/src/util/virmacaddr.c b/src/util/virmacaddr.c
index 5f825735ae..3eb6407c45 100644
--- a/src/util/virmacaddr.c
+++ b/src/util/virmacaddr.c
@@ -187,10 +187,10 @@ const char *
virMacAddrFormat(const virMacAddr *addr,
char *str)
{
- snprintf(str, VIR_MAC_STRING_BUFLEN,
- "%02x:%02x:%02x:%02x:%02x:%02x",
- addr->addr[0], addr->addr[1], addr->addr[2],
- addr->addr[3], addr->addr[4], addr->addr[5]);
+ g_snprintf(str, VIR_MAC_STRING_BUFLEN,
+ "%02x:%02x:%02x:%02x:%02x:%02x",
+ addr->addr[0], addr->addr[1], addr->addr[2],
+ addr->addr[3], addr->addr[4], addr->addr[5]);
str[VIR_MAC_STRING_BUFLEN-1] = '\0';
return str;
}
diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c
index d466545cc1..3a7a6dc730 100644
--- a/src/util/virnetdevbridge.c
+++ b/src/util/virnetdevbridge.c
@@ -126,7 +126,7 @@ static int virNetDevBridgeSet(const char *brname,
if (virFileExists(path)) {
char valuestr[INT_BUFSIZE_BOUND(value)];
- snprintf(valuestr, sizeof(valuestr), "%lu", value);
+ g_snprintf(valuestr, sizeof(valuestr), "%lu", value);
if (virFileWriteStr(path, valuestr, 0) >= 0)
return 0;
VIR_DEBUG("Unable to set bridge %s %s via sysfs", brname, paramname);
@@ -219,7 +219,7 @@ virNetDevBridgePortSet(const char *brname,
int ret = -1;
g_autofree char *path = NULL;
- snprintf(valuestr, sizeof(valuestr), "%lu", value);
+ g_snprintf(valuestr, sizeof(valuestr), "%lu", value);
path = g_strdup_printf(SYSFS_NET_DIR "%s/brif/%s/%s", brname, ifname,
paramname);
diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c
index cb901d7136..68c68a19ff 100644
--- a/src/util/virnetdevmacvlan.c
+++ b/src/util/virnetdevmacvlan.c
@@ -526,11 +526,11 @@ typedef struct virNetlinkCallbackData *virNetlinkCallbackDataPtr;
static int instance2str(const unsigned char *p, char *dst, size_t size)
{
if (dst && size > INSTANCE_STRLEN) {
- snprintf(dst, size, "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
- "%02x%02x-%02x%02x%02x%02x%02x%02x",
- p[0], p[1], p[2], p[3],
- p[4], p[5], p[6], p[7],
- p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
+ g_snprintf(dst, size, "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
+ "%02x%02x-%02x%02x%02x%02x%02x%02x",
+ p[0], p[1], p[2], p[3],
+ p[4], p[5], p[6], p[7],
+ p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
return 0;
}
return -1;
@@ -997,7 +997,7 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
virMutexUnlock(&virNetDevMacVLanCreateMutex);
return -1;
}
- snprintf(ifname, sizeof(ifname), pattern, reservedID);
+ g_snprintf(ifname, sizeof(ifname), pattern, reservedID);
if (virNetDevMacVLanCreate(ifname, type, macaddress, linkdev,
macvtapMode, &do_retry) < 0) {
virNetDevMacVLanReleaseID(reservedID, flags);
diff --git a/src/util/virpci.c b/src/util/virpci.c
index 9a43df7ab2..9bea5a20d0 100644
--- a/src/util/virpci.c
+++ b/src/util/virpci.c
@@ -1394,8 +1394,8 @@ virPCIDeviceNew(unsigned int domain,
}
/* strings contain '0x' prefix */
- if (snprintf(dev->id, sizeof(dev->id), "%s %s", &vendor[2],
- &product[2]) >= sizeof(dev->id)) {
+ if (g_snprintf(dev->id, sizeof(dev->id), "%s %s", &vendor[2],
+ &product[2]) >= sizeof(dev->id)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("dev->id buffer overflow: %s %s"),
&vendor[2], &product[2]);
diff --git a/src/util/virpidfile.c b/src/util/virpidfile.c
index 3e78735c9c..93b32a103d 100644
--- a/src/util/virpidfile.c
+++ b/src/util/virpidfile.c
@@ -68,7 +68,7 @@ int virPidFileWritePath(const char *pidfile,
goto cleanup;
}
- snprintf(pidstr, sizeof(pidstr), "%lld", (long long) pid);
+ g_snprintf(pidstr, sizeof(pidstr), "%lld", (long long) pid);
if (safewrite(fd, pidstr, strlen(pidstr)) < 0) {
rc = -errno;
@@ -392,7 +392,7 @@ int virPidFileAcquirePath(const char *path,
/* Someone else must be racing with us, so try again */
}
- snprintf(pidstr, sizeof(pidstr), "%lld", (long long) pid);
+ g_snprintf(pidstr, sizeof(pidstr), "%lld", (long long) pid);
if (ftruncate(fd, 0) < 0) {
virReportSystemError(errno,
diff --git a/src/util/virtime.c b/src/util/virtime.c
index 6f978d7c64..701b2f085a 100644
--- a/src/util/virtime.c
+++ b/src/util/virtime.c
@@ -209,11 +209,11 @@ int virTimeStringThenRaw(unsigned long long when, char *buf)
fields.tm_year += 1900;
fields.tm_mon += 1;
- if (snprintf(buf, VIR_TIME_STRING_BUFLEN,
- "%4d-%02d-%02d %02d:%02d:%02d.%03d+0000",
- fields.tm_year, fields.tm_mon, fields.tm_mday,
- fields.tm_hour, fields.tm_min, fields.tm_sec,
- (int) (when % 1000)) >= VIR_TIME_STRING_BUFLEN) {
+ if (g_snprintf(buf, VIR_TIME_STRING_BUFLEN,
+ "%4d-%02d-%02d %02d:%02d:%02d.%03d+0000",
+ fields.tm_year, fields.tm_mon, fields.tm_mday,
+ fields.tm_hour, fields.tm_min, fields.tm_sec,
+ (int) (when % 1000)) >= VIR_TIME_STRING_BUFLEN) {
errno = ERANGE;
return -1;
}
diff --git a/src/util/virusb.c b/src/util/virusb.c
index 7ce582085f..a2562b7ea8 100644
--- a/src/util/virusb.c
+++ b/src/util/virusb.c
@@ -319,8 +319,8 @@ virUSBDeviceNew(unsigned int bus,
dev->bus = bus;
dev->dev = devno;
- if (snprintf(dev->name, sizeof(dev->name), "%.3d:%.3d",
- dev->bus, dev->dev) >= sizeof(dev->name)) {
+ if (g_snprintf(dev->name, sizeof(dev->name), "%.3d:%.3d",
+ dev->bus, dev->dev) >= sizeof(dev->name)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("dev->name buffer overflow: %.3d:%.3d"),
dev->bus, dev->dev);
@@ -337,8 +337,8 @@ virUSBDeviceNew(unsigned int bus,
}
/* XXX fixme. this should be product/vendor */
- if (snprintf(dev->id, sizeof(dev->id), "%d %d", dev->bus,
- dev->dev) >= sizeof(dev->id)) {
+ if (g_snprintf(dev->id, sizeof(dev->id), "%d %d", dev->bus,
+ dev->dev) >= sizeof(dev->id)) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("dev->id buffer overflow: %d %d"),
dev->bus, dev->dev);
diff --git a/src/util/viruuid.c b/src/util/viruuid.c
index 8930a0e199..7626d72c23 100644
--- a/src/util/viruuid.c
+++ b/src/util/viruuid.c
@@ -153,12 +153,12 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid)
const char *
virUUIDFormat(const unsigned char *uuid, char *uuidstr)
{
- snprintf(uuidstr, VIR_UUID_STRING_BUFLEN,
-
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
- uuid[0], uuid[1], uuid[2], uuid[3],
- uuid[4], uuid[5], uuid[6], uuid[7],
- uuid[8], uuid[9], uuid[10], uuid[11],
- uuid[12], uuid[13], uuid[14], uuid[15]);
+ g_snprintf(uuidstr, VIR_UUID_STRING_BUFLEN,
+
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ uuid[0], uuid[1], uuid[2], uuid[3],
+ uuid[4], uuid[5], uuid[6], uuid[7],
+ uuid[8], uuid[9], uuid[10], uuid[11],
+ uuid[12], uuid[13], uuid[14], uuid[15]);
uuidstr[VIR_UUID_STRING_BUFLEN-1] = '\0';
return uuidstr;
}
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index 0bd47e3ddb..1b3160d112 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -1288,14 +1288,14 @@ vboxAttachNetwork(virDomainDefPtr def, vboxDriverPtr data,
IMachine *machine)
PRUnichar *MACAddress = NULL;
virMacAddrFormat(&def->nets[i]->mac, macaddr);
- snprintf(macaddrvbox, VIR_MAC_STRING_BUFLEN - 5,
- "%02X%02X%02X%02X%02X%02X",
- def->nets[i]->mac.addr[0],
- def->nets[i]->mac.addr[1],
- def->nets[i]->mac.addr[2],
- def->nets[i]->mac.addr[3],
- def->nets[i]->mac.addr[4],
- def->nets[i]->mac.addr[5]);
+ g_snprintf(macaddrvbox, VIR_MAC_STRING_BUFLEN - 5,
+ "%02X%02X%02X%02X%02X%02X",
+ def->nets[i]->mac.addr[0],
+ def->nets[i]->mac.addr[1],
+ def->nets[i]->mac.addr[2],
+ def->nets[i]->mac.addr[3],
+ def->nets[i]->mac.addr[4],
+ def->nets[i]->mac.addr[5]);
macaddrvbox[VIR_MAC_STRING_BUFLEN - 6] = '\0';
VIR_DEBUG("NIC(%zu): Type: %d", i, def->nets[i]->type);
@@ -1786,15 +1786,15 @@ vboxAttachUSB(virDomainDefPtr def, vboxDriverPtr data, IMachine
*machine)
continue;
if (def->hostdevs[i]->source.subsys.u.usb.vendor) {
- snprintf(vendorId, sizeof(vendorId), "%x",
- def->hostdevs[i]->source.subsys.u.usb.vendor);
+ g_snprintf(vendorId, sizeof(vendorId), "%x",
+ def->hostdevs[i]->source.subsys.u.usb.vendor);
VBOX_UTF8_TO_UTF16(vendorId, &vendorIdUtf16);
gVBoxAPI.UIUSBDeviceFilter.SetVendorId(filter, vendorIdUtf16);
VBOX_UTF16_FREE(vendorIdUtf16);
}
if (def->hostdevs[i]->source.subsys.u.usb.product) {
- snprintf(productId, sizeof(productId), "%x",
- def->hostdevs[i]->source.subsys.u.usb.product);
+ g_snprintf(productId, sizeof(productId), "%x",
+ def->hostdevs[i]->source.subsys.u.usb.product);
VBOX_UTF8_TO_UTF16(productId, &productIdUtf16);
gVBoxAPI.UIUSBDeviceFilter.SetProductId(filter,
productIdUtf16);
diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c
index a5a907768b..872825d86f 100644
--- a/src/vbox/vbox_tmpl.c
+++ b/src/vbox/vbox_tmpl.c
@@ -214,7 +214,7 @@ static PRUnichar *PRUnicharFromInt(PCVBOXXPCOM pFuncs, int n) {
PRUnichar *strUtf16 = NULL;
char s[24];
- snprintf(s, sizeof(s), "%d", n);
+ g_snprintf(s, sizeof(s), "%d", n);
pFuncs->pfnUtf8ToUtf16(s, &strUtf16);
diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c
index 2cd6fc6049..0ccc4eefe6 100644
--- a/src/vmx/vmx.c
+++ b/src/vmx/vmx.c
@@ -500,7 +500,7 @@ def->parallels[0]...
#define VIR_FROM_THIS VIR_FROM_NONE
#define VMX_BUILD_NAME_EXTRA(_suffix, _extra) \
- snprintf(_suffix##_name, sizeof(_suffix##_name), "%s."_extra, prefix);
+ g_snprintf(_suffix##_name, sizeof(_suffix##_name), "%s."_extra, prefix);
#define VMX_BUILD_NAME(_suffix) \
VMX_BUILD_NAME_EXTRA(_suffix, #_suffix)
@@ -640,7 +640,7 @@ virVMXEscapeHex(const char *string, char escape, const char *special)
if (*tmp1 == escape || strspn(tmp1, special) > 0) {
*tmp2++ = escape;
- snprintf(tmp2, 3, "%02x", (unsigned int)*tmp1);
+ g_snprintf(tmp2, 3, "%02x", (unsigned int)*tmp1);
tmp2 += 2;
} else {
@@ -1951,9 +1951,9 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool
*present,
return -1;
}
- snprintf(present_name, sizeof(present_name), "scsi%d.present",
controller);
- snprintf(virtualDev_name, sizeof(virtualDev_name), "scsi%d.virtualDev",
- controller);
+ g_snprintf(present_name, sizeof(present_name), "scsi%d.present",
controller);
+ g_snprintf(virtualDev_name, sizeof(virtualDev_name), "scsi%d.virtualDev",
+ controller);
if (virVMXGetConfigBoolean(conf, present_name, present, false, true) < 0)
goto cleanup;
@@ -2443,7 +2443,7 @@ int virVMXParseFileSystem(virConfPtr conf, int number,
virDomainFSDefPtr *def)
return -1;
}
- snprintf(prefix, sizeof(prefix), "sharedFolder%d", number);
+ g_snprintf(prefix, sizeof(prefix), "sharedFolder%d", number);
VMX_BUILD_NAME(present);
VMX_BUILD_NAME(enabled);
@@ -2548,7 +2548,7 @@ virVMXParseEthernet(virConfPtr conf, int controller,
virDomainNetDefPtr *def)
return -1;
}
- snprintf(prefix, sizeof(prefix), "ethernet%d", controller);
+ g_snprintf(prefix, sizeof(prefix), "ethernet%d", controller);
VMX_BUILD_NAME(present);
VMX_BUILD_NAME(startConnected);
@@ -2753,7 +2753,7 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
return -1;
}
- snprintf(prefix, sizeof(prefix), "serial%d", port);
+ g_snprintf(prefix, sizeof(prefix), "serial%d", port);
VMX_BUILD_NAME(present);
VMX_BUILD_NAME(startConnected);
@@ -2930,7 +2930,7 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
return -1;
}
- snprintf(prefix, sizeof(prefix), "parallel%d", port);
+ g_snprintf(prefix, sizeof(prefix), "parallel%d", port);
VMX_BUILD_NAME(present);
VMX_BUILD_NAME(startConnected);
diff --git a/src/vz/vz_driver.c b/src/vz/vz_driver.c
index f3cd919086..6b925653d5 100644
--- a/src/vz/vz_driver.c
+++ b/src/vz/vz_driver.c
@@ -3453,8 +3453,8 @@ vzDomainGetJobStats(virDomainPtr domain,
#define VZ_ADD_STAT_PARAM_UUL(group, field, counter) \
do { \
if (stat.field != -1) { \
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \
- group ".%zu." counter, i); \
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \
+ group ".%zu." counter, i); \
if (virTypedParamsAddULLong(&record->params, \
&record->nparams, \
maxparams, \
@@ -3490,8 +3490,8 @@ vzDomainGetBlockStats(virDomainObjPtr dom,
IS_CT(dom->def)) < 0)
return -1;
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "block.%zu.name", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "block.%zu.name", i);
if (virTypedParamsAddString(&record->params,
&record->nparams,
maxparams,
@@ -3500,8 +3500,8 @@ vzDomainGetBlockStats(virDomainObjPtr dom,
return -1;
if (virStorageSourceIsLocalStorage(disk->src) &&
disk->src->path) {
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "block.%zu.path", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "block.%zu.path", i);
if (virTypedParamsAddString(&record->params,
&record->nparams,
maxparams,
@@ -3516,8 +3516,8 @@ vzDomainGetBlockStats(virDomainObjPtr dom,
VZ_ADD_STAT_PARAM_UUL("block", wr_bytes, "wr.bytes");
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "block.%zu.capacity", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "block.%zu.capacity", i);
if (virTypedParamsAddULLong(&record->params,
&record->nparams,
maxparams,
@@ -3555,7 +3555,7 @@ vzDomainGetNetStats(virDomainObjPtr dom,
&stat) < 0)
return -1;
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "net.%zu.name", i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "net.%zu.name",
i);
if (virTypedParamsAddString(&record->params,
&record->nparams,
maxparams,
@@ -3600,7 +3600,7 @@ vzDomainGetVCPUStats(virDomainObjPtr dom,
VIR_VCPU_OFFLINE;
unsigned long long time;
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "vcpu.%zu.state",
i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "vcpu.%zu.state",
i);
if (virTypedParamsAddInt(&record->params,
&record->nparams,
maxparams,
@@ -3611,7 +3611,7 @@ vzDomainGetVCPUStats(virDomainObjPtr dom,
if (prlsdkGetVcpuStats(privdom->stats, i, &time) < 0)
return -1;
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "vcpu.%zu.time",
i);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, "vcpu.%zu.time",
i);
if (virTypedParamsAddULLong(&record->params,
&record->nparams,
maxparams,
diff --git a/src/vz/vz_sdk.c b/src/vz/vz_sdk.c
index 76165290b8..0daffb6844 100644
--- a/src/vz/vz_sdk.c
+++ b/src/vz/vz_sdk.c
@@ -3171,10 +3171,10 @@ static int prlsdkAddSerial(PRL_HANDLE sdkdom, virDomainChrDefPtr
chr)
static const char * prlsdkFormatMac(virMacAddrPtr mac, char *macstr)
{
- snprintf(macstr, PRL_MAC_STRING_BUFNAME,
- "%02X%02X%02X%02X%02X%02X",
- mac->addr[0], mac->addr[1], mac->addr[2],
- mac->addr[3], mac->addr[4], mac->addr[5]);
+ g_snprintf(macstr, PRL_MAC_STRING_BUFNAME,
+ "%02X%02X%02X%02X%02X%02X",
+ mac->addr[0], mac->addr[1], mac->addr[2],
+ mac->addr[3], mac->addr[4], mac->addr[5]);
macstr[PRL_MAC_STRING_BUFNAME - 1] = '\0';
return macstr;
}
diff --git a/tests/libxlmock.c b/tests/libxlmock.c
index 4476cf728f..38302b2ae8 100644
--- a/tests/libxlmock.c
+++ b/tests/libxlmock.c
@@ -99,7 +99,7 @@ VIR_MOCK_IMPL_RET_ARGS(virFileMakePath, int,
{
/* replace log path with a writable directory */
if (strstr(path, "/log/")) {
- snprintf((char*)path, strlen(path), ".");
+ g_snprintf((char*)path, strlen(path), ".");
return 0;
}
return real_virFileMakePath(path);
diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c
index e767e6c0f6..9dbbfb3cfe 100644
--- a/tests/qemuagenttest.c
+++ b/tests/qemuagenttest.c
@@ -1111,8 +1111,8 @@ checkUserInfo(virTypedParameterPtr params,
const char *domain = NULL;
unsigned long long logintime = 0;
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "user.%zu.name", nth);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "user.%zu.name", nth);
if (virTypedParamsGetString(params, nparams, param_name, &username) < 0)
return -1;
@@ -1123,8 +1123,8 @@ checkUserInfo(virTypedParameterPtr params,
return -1;
}
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "user.%zu.domain", nth);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "user.%zu.domain", nth);
if (virTypedParamsGetString(params, nparams, param_name, &domain) < 0)
return -1;
@@ -1135,8 +1135,8 @@ checkUserInfo(virTypedParameterPtr params,
return -1;
}
- snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
- "user.%zu.login-time", nth);
+ g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
+ "user.%zu.login-time", nth);
if (virTypedParamsGetULLong(params, nparams, param_name, &logintime) < 0)
return -1;
diff --git a/tests/testutils.c b/tests/testutils.c
index a3bedd0fef..2ae93b212d 100644
--- a/tests/testutils.c
+++ b/tests/testutils.c
@@ -1188,7 +1188,7 @@ const char
/* calculate length of the rest of the string */
len -= (virtTestCounterPrefixEndOffset - virtTestCounterStr);
- snprintf(virtTestCounterPrefixEndOffset, len, "%d", ++virtTestCounter);
+ g_snprintf(virtTestCounterPrefixEndOffset, len, "%d", ++virtTestCounter);
return virtTestCounterStr;
}
diff --git a/tests/virnetsockettest.c b/tests/virnetsockettest.c
index 4e9f201e45..951d01be70 100644
--- a/tests/virnetsockettest.c
+++ b/tests/virnetsockettest.c
@@ -211,7 +211,7 @@ testSocketAccept(const void *opaque)
cdata.path = path;
} else {
- snprintf(portstr, sizeof(portstr), "%d", data->port);
+ g_snprintf(portstr, sizeof(portstr), "%d", data->port);
if (virNetSocketNewListenTCP(data->lnode, portstr,
AF_UNSPEC,
&lsock, &nlsock) < 0)
diff --git a/tests/virpcimock.c b/tests/virpcimock.c
index 7e4554a1dc..341afb385b 100644
--- a/tests/virpcimock.c
+++ b/tests/virpcimock.c
@@ -417,9 +417,9 @@ pci_device_create_iommu(const struct pciDevice *dev,
if (virFileMakePath(iommuPath) < 0)
ABORT("Unable to create: %s", iommuPath);
- if (snprintf(tmp, sizeof(tmp),
- "../../../../devices/pci%04x:%02x/%s",
- dev->addr.domain, dev->addr.bus, devid) < 0) {
+ if (g_snprintf(tmp, sizeof(tmp),
+ "../../../../devices/pci%04x:%02x/%s",
+ dev->addr.domain, dev->addr.bus, devid) < 0) {
ABORT("@tmp overflow");
}
@@ -512,15 +512,15 @@ pci_device_new_from_stub(const struct pciDevice *data)
make_file(devpath, "config", "some dummy config", -1);
}
- if (snprintf(tmp, sizeof(tmp), "0x%.4x", dev->vendor) < 0)
+ if (g_snprintf(tmp, sizeof(tmp), "0x%.4x", dev->vendor) < 0)
ABORT("@tmp overflow");
make_file(devpath, "vendor", tmp, -1);
- if (snprintf(tmp, sizeof(tmp), "0x%.4x", dev->device) < 0)
+ if (g_snprintf(tmp, sizeof(tmp), "0x%.4x", dev->device) < 0)
ABORT("@tmp overflow");
make_file(devpath, "device", tmp, -1);
- if (snprintf(tmp, sizeof(tmp), "0x%.4x", dev->klass) < 0)
+ if (g_snprintf(tmp, sizeof(tmp), "0x%.4x", dev->klass) < 0)
ABORT("@tmp overflow");
make_file(devpath, "class", tmp, -1);
@@ -528,15 +528,15 @@ pci_device_new_from_stub(const struct pciDevice *data)
pci_device_create_iommu(dev, devid);
- if (snprintf(tmp, sizeof(tmp),
- "../../../kernel/iommu_groups/%d", dev->iommuGroup) < 0)
{
+ if (g_snprintf(tmp, sizeof(tmp),
+ "../../../kernel/iommu_groups/%d", dev->iommuGroup) <
0) {
ABORT("@tmp overflow");
}
make_symlink(devpath, "iommu_group", tmp);
- if (snprintf(tmp, sizeof(tmp),
- "../../../devices/pci%04x:%02x/%s",
- dev->addr.domain, dev->addr.bus, devid) < 0) {
+ if (g_snprintf(tmp, sizeof(tmp),
+ "../../../devices/pci%04x:%02x/%s",
+ dev->addr.domain, dev->addr.bus, devid) < 0) {
ABORT("@tmp overflow");
}
@@ -545,9 +545,9 @@ pci_device_new_from_stub(const struct pciDevice *data)
make_symlink(devsympath, devid, tmp);
if (dev->physfn) {
- if (snprintf(tmp, sizeof(tmp),
- "%s%s/devices/%s", fakerootdir,
- SYSFS_PCI_PREFIX, dev->physfn) < 0) {
+ if (g_snprintf(tmp, sizeof(tmp),
+ "%s%s/devices/%s", fakerootdir,
+ SYSFS_PCI_PREFIX, dev->physfn) < 0) {
ABORT("@tmp overflow");
}
make_symlink(devpath, "physfn", tmp);
diff --git a/tests/virsystemdtest.c b/tests/virsystemdtest.c
index b85259f61f..b5624241bb 100644
--- a/tests/virsystemdtest.c
+++ b/tests/virsystemdtest.c
@@ -564,8 +564,8 @@ testActivation(bool useNames)
for (i = 0; i < nsockIP; i++)
virBufferAddLit(&names, ":demo-ip.socket");
- snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP);
- snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid());
+ g_snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP);
+ g_snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid());
setenv("LISTEN_FDS", nfdstr, 1);
setenv("LISTEN_PID", pidstr, 1);
diff --git a/tools/virsh-domain-monitor.c b/tools/virsh-domain-monitor.c
index 034c913d5e..c2f157ad6b 100644
--- a/tools/virsh-domain-monitor.c
+++ b/tools/virsh-domain-monitor.c
@@ -2003,7 +2003,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
dom = list->domains[i];
id = virDomainGetID(dom);
if (id != (unsigned int) -1)
- snprintf(id_buf, sizeof(id_buf), "%d", id);
+ g_snprintf(id_buf, sizeof(id_buf), "%d", id);
else
ignore_value(virStrcpyStatic(id_buf, "-"));
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 0feb21ef17..0b60bf59fb 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -12098,7 +12098,7 @@ virshDomainDetachInterface(char *doc,
goto cleanup;
}
- snprintf(buf, sizeof(buf), "/domain/devices/interface[@type='%s']",
type);
+ g_snprintf(buf, sizeof(buf),
"/domain/devices/interface[@type='%s']", type);
obj = xmlXPathEval(BAD_CAST buf, ctxt);
if (obj == NULL || obj->type != XPATH_NODESET ||
obj->nodesetval == NULL || obj->nodesetval->nodeNr == 0) {
diff --git a/tools/virt-host-validate-common.c b/tools/virt-host-validate-common.c
index af8def21f3..bce0f14917 100644
--- a/tools/virt-host-validate-common.c
+++ b/tools/virt-host-validate-common.c
@@ -172,7 +172,7 @@ int virHostValidateNamespace(const char *hvname,
virHostMsgCheck(hvname, "for namespace %s", ns_name);
char nspath[100];
- snprintf(nspath, sizeof(nspath), "/proc/self/ns/%s", ns_name);
+ g_snprintf(nspath, sizeof(nspath), "/proc/self/ns/%s", ns_name);
if (access(nspath, F_OK) < 0) {
virHostMsgFail(level, "%s", hint);
diff --git a/tools/vsh-table.c b/tools/vsh-table.c
index c2271a4e2d..9008b0d431 100644
--- a/tools/vsh-table.c
+++ b/tools/vsh-table.c
@@ -227,7 +227,7 @@ vshTableSafeEncode(const char *s, size_t *width)
while (p && *p) {
if ((*p == '\\' && *(p + 1) == 'x') ||
c_iscntrl(*p)) {
- snprintf(buf, HEX_ENCODE_LENGTH + 1, "\\x%02x", *p);
+ g_snprintf(buf, HEX_ENCODE_LENGTH + 1, "\\x%02x", *p);
buf += HEX_ENCODE_LENGTH;
*width += HEX_ENCODE_LENGTH;
p++;
@@ -245,7 +245,7 @@ vshTableSafeEncode(const char *s, size_t *width)
* printable char according to the current locales.
*/
if (!c_isprint(*p)) {
- snprintf(buf, HEX_ENCODE_LENGTH + 1, "\\x%02x", *p);
+ g_snprintf(buf, HEX_ENCODE_LENGTH + 1, "\\x%02x", *p);
buf += HEX_ENCODE_LENGTH;
*width += HEX_ENCODE_LENGTH;
} else {
@@ -255,7 +255,7 @@ vshTableSafeEncode(const char *s, size_t *width)
} else if (!iswprint(wc)) {
size_t i;
for (i = 0; i < len; i++) {
- snprintf(buf, HEX_ENCODE_LENGTH + 1, "\\x%02x", p[i]);
+ g_snprintf(buf, HEX_ENCODE_LENGTH + 1, "\\x%02x", p[i]);
buf += HEX_ENCODE_LENGTH;
*width += HEX_ENCODE_LENGTH;
}
diff --git a/tools/vsh.c b/tools/vsh.c
index 000cf6a009..26ee4a3fe4 100644
--- a/tools/vsh.c
+++ b/tools/vsh.c
@@ -719,24 +719,24 @@ vshCmddefHelp(vshControl *ctl, const vshCmdDef *def)
for (opt = def->opts; opt->name; opt++) {
switch (opt->type) {
case VSH_OT_BOOL:
- snprintf(buf, sizeof(buf), "--%s", opt->name);
+ g_snprintf(buf, sizeof(buf), "--%s", opt->name);
break;
case VSH_OT_INT:
- snprintf(buf, sizeof(buf),
- (opt->flags & VSH_OFLAG_REQ) ? _("[--%s]
<number>")
- : _("--%s <number>"), opt->name);
+ g_snprintf(buf, sizeof(buf),
+ (opt->flags & VSH_OFLAG_REQ) ? _("[--%s]
<number>")
+ : _("--%s <number>"), opt->name);
break;
case VSH_OT_STRING:
- snprintf(buf, sizeof(buf), _("--%s <string>"),
opt->name);
+ g_snprintf(buf, sizeof(buf), _("--%s <string>"),
opt->name);
break;
case VSH_OT_DATA:
- snprintf(buf, sizeof(buf), _("[--%s] <string>"),
- opt->name);
+ g_snprintf(buf, sizeof(buf), _("[--%s] <string>"),
+ opt->name);
break;
case VSH_OT_ARGV:
- snprintf(buf, sizeof(buf),
- shortopt ? _("[--%s] <string>") :
_("<%s>"),
- opt->name);
+ g_snprintf(buf, sizeof(buf),
+ shortopt ? _("[--%s] <string>") :
_("<%s>"),
+ opt->name);
break;
case VSH_OT_ALIAS:
continue;
@@ -2690,7 +2690,7 @@ vshReadlineOptionsGenerator(const char *text,
name_len = strlen(name);
ret[ret_size] = vshMalloc(NULL, name_len + 3);
- snprintf(ret[ret_size], name_len + 3, "--%s", name);
+ g_snprintf(ret[ret_size], name_len + 3, "--%s", name);
ret_size++;
/* Terminate the string list properly. */
ret[ret_size] = NULL;
diff --git a/tools/wireshark/src/packet-libvirt.c b/tools/wireshark/src/packet-libvirt.c
index 7096e72e67..20b7a3ec81 100644
--- a/tools/wireshark/src/packet-libvirt.c
+++ b/tools/wireshark/src/packet-libvirt.c
@@ -169,7 +169,7 @@ format_xdr_bytes(guint8 *bytes, guint32 length)
for (i = 0; i < length; i++) {
/* We know that buf has enough size to contain
2 * length + '\0' characters. */
- snprintf(buf, 2*(length - i) + 1, "%02x", bytes[i]);
+ g_snprintf(buf, 2*(length - i) + 1, "%02x", bytes[i]);
buf += 2;
}
return buf - length*2;
--
2.23.0