mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 03:25:20 +00:00
replace use of gnulib snprintf by g_snprintf
Glib implementation follows the ISO C99 standard so it's safe to replace the gnulib implementation. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
parent
8addef2bef
commit
43b01ef2d6
@ -1381,7 +1381,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset,
|
|||||||
|
|
||||||
/* press the keys */
|
/* press the keys */
|
||||||
for (i = 0; i < nkeycodes; i++) {
|
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,
|
params = hypervCreateInvokeParamsList(priv, "PressKey", selector,
|
||||||
Msvm_Keyboard_WmiInfo);
|
Msvm_Keyboard_WmiInfo);
|
||||||
@ -1409,7 +1409,7 @@ hypervDomainSendKey(virDomainPtr domain, unsigned int codeset,
|
|||||||
|
|
||||||
/* release the keys */
|
/* release the keys */
|
||||||
for (i = 0; i < nkeycodes; i++) {
|
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,
|
params = hypervCreateInvokeParamsList(priv, "ReleaseKey", selector,
|
||||||
Msvm_Keyboard_WmiInfo);
|
Msvm_Keyboard_WmiInfo);
|
||||||
|
|
||||||
|
@ -418,12 +418,12 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(xlCPU,
|
g_snprintf(xlCPU,
|
||||||
sizeof(xlCPU),
|
sizeof(xlCPU),
|
||||||
"%s=0",
|
"%s=0",
|
||||||
xenTranslateCPUFeature(
|
xenTranslateCPUFeature(
|
||||||
def->cpu->features[i].name,
|
def->cpu->features[i].name,
|
||||||
false));
|
false));
|
||||||
if (libxl_cpuid_parse_config(&b_info->cpuid, xlCPU)) {
|
if (libxl_cpuid_parse_config(&b_info->cpuid, xlCPU)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unsupported cpu feature '%s'"),
|
_("unsupported cpu feature '%s'"),
|
||||||
@ -440,11 +440,11 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(xlCPU,
|
g_snprintf(xlCPU,
|
||||||
sizeof(xlCPU),
|
sizeof(xlCPU),
|
||||||
"%s=1",
|
"%s=1",
|
||||||
xenTranslateCPUFeature(
|
xenTranslateCPUFeature(
|
||||||
def->cpu->features[i].name, false));
|
def->cpu->features[i].name, false));
|
||||||
if (libxl_cpuid_parse_config(&b_info->cpuid, xlCPU)) {
|
if (libxl_cpuid_parse_config(&b_info->cpuid, xlCPU)) {
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||||
_("unsupported cpu feature '%s'"),
|
_("unsupported cpu feature '%s'"),
|
||||||
|
@ -745,7 +745,7 @@ libxlDomainMigrationDstPrepare(virConnectPtr dconn,
|
|||||||
*uri_out = g_strdup_printf("tcp://%s:%d", hostname, port);
|
*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,
|
if (virNetSocketNewListenTCP(hostname, portstr,
|
||||||
AF_UNSPEC,
|
AF_UNSPEC,
|
||||||
@ -1221,7 +1221,7 @@ libxlDomainMigrationSrcPerform(libxlDriverPrivatePtr driver,
|
|||||||
|
|
||||||
hostname = uri->server;
|
hostname = uri->server;
|
||||||
port = uri->port;
|
port = uri->port;
|
||||||
snprintf(portstr, sizeof(portstr), "%d", port);
|
g_snprintf(portstr, sizeof(portstr), "%d", port);
|
||||||
|
|
||||||
/* socket connect to dst host:port */
|
/* socket connect to dst host:port */
|
||||||
if (virNetSocketNewConnectTCP(hostname, portstr,
|
if (virNetSocketNewConnectTCP(hostname, portstr,
|
||||||
|
@ -1415,10 +1415,10 @@ int virLXCProcessStart(virConnectPtr conn,
|
|||||||
if (virLXCProcessReadLogOutput(vm, logfile, pos, ebuf,
|
if (virLXCProcessReadLogOutput(vm, logfile, pos, ebuf,
|
||||||
sizeof(ebuf)) <= 0) {
|
sizeof(ebuf)) <= 0) {
|
||||||
if (WIFEXITED(status))
|
if (WIFEXITED(status))
|
||||||
snprintf(ebuf, sizeof(ebuf), _("unexpected exit status %d"),
|
g_snprintf(ebuf, sizeof(ebuf), _("unexpected exit status %d"),
|
||||||
WEXITSTATUS(status));
|
WEXITSTATUS(status));
|
||||||
else
|
else
|
||||||
snprintf(ebuf, sizeof(ebuf), "%s", _("terminated abnormally"));
|
g_snprintf(ebuf, sizeof(ebuf), "%s", _("terminated abnormally"));
|
||||||
}
|
}
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("guest failed to start: %s"), ebuf);
|
_("guest failed to start: %s"), ebuf);
|
||||||
|
@ -76,9 +76,9 @@ enum ctdirStatus {
|
|||||||
static enum ctdirStatus iptables_ctdir_corrected;
|
static enum ctdirStatus iptables_ctdir_corrected;
|
||||||
|
|
||||||
#define PRINT_ROOT_CHAIN(buf, prefix, ifname) \
|
#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) \
|
#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_IN_CHAIN "libvirt-in"
|
||||||
#define VIRT_OUT_CHAIN "libvirt-out"
|
#define VIRT_OUT_CHAIN "libvirt-out"
|
||||||
@ -86,7 +86,7 @@ static enum ctdirStatus iptables_ctdir_corrected;
|
|||||||
#define HOST_IN_CHAIN "libvirt-host-in"
|
#define HOST_IN_CHAIN "libvirt-host-in"
|
||||||
|
|
||||||
#define PRINT_IPT_ROOT_CHAIN(buf, prefix, ifname) \
|
#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;
|
static bool newMatchState;
|
||||||
|
|
||||||
@ -204,7 +204,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
data = virSocketAddrFormat(&item->u.ipaddr);
|
data = virSocketAddrFormat(&item->u.ipaddr);
|
||||||
if (!data)
|
if (!data)
|
||||||
return -1;
|
return -1;
|
||||||
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
|
if (g_snprintf(buf, bufsize, "%s", data) >= bufsize) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("buffer too small for IP address"));
|
_("buffer too small for IP address"));
|
||||||
VIR_FREE(data);
|
VIR_FREE(data);
|
||||||
@ -218,7 +218,7 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
if (!data)
|
if (!data)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (snprintf(buf, bufsize, "%s", data) >= bufsize) {
|
if (g_snprintf(buf, bufsize, "%s", data) >= bufsize) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("buffer too small for IPv6 address"));
|
_("buffer too small for IPv6 address"));
|
||||||
VIR_FREE(data);
|
VIR_FREE(data);
|
||||||
@ -240,8 +240,8 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
|
|
||||||
case DATATYPE_IPV6MASK:
|
case DATATYPE_IPV6MASK:
|
||||||
case DATATYPE_IPMASK:
|
case DATATYPE_IPMASK:
|
||||||
if (snprintf(buf, bufsize, "%d",
|
if (g_snprintf(buf, bufsize, "%d",
|
||||||
item->u.u8) >= bufsize) {
|
item->u.u8) >= bufsize) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Buffer too small for uint8 type"));
|
_("Buffer too small for uint8 type"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -250,8 +250,8 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
|
|
||||||
case DATATYPE_UINT32:
|
case DATATYPE_UINT32:
|
||||||
case DATATYPE_UINT32_HEX:
|
case DATATYPE_UINT32_HEX:
|
||||||
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%u",
|
if (g_snprintf(buf, bufsize, asHex ? "0x%x" : "%u",
|
||||||
item->u.u32) >= bufsize) {
|
item->u.u32) >= bufsize) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Buffer too small for uint32 type"));
|
_("Buffer too small for uint32 type"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -260,8 +260,8 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
|
|
||||||
case DATATYPE_UINT16:
|
case DATATYPE_UINT16:
|
||||||
case DATATYPE_UINT16_HEX:
|
case DATATYPE_UINT16_HEX:
|
||||||
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
|
if (g_snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
|
||||||
item->u.u16) >= bufsize) {
|
item->u.u16) >= bufsize) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Buffer too small for uint16 type"));
|
_("Buffer too small for uint16 type"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -270,8 +270,8 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
|||||||
|
|
||||||
case DATATYPE_UINT8:
|
case DATATYPE_UINT8:
|
||||||
case DATATYPE_UINT8_HEX:
|
case DATATYPE_UINT8_HEX:
|
||||||
if (snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
|
if (g_snprintf(buf, bufsize, asHex ? "0x%x" : "%d",
|
||||||
item->u.u8) >= bufsize) {
|
item->u.u8) >= bufsize) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Buffer too small for uint8 type"));
|
_("Buffer too small for uint8 type"));
|
||||||
return -1;
|
return -1;
|
||||||
@ -3192,11 +3192,11 @@ iptablesCheckBridgeNFCallEnabled(bool isIPv6)
|
|||||||
if (read(fd, buffer, 1) == 1) {
|
if (read(fd, buffer, 1) == 1) {
|
||||||
if (buffer[0] == '0') {
|
if (buffer[0] == '0') {
|
||||||
char msg[256];
|
char msg[256];
|
||||||
snprintf(msg, sizeof(msg),
|
g_snprintf(msg, sizeof(msg),
|
||||||
_("To enable ip%stables filtering for the VM do "
|
_("To enable ip%stables filtering for the VM do "
|
||||||
"'echo 1 > %s'"),
|
"'echo 1 > %s'"),
|
||||||
isIPv6 ? "6" : "",
|
isIPv6 ? "6" : "",
|
||||||
pathname);
|
pathname);
|
||||||
VIR_WARN("%s", msg);
|
VIR_WARN("%s", msg);
|
||||||
if (isIPv6)
|
if (isIPv6)
|
||||||
lastReportIPv6 = now;
|
lastReportIPv6 = now;
|
||||||
|
@ -61,7 +61,7 @@ VIR_LOG_INIT("nwfilter.nwfilter_learnipaddr");
|
|||||||
|
|
||||||
#define IFINDEX2STR(VARNAME, ifindex) \
|
#define IFINDEX2STR(VARNAME, ifindex) \
|
||||||
char VARNAME[INT_BUFSIZE_BOUND(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 */
|
#define PKT_TIMEOUT_MS 500 /* ms */
|
||||||
|
|
||||||
|
@ -1248,7 +1248,7 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm,
|
|||||||
if (pcpus > 0 && pcpus < nvcpus)
|
if (pcpus > 0 && pcpus < nvcpus)
|
||||||
nvcpus = pcpus;
|
nvcpus = pcpus;
|
||||||
|
|
||||||
snprintf(str_vcpus, sizeof(str_vcpus), "%d", nvcpus);
|
g_snprintf(str_vcpus, sizeof(str_vcpus), "%d", nvcpus);
|
||||||
|
|
||||||
openvzSetProgramSentinal(prog, vm->def->name);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (virRun(prog, NULL) < 0)
|
if (virRun(prog, NULL) < 0)
|
||||||
@ -1503,7 +1503,7 @@ static int openvzConnectListDefinedDomains(virConnectPtr conn G_GNUC_UNUSED,
|
|||||||
_("Could not parse VPS ID %s"), buf);
|
_("Could not parse VPS ID %s"), buf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
snprintf(vpsname, sizeof(vpsname), "%d", veid);
|
g_snprintf(vpsname, sizeof(vpsname), "%d", veid);
|
||||||
names[got] = g_strdup(vpsname);
|
names[got] = g_strdup(vpsname);
|
||||||
got ++;
|
got ++;
|
||||||
}
|
}
|
||||||
@ -1600,7 +1600,7 @@ openvzDomainSetMemoryInternal(virDomainObjPtr vm,
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* memory has to be changed its format from kbyte to byte */
|
/* 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);
|
openvzSetProgramSentinal(prog, vm->def->name);
|
||||||
if (virRun(prog, NULL) < 0)
|
if (virRun(prog, NULL) < 0)
|
||||||
|
@ -2225,61 +2225,61 @@ qemuAgentGetFSInfoParams(qemuAgentPtr mon,
|
|||||||
|
|
||||||
for (i = 0; i < nfs; i++) {
|
for (i = 0; i < nfs; i++) {
|
||||||
char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
|
char param_name[VIR_TYPED_PARAM_FIELD_LENGTH];
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"fs.%zu.name", i);
|
"fs.%zu.name", i);
|
||||||
if (virTypedParamsAddString(params, nparams, maxparams,
|
if (virTypedParamsAddString(params, nparams, maxparams,
|
||||||
param_name, fsinfo[i]->name) < 0)
|
param_name, fsinfo[i]->name) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"fs.%zu.mountpoint", i);
|
"fs.%zu.mountpoint", i);
|
||||||
if (virTypedParamsAddString(params, nparams, maxparams,
|
if (virTypedParamsAddString(params, nparams, maxparams,
|
||||||
param_name, fsinfo[i]->mountpoint) < 0)
|
param_name, fsinfo[i]->mountpoint) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"fs.%zu.fstype", i);
|
"fs.%zu.fstype", i);
|
||||||
if (virTypedParamsAddString(params, nparams, maxparams,
|
if (virTypedParamsAddString(params, nparams, maxparams,
|
||||||
param_name, fsinfo[i]->fstype) < 0)
|
param_name, fsinfo[i]->fstype) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
/* disk usage values are not returned by older guest agents, so
|
/* disk usage values are not returned by older guest agents, so
|
||||||
* only add the params if the value is set */
|
* only add the params if the value is set */
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"fs.%zu.total-bytes", i);
|
"fs.%zu.total-bytes", i);
|
||||||
if (fsinfo[i]->total_bytes != -1 &&
|
if (fsinfo[i]->total_bytes != -1 &&
|
||||||
virTypedParamsAddULLong(params, nparams, maxparams,
|
virTypedParamsAddULLong(params, nparams, maxparams,
|
||||||
param_name, fsinfo[i]->total_bytes) < 0)
|
param_name, fsinfo[i]->total_bytes) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"fs.%zu.used-bytes", i);
|
"fs.%zu.used-bytes", i);
|
||||||
if (fsinfo[i]->used_bytes != -1 &&
|
if (fsinfo[i]->used_bytes != -1 &&
|
||||||
virTypedParamsAddULLong(params, nparams, maxparams,
|
virTypedParamsAddULLong(params, nparams, maxparams,
|
||||||
param_name, fsinfo[i]->used_bytes) < 0)
|
param_name, fsinfo[i]->used_bytes) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"fs.%zu.disk.count", i);
|
"fs.%zu.disk.count", i);
|
||||||
if (virTypedParamsAddUInt(params, nparams, maxparams,
|
if (virTypedParamsAddUInt(params, nparams, maxparams,
|
||||||
param_name, fsinfo[i]->ndisks) < 0)
|
param_name, fsinfo[i]->ndisks) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
for (j = 0; j < fsinfo[i]->ndisks; j++) {
|
for (j = 0; j < fsinfo[i]->ndisks; j++) {
|
||||||
qemuAgentDiskInfoPtr d = fsinfo[i]->disks[j];
|
qemuAgentDiskInfoPtr d = fsinfo[i]->disks[j];
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"fs.%zu.disk.%zu.alias", i, j);
|
"fs.%zu.disk.%zu.alias", i, j);
|
||||||
if (d->alias &&
|
if (d->alias &&
|
||||||
virTypedParamsAddString(params, nparams, maxparams,
|
virTypedParamsAddString(params, nparams, maxparams,
|
||||||
param_name, d->alias) < 0)
|
param_name, d->alias) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"fs.%zu.disk.%zu.serial", i, j);
|
"fs.%zu.disk.%zu.serial", i, j);
|
||||||
if (d->serial &&
|
if (d->serial &&
|
||||||
virTypedParamsAddString(params, nparams, maxparams,
|
virTypedParamsAddString(params, nparams, maxparams,
|
||||||
param_name, d->serial) < 0)
|
param_name, d->serial) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"fs.%zu.disk.%zu.device", i, j);
|
"fs.%zu.disk.%zu.device", i, j);
|
||||||
if (d->devnode &&
|
if (d->devnode &&
|
||||||
virTypedParamsAddString(params, nparams, maxparams,
|
virTypedParamsAddString(params, nparams, maxparams,
|
||||||
param_name, d->devnode) < 0)
|
param_name, d->devnode) < 0)
|
||||||
@ -2582,15 +2582,15 @@ qemuAgentGetUsers(qemuAgentPtr mon,
|
|||||||
return -1;
|
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,
|
if (virTypedParamsAddString(params, nparams, maxparams,
|
||||||
param_name, strvalue) < 0)
|
param_name, strvalue) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* 'domain' is only present for windows guests */
|
/* 'domain' is only present for windows guests */
|
||||||
if ((strvalue = virJSONValueObjectGetString(entry, "domain"))) {
|
if ((strvalue = virJSONValueObjectGetString(entry, "domain"))) {
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"user.%zu.domain", i);
|
"user.%zu.domain", i);
|
||||||
if (virTypedParamsAddString(params, nparams, maxparams,
|
if (virTypedParamsAddString(params, nparams, maxparams,
|
||||||
param_name, strvalue) < 0)
|
param_name, strvalue) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -2601,8 +2601,8 @@ qemuAgentGetUsers(qemuAgentPtr mon,
|
|||||||
_("'login-time' missing in reply of guest-get-users"));
|
_("'login-time' missing in reply of guest-get-users"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"user.%zu.login-time", i);
|
"user.%zu.login-time", i);
|
||||||
if (virTypedParamsAddULLong(params, nparams, maxparams,
|
if (virTypedParamsAddULLong(params, nparams, maxparams,
|
||||||
param_name, logintime * 1000) < 0)
|
param_name, logintime * 1000) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -5106,8 +5106,8 @@ qemuDomainPinVcpuLive(virDomainObjPtr vm,
|
|||||||
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
|
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
|
if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) {
|
VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) {
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5801,8 +5801,8 @@ qemuDomainPinIOThread(virDomainPtr dom,
|
|||||||
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
|
if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm, driver->caps) < 0)
|
||||||
goto endjob;
|
goto endjob;
|
||||||
|
|
||||||
if (snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
|
if (g_snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
VIR_DOMAIN_TUNABLE_CPU_IOTHREADSPIN, iothread_id) < 0) {
|
VIR_DOMAIN_TUNABLE_CPU_IOTHREADSPIN, iothread_id) < 0) {
|
||||||
goto endjob;
|
goto endjob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2342,8 +2342,8 @@ virSecurityDACGetProcessLabelInternal(pid_t pid,
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(seclabel->label, VIR_SECURITY_LABEL_BUFLEN,
|
g_snprintf(seclabel->label, VIR_SECURITY_LABEL_BUFLEN,
|
||||||
"+%u:+%u", (unsigned int)sb.st_uid, (unsigned int)sb.st_gid);
|
"+%u:+%u", (unsigned int)sb.st_uid, (unsigned int)sb.st_gid);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@ -2371,8 +2371,8 @@ virSecurityDACGetProcessLabelInternal(pid_t pid,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(seclabel->label, VIR_SECURITY_LABEL_BUFLEN,
|
g_snprintf(seclabel->label, VIR_SECURITY_LABEL_BUFLEN,
|
||||||
"+%u:+%u", (unsigned int)p.ki_uid, (unsigned int)p.ki_groups[0]);
|
"+%u:+%u", (unsigned int)p.ki_uid, (unsigned int)p.ki_groups[0]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -155,7 +155,7 @@ parserCommand(const char *profile_name, const char cmd)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(flag, 3, "-%c", cmd);
|
g_snprintf(flag, 3, "-%c", cmd);
|
||||||
|
|
||||||
profile = g_strdup_printf("%s/%s", APPARMOR_DIR "/libvirt", profile_name);
|
profile = g_strdup_printf("%s/%s", APPARMOR_DIR "/libvirt", profile_name);
|
||||||
|
|
||||||
|
@ -3961,7 +3961,7 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
|
|||||||
if (virDirOpen(&devicedir, device_path) < 0)
|
if (virDirOpen(&devicedir, device_path) < 0)
|
||||||
return -1;
|
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) {
|
while ((retval = virDirRead(devicedir, &lun_dirent, device_path)) > 0) {
|
||||||
int rc;
|
int rc;
|
||||||
|
@ -794,7 +794,7 @@ virHostCPUGetStatsLinux(FILE *procstat,
|
|||||||
if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS) {
|
if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS) {
|
||||||
strcpy(cpu_header, "cpu ");
|
strcpy(cpu_header, "cpu ");
|
||||||
} else {
|
} 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) {
|
while (fgets(line, sizeof(line), procstat) != NULL) {
|
||||||
|
@ -192,7 +192,7 @@ iptablesInput(virFirewallPtr fw,
|
|||||||
{
|
{
|
||||||
char portstr[32];
|
char portstr[32];
|
||||||
|
|
||||||
snprintf(portstr, sizeof(portstr), "%d", port);
|
g_snprintf(portstr, sizeof(portstr), "%d", port);
|
||||||
portstr[sizeof(portstr) - 1] = '\0';
|
portstr[sizeof(portstr) - 1] = '\0';
|
||||||
|
|
||||||
virFirewallAddRule(fw, layer,
|
virFirewallAddRule(fw, layer,
|
||||||
@ -217,7 +217,7 @@ iptablesOutput(virFirewallPtr fw,
|
|||||||
{
|
{
|
||||||
char portstr[32];
|
char portstr[32];
|
||||||
|
|
||||||
snprintf(portstr, sizeof(portstr), "%d", port);
|
g_snprintf(portstr, sizeof(portstr), "%d", port);
|
||||||
portstr[sizeof(portstr) - 1] = '\0';
|
portstr[sizeof(portstr) - 1] = '\0';
|
||||||
|
|
||||||
virFirewallAddRule(fw, layer,
|
virFirewallAddRule(fw, layer,
|
||||||
@ -1100,7 +1100,7 @@ iptablesOutputFixUdpChecksum(virFirewallPtr fw,
|
|||||||
{
|
{
|
||||||
char portstr[32];
|
char portstr[32];
|
||||||
|
|
||||||
snprintf(portstr, sizeof(portstr), "%d", port);
|
g_snprintf(portstr, sizeof(portstr), "%d", port);
|
||||||
portstr[sizeof(portstr) - 1] = '\0';
|
portstr[sizeof(portstr) - 1] = '\0';
|
||||||
|
|
||||||
virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4,
|
virFirewallAddRule(fw, VIR_FIREWALL_LAYER_IPV4,
|
||||||
|
@ -187,10 +187,10 @@ const char *
|
|||||||
virMacAddrFormat(const virMacAddr *addr,
|
virMacAddrFormat(const virMacAddr *addr,
|
||||||
char *str)
|
char *str)
|
||||||
{
|
{
|
||||||
snprintf(str, VIR_MAC_STRING_BUFLEN,
|
g_snprintf(str, VIR_MAC_STRING_BUFLEN,
|
||||||
"%02x:%02x:%02x:%02x:%02x:%02x",
|
"%02x:%02x:%02x:%02x:%02x:%02x",
|
||||||
addr->addr[0], addr->addr[1], addr->addr[2],
|
addr->addr[0], addr->addr[1], addr->addr[2],
|
||||||
addr->addr[3], addr->addr[4], addr->addr[5]);
|
addr->addr[3], addr->addr[4], addr->addr[5]);
|
||||||
str[VIR_MAC_STRING_BUFLEN-1] = '\0';
|
str[VIR_MAC_STRING_BUFLEN-1] = '\0';
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ static int virNetDevBridgeSet(const char *brname,
|
|||||||
|
|
||||||
if (virFileExists(path)) {
|
if (virFileExists(path)) {
|
||||||
char valuestr[INT_BUFSIZE_BOUND(value)];
|
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)
|
if (virFileWriteStr(path, valuestr, 0) >= 0)
|
||||||
return 0;
|
return 0;
|
||||||
VIR_DEBUG("Unable to set bridge %s %s via sysfs", brname, paramname);
|
VIR_DEBUG("Unable to set bridge %s %s via sysfs", brname, paramname);
|
||||||
@ -219,7 +219,7 @@ virNetDevBridgePortSet(const char *brname,
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
g_autofree char *path = NULL;
|
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,
|
path = g_strdup_printf(SYSFS_NET_DIR "%s/brif/%s/%s", brname, ifname,
|
||||||
paramname);
|
paramname);
|
||||||
|
@ -526,11 +526,11 @@ typedef struct virNetlinkCallbackData *virNetlinkCallbackDataPtr;
|
|||||||
static int instance2str(const unsigned char *p, char *dst, size_t size)
|
static int instance2str(const unsigned char *p, char *dst, size_t size)
|
||||||
{
|
{
|
||||||
if (dst && size > INSTANCE_STRLEN) {
|
if (dst && size > INSTANCE_STRLEN) {
|
||||||
snprintf(dst, size, "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
|
g_snprintf(dst, size, "%02x%02x%02x%02x-%02x%02x-%02x%02x-"
|
||||||
"%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[0], p[1], p[2], p[3],
|
||||||
p[4], p[5], p[6], p[7],
|
p[4], p[5], p[6], p[7],
|
||||||
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
|
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
@ -997,7 +997,7 @@ virNetDevMacVLanCreateWithVPortProfile(const char *ifnameRequested,
|
|||||||
virMutexUnlock(&virNetDevMacVLanCreateMutex);
|
virMutexUnlock(&virNetDevMacVLanCreateMutex);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
snprintf(ifname, sizeof(ifname), pattern, reservedID);
|
g_snprintf(ifname, sizeof(ifname), pattern, reservedID);
|
||||||
if (virNetDevMacVLanCreate(ifname, type, macaddress, linkdev,
|
if (virNetDevMacVLanCreate(ifname, type, macaddress, linkdev,
|
||||||
macvtapMode, &do_retry) < 0) {
|
macvtapMode, &do_retry) < 0) {
|
||||||
virNetDevMacVLanReleaseID(reservedID, flags);
|
virNetDevMacVLanReleaseID(reservedID, flags);
|
||||||
|
@ -1394,8 +1394,8 @@ virPCIDeviceNew(unsigned int domain,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* strings contain '0x' prefix */
|
/* strings contain '0x' prefix */
|
||||||
if (snprintf(dev->id, sizeof(dev->id), "%s %s", &vendor[2],
|
if (g_snprintf(dev->id, sizeof(dev->id), "%s %s", &vendor[2],
|
||||||
&product[2]) >= sizeof(dev->id)) {
|
&product[2]) >= sizeof(dev->id)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("dev->id buffer overflow: %s %s"),
|
_("dev->id buffer overflow: %s %s"),
|
||||||
&vendor[2], &product[2]);
|
&vendor[2], &product[2]);
|
||||||
|
@ -67,7 +67,7 @@ int virPidFileWritePath(const char *pidfile,
|
|||||||
goto cleanup;
|
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) {
|
if (safewrite(fd, pidstr, strlen(pidstr)) < 0) {
|
||||||
rc = -errno;
|
rc = -errno;
|
||||||
@ -392,7 +392,7 @@ int virPidFileAcquirePath(const char *path,
|
|||||||
/* Someone else must be racing with us, so try again */
|
/* 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) {
|
if (ftruncate(fd, 0) < 0) {
|
||||||
virReportSystemError(errno,
|
virReportSystemError(errno,
|
||||||
|
@ -209,11 +209,11 @@ int virTimeStringThenRaw(unsigned long long when, char *buf)
|
|||||||
fields.tm_year += 1900;
|
fields.tm_year += 1900;
|
||||||
fields.tm_mon += 1;
|
fields.tm_mon += 1;
|
||||||
|
|
||||||
if (snprintf(buf, VIR_TIME_STRING_BUFLEN,
|
if (g_snprintf(buf, VIR_TIME_STRING_BUFLEN,
|
||||||
"%4d-%02d-%02d %02d:%02d:%02d.%03d+0000",
|
"%4d-%02d-%02d %02d:%02d:%02d.%03d+0000",
|
||||||
fields.tm_year, fields.tm_mon, fields.tm_mday,
|
fields.tm_year, fields.tm_mon, fields.tm_mday,
|
||||||
fields.tm_hour, fields.tm_min, fields.tm_sec,
|
fields.tm_hour, fields.tm_min, fields.tm_sec,
|
||||||
(int) (when % 1000)) >= VIR_TIME_STRING_BUFLEN) {
|
(int) (when % 1000)) >= VIR_TIME_STRING_BUFLEN) {
|
||||||
errno = ERANGE;
|
errno = ERANGE;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -319,8 +319,8 @@ virUSBDeviceNew(unsigned int bus,
|
|||||||
dev->bus = bus;
|
dev->bus = bus;
|
||||||
dev->dev = devno;
|
dev->dev = devno;
|
||||||
|
|
||||||
if (snprintf(dev->name, sizeof(dev->name), "%.3d:%.3d",
|
if (g_snprintf(dev->name, sizeof(dev->name), "%.3d:%.3d",
|
||||||
dev->bus, dev->dev) >= sizeof(dev->name)) {
|
dev->bus, dev->dev) >= sizeof(dev->name)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("dev->name buffer overflow: %.3d:%.3d"),
|
_("dev->name buffer overflow: %.3d:%.3d"),
|
||||||
dev->bus, dev->dev);
|
dev->bus, dev->dev);
|
||||||
@ -337,8 +337,8 @@ virUSBDeviceNew(unsigned int bus,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* XXX fixme. this should be product/vendor */
|
/* XXX fixme. this should be product/vendor */
|
||||||
if (snprintf(dev->id, sizeof(dev->id), "%d %d", dev->bus,
|
if (g_snprintf(dev->id, sizeof(dev->id), "%d %d", dev->bus,
|
||||||
dev->dev) >= sizeof(dev->id)) {
|
dev->dev) >= sizeof(dev->id)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("dev->id buffer overflow: %d %d"),
|
_("dev->id buffer overflow: %d %d"),
|
||||||
dev->bus, dev->dev);
|
dev->bus, dev->dev);
|
||||||
|
@ -153,12 +153,12 @@ virUUIDParse(const char *uuidstr, unsigned char *uuid)
|
|||||||
const char *
|
const char *
|
||||||
virUUIDFormat(const unsigned char *uuid, char *uuidstr)
|
virUUIDFormat(const unsigned char *uuid, char *uuidstr)
|
||||||
{
|
{
|
||||||
snprintf(uuidstr, VIR_UUID_STRING_BUFLEN,
|
g_snprintf(uuidstr, VIR_UUID_STRING_BUFLEN,
|
||||||
"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
|
"%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[0], uuid[1], uuid[2], uuid[3],
|
||||||
uuid[4], uuid[5], uuid[6], uuid[7],
|
uuid[4], uuid[5], uuid[6], uuid[7],
|
||||||
uuid[8], uuid[9], uuid[10], uuid[11],
|
uuid[8], uuid[9], uuid[10], uuid[11],
|
||||||
uuid[12], uuid[13], uuid[14], uuid[15]);
|
uuid[12], uuid[13], uuid[14], uuid[15]);
|
||||||
uuidstr[VIR_UUID_STRING_BUFLEN-1] = '\0';
|
uuidstr[VIR_UUID_STRING_BUFLEN-1] = '\0';
|
||||||
return uuidstr;
|
return uuidstr;
|
||||||
}
|
}
|
||||||
|
@ -1288,14 +1288,14 @@ vboxAttachNetwork(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
|
|||||||
PRUnichar *MACAddress = NULL;
|
PRUnichar *MACAddress = NULL;
|
||||||
|
|
||||||
virMacAddrFormat(&def->nets[i]->mac, macaddr);
|
virMacAddrFormat(&def->nets[i]->mac, macaddr);
|
||||||
snprintf(macaddrvbox, VIR_MAC_STRING_BUFLEN - 5,
|
g_snprintf(macaddrvbox, VIR_MAC_STRING_BUFLEN - 5,
|
||||||
"%02X%02X%02X%02X%02X%02X",
|
"%02X%02X%02X%02X%02X%02X",
|
||||||
def->nets[i]->mac.addr[0],
|
def->nets[i]->mac.addr[0],
|
||||||
def->nets[i]->mac.addr[1],
|
def->nets[i]->mac.addr[1],
|
||||||
def->nets[i]->mac.addr[2],
|
def->nets[i]->mac.addr[2],
|
||||||
def->nets[i]->mac.addr[3],
|
def->nets[i]->mac.addr[3],
|
||||||
def->nets[i]->mac.addr[4],
|
def->nets[i]->mac.addr[4],
|
||||||
def->nets[i]->mac.addr[5]);
|
def->nets[i]->mac.addr[5]);
|
||||||
macaddrvbox[VIR_MAC_STRING_BUFLEN - 6] = '\0';
|
macaddrvbox[VIR_MAC_STRING_BUFLEN - 6] = '\0';
|
||||||
|
|
||||||
VIR_DEBUG("NIC(%zu): Type: %d", i, def->nets[i]->type);
|
VIR_DEBUG("NIC(%zu): Type: %d", i, def->nets[i]->type);
|
||||||
@ -1786,15 +1786,15 @@ vboxAttachUSB(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (def->hostdevs[i]->source.subsys.u.usb.vendor) {
|
if (def->hostdevs[i]->source.subsys.u.usb.vendor) {
|
||||||
snprintf(vendorId, sizeof(vendorId), "%x",
|
g_snprintf(vendorId, sizeof(vendorId), "%x",
|
||||||
def->hostdevs[i]->source.subsys.u.usb.vendor);
|
def->hostdevs[i]->source.subsys.u.usb.vendor);
|
||||||
VBOX_UTF8_TO_UTF16(vendorId, &vendorIdUtf16);
|
VBOX_UTF8_TO_UTF16(vendorId, &vendorIdUtf16);
|
||||||
gVBoxAPI.UIUSBDeviceFilter.SetVendorId(filter, vendorIdUtf16);
|
gVBoxAPI.UIUSBDeviceFilter.SetVendorId(filter, vendorIdUtf16);
|
||||||
VBOX_UTF16_FREE(vendorIdUtf16);
|
VBOX_UTF16_FREE(vendorIdUtf16);
|
||||||
}
|
}
|
||||||
if (def->hostdevs[i]->source.subsys.u.usb.product) {
|
if (def->hostdevs[i]->source.subsys.u.usb.product) {
|
||||||
snprintf(productId, sizeof(productId), "%x",
|
g_snprintf(productId, sizeof(productId), "%x",
|
||||||
def->hostdevs[i]->source.subsys.u.usb.product);
|
def->hostdevs[i]->source.subsys.u.usb.product);
|
||||||
VBOX_UTF8_TO_UTF16(productId, &productIdUtf16);
|
VBOX_UTF8_TO_UTF16(productId, &productIdUtf16);
|
||||||
gVBoxAPI.UIUSBDeviceFilter.SetProductId(filter,
|
gVBoxAPI.UIUSBDeviceFilter.SetProductId(filter,
|
||||||
productIdUtf16);
|
productIdUtf16);
|
||||||
|
@ -214,7 +214,7 @@ static PRUnichar *PRUnicharFromInt(PCVBOXXPCOM pFuncs, int n) {
|
|||||||
PRUnichar *strUtf16 = NULL;
|
PRUnichar *strUtf16 = NULL;
|
||||||
char s[24];
|
char s[24];
|
||||||
|
|
||||||
snprintf(s, sizeof(s), "%d", n);
|
g_snprintf(s, sizeof(s), "%d", n);
|
||||||
|
|
||||||
pFuncs->pfnUtf8ToUtf16(s, &strUtf16);
|
pFuncs->pfnUtf8ToUtf16(s, &strUtf16);
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ def->parallels[0]...
|
|||||||
#define VIR_FROM_THIS VIR_FROM_NONE
|
#define VIR_FROM_THIS VIR_FROM_NONE
|
||||||
|
|
||||||
#define VMX_BUILD_NAME_EXTRA(_suffix, _extra) \
|
#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) \
|
#define VMX_BUILD_NAME(_suffix) \
|
||||||
VMX_BUILD_NAME_EXTRA(_suffix, #_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) {
|
if (*tmp1 == escape || strspn(tmp1, special) > 0) {
|
||||||
*tmp2++ = escape;
|
*tmp2++ = escape;
|
||||||
|
|
||||||
snprintf(tmp2, 3, "%02x", (unsigned int)*tmp1);
|
g_snprintf(tmp2, 3, "%02x", (unsigned int)*tmp1);
|
||||||
|
|
||||||
tmp2 += 2;
|
tmp2 += 2;
|
||||||
} else {
|
} else {
|
||||||
@ -1951,9 +1951,9 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(present_name, sizeof(present_name), "scsi%d.present", controller);
|
g_snprintf(present_name, sizeof(present_name), "scsi%d.present", controller);
|
||||||
snprintf(virtualDev_name, sizeof(virtualDev_name), "scsi%d.virtualDev",
|
g_snprintf(virtualDev_name, sizeof(virtualDev_name), "scsi%d.virtualDev",
|
||||||
controller);
|
controller);
|
||||||
|
|
||||||
if (virVMXGetConfigBoolean(conf, present_name, present, false, true) < 0)
|
if (virVMXGetConfigBoolean(conf, present_name, present, false, true) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -2443,7 +2443,7 @@ int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(prefix, sizeof(prefix), "sharedFolder%d", number);
|
g_snprintf(prefix, sizeof(prefix), "sharedFolder%d", number);
|
||||||
|
|
||||||
VMX_BUILD_NAME(present);
|
VMX_BUILD_NAME(present);
|
||||||
VMX_BUILD_NAME(enabled);
|
VMX_BUILD_NAME(enabled);
|
||||||
@ -2548,7 +2548,7 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(prefix, sizeof(prefix), "ethernet%d", controller);
|
g_snprintf(prefix, sizeof(prefix), "ethernet%d", controller);
|
||||||
|
|
||||||
VMX_BUILD_NAME(present);
|
VMX_BUILD_NAME(present);
|
||||||
VMX_BUILD_NAME(startConnected);
|
VMX_BUILD_NAME(startConnected);
|
||||||
@ -2753,7 +2753,7 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(prefix, sizeof(prefix), "serial%d", port);
|
g_snprintf(prefix, sizeof(prefix), "serial%d", port);
|
||||||
|
|
||||||
VMX_BUILD_NAME(present);
|
VMX_BUILD_NAME(present);
|
||||||
VMX_BUILD_NAME(startConnected);
|
VMX_BUILD_NAME(startConnected);
|
||||||
@ -2930,7 +2930,7 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(prefix, sizeof(prefix), "parallel%d", port);
|
g_snprintf(prefix, sizeof(prefix), "parallel%d", port);
|
||||||
|
|
||||||
VMX_BUILD_NAME(present);
|
VMX_BUILD_NAME(present);
|
||||||
VMX_BUILD_NAME(startConnected);
|
VMX_BUILD_NAME(startConnected);
|
||||||
|
@ -3453,8 +3453,8 @@ vzDomainGetJobStats(virDomainPtr domain,
|
|||||||
#define VZ_ADD_STAT_PARAM_UUL(group, field, counter) \
|
#define VZ_ADD_STAT_PARAM_UUL(group, field, counter) \
|
||||||
do { \
|
do { \
|
||||||
if (stat.field != -1) { \
|
if (stat.field != -1) { \
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \
|
||||||
group ".%zu." counter, i); \
|
group ".%zu." counter, i); \
|
||||||
if (virTypedParamsAddULLong(&record->params, \
|
if (virTypedParamsAddULLong(&record->params, \
|
||||||
&record->nparams, \
|
&record->nparams, \
|
||||||
maxparams, \
|
maxparams, \
|
||||||
@ -3490,8 +3490,8 @@ vzDomainGetBlockStats(virDomainObjPtr dom,
|
|||||||
IS_CT(dom->def)) < 0)
|
IS_CT(dom->def)) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"block.%zu.name", i);
|
"block.%zu.name", i);
|
||||||
if (virTypedParamsAddString(&record->params,
|
if (virTypedParamsAddString(&record->params,
|
||||||
&record->nparams,
|
&record->nparams,
|
||||||
maxparams,
|
maxparams,
|
||||||
@ -3500,8 +3500,8 @@ vzDomainGetBlockStats(virDomainObjPtr dom,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (virStorageSourceIsLocalStorage(disk->src) && disk->src->path) {
|
if (virStorageSourceIsLocalStorage(disk->src) && disk->src->path) {
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"block.%zu.path", i);
|
"block.%zu.path", i);
|
||||||
if (virTypedParamsAddString(&record->params,
|
if (virTypedParamsAddString(&record->params,
|
||||||
&record->nparams,
|
&record->nparams,
|
||||||
maxparams,
|
maxparams,
|
||||||
@ -3516,8 +3516,8 @@ vzDomainGetBlockStats(virDomainObjPtr dom,
|
|||||||
VZ_ADD_STAT_PARAM_UUL("block", wr_bytes, "wr.bytes");
|
VZ_ADD_STAT_PARAM_UUL("block", wr_bytes, "wr.bytes");
|
||||||
|
|
||||||
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"block.%zu.capacity", i);
|
"block.%zu.capacity", i);
|
||||||
if (virTypedParamsAddULLong(&record->params,
|
if (virTypedParamsAddULLong(&record->params,
|
||||||
&record->nparams,
|
&record->nparams,
|
||||||
maxparams,
|
maxparams,
|
||||||
@ -3555,7 +3555,7 @@ vzDomainGetNetStats(virDomainObjPtr dom,
|
|||||||
&stat) < 0)
|
&stat) < 0)
|
||||||
return -1;
|
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,
|
if (virTypedParamsAddString(&record->params,
|
||||||
&record->nparams,
|
&record->nparams,
|
||||||
maxparams,
|
maxparams,
|
||||||
@ -3600,7 +3600,7 @@ vzDomainGetVCPUStats(virDomainObjPtr dom,
|
|||||||
VIR_VCPU_OFFLINE;
|
VIR_VCPU_OFFLINE;
|
||||||
unsigned long long time;
|
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,
|
if (virTypedParamsAddInt(&record->params,
|
||||||
&record->nparams,
|
&record->nparams,
|
||||||
maxparams,
|
maxparams,
|
||||||
@ -3611,7 +3611,7 @@ vzDomainGetVCPUStats(virDomainObjPtr dom,
|
|||||||
if (prlsdkGetVcpuStats(privdom->stats, i, &time) < 0)
|
if (prlsdkGetVcpuStats(privdom->stats, i, &time) < 0)
|
||||||
return -1;
|
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,
|
if (virTypedParamsAddULLong(&record->params,
|
||||||
&record->nparams,
|
&record->nparams,
|
||||||
maxparams,
|
maxparams,
|
||||||
|
@ -3171,10 +3171,10 @@ static int prlsdkAddSerial(PRL_HANDLE sdkdom, virDomainChrDefPtr chr)
|
|||||||
|
|
||||||
static const char * prlsdkFormatMac(virMacAddrPtr mac, char *macstr)
|
static const char * prlsdkFormatMac(virMacAddrPtr mac, char *macstr)
|
||||||
{
|
{
|
||||||
snprintf(macstr, PRL_MAC_STRING_BUFNAME,
|
g_snprintf(macstr, PRL_MAC_STRING_BUFNAME,
|
||||||
"%02X%02X%02X%02X%02X%02X",
|
"%02X%02X%02X%02X%02X%02X",
|
||||||
mac->addr[0], mac->addr[1], mac->addr[2],
|
mac->addr[0], mac->addr[1], mac->addr[2],
|
||||||
mac->addr[3], mac->addr[4], mac->addr[5]);
|
mac->addr[3], mac->addr[4], mac->addr[5]);
|
||||||
macstr[PRL_MAC_STRING_BUFNAME - 1] = '\0';
|
macstr[PRL_MAC_STRING_BUFNAME - 1] = '\0';
|
||||||
return macstr;
|
return macstr;
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ VIR_MOCK_IMPL_RET_ARGS(virFileMakePath, int,
|
|||||||
{
|
{
|
||||||
/* replace log path with a writable directory */
|
/* replace log path with a writable directory */
|
||||||
if (strstr(path, "/log/")) {
|
if (strstr(path, "/log/")) {
|
||||||
snprintf((char*)path, strlen(path), ".");
|
g_snprintf((char*)path, strlen(path), ".");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return real_virFileMakePath(path);
|
return real_virFileMakePath(path);
|
||||||
|
@ -1111,8 +1111,8 @@ checkUserInfo(virTypedParameterPtr params,
|
|||||||
const char *domain = NULL;
|
const char *domain = NULL;
|
||||||
unsigned long long logintime = 0;
|
unsigned long long logintime = 0;
|
||||||
|
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"user.%zu.name", nth);
|
"user.%zu.name", nth);
|
||||||
if (virTypedParamsGetString(params, nparams, param_name, &username) < 0)
|
if (virTypedParamsGetString(params, nparams, param_name, &username) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -1123,8 +1123,8 @@ checkUserInfo(virTypedParameterPtr params,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"user.%zu.domain", nth);
|
"user.%zu.domain", nth);
|
||||||
if (virTypedParamsGetString(params, nparams, param_name, &domain) < 0)
|
if (virTypedParamsGetString(params, nparams, param_name, &domain) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -1135,8 +1135,8 @@ checkUserInfo(virTypedParameterPtr params,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
g_snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH,
|
||||||
"user.%zu.login-time", nth);
|
"user.%zu.login-time", nth);
|
||||||
if (virTypedParamsGetULLong(params, nparams, param_name, &logintime) < 0)
|
if (virTypedParamsGetULLong(params, nparams, param_name, &logintime) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -1187,7 +1187,7 @@ const char
|
|||||||
/* calculate length of the rest of the string */
|
/* calculate length of the rest of the string */
|
||||||
len -= (virtTestCounterPrefixEndOffset - virtTestCounterStr);
|
len -= (virtTestCounterPrefixEndOffset - virtTestCounterStr);
|
||||||
|
|
||||||
snprintf(virtTestCounterPrefixEndOffset, len, "%d", ++virtTestCounter);
|
g_snprintf(virtTestCounterPrefixEndOffset, len, "%d", ++virtTestCounter);
|
||||||
|
|
||||||
return virtTestCounterStr;
|
return virtTestCounterStr;
|
||||||
}
|
}
|
||||||
|
@ -211,7 +211,7 @@ testSocketAccept(const void *opaque)
|
|||||||
|
|
||||||
cdata.path = path;
|
cdata.path = path;
|
||||||
} else {
|
} else {
|
||||||
snprintf(portstr, sizeof(portstr), "%d", data->port);
|
g_snprintf(portstr, sizeof(portstr), "%d", data->port);
|
||||||
if (virNetSocketNewListenTCP(data->lnode, portstr,
|
if (virNetSocketNewListenTCP(data->lnode, portstr,
|
||||||
AF_UNSPEC,
|
AF_UNSPEC,
|
||||||
&lsock, &nlsock) < 0)
|
&lsock, &nlsock) < 0)
|
||||||
|
@ -417,9 +417,9 @@ pci_device_create_iommu(const struct pciDevice *dev,
|
|||||||
if (virFileMakePath(iommuPath) < 0)
|
if (virFileMakePath(iommuPath) < 0)
|
||||||
ABORT("Unable to create: %s", iommuPath);
|
ABORT("Unable to create: %s", iommuPath);
|
||||||
|
|
||||||
if (snprintf(tmp, sizeof(tmp),
|
if (g_snprintf(tmp, sizeof(tmp),
|
||||||
"../../../../devices/pci%04x:%02x/%s",
|
"../../../../devices/pci%04x:%02x/%s",
|
||||||
dev->addr.domain, dev->addr.bus, devid) < 0) {
|
dev->addr.domain, dev->addr.bus, devid) < 0) {
|
||||||
ABORT("@tmp overflow");
|
ABORT("@tmp overflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -512,15 +512,15 @@ pci_device_new_from_stub(const struct pciDevice *data)
|
|||||||
make_file(devpath, "config", "some dummy config", -1);
|
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");
|
ABORT("@tmp overflow");
|
||||||
make_file(devpath, "vendor", tmp, -1);
|
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");
|
ABORT("@tmp overflow");
|
||||||
make_file(devpath, "device", tmp, -1);
|
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");
|
ABORT("@tmp overflow");
|
||||||
make_file(devpath, "class", tmp, -1);
|
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);
|
pci_device_create_iommu(dev, devid);
|
||||||
|
|
||||||
if (snprintf(tmp, sizeof(tmp),
|
if (g_snprintf(tmp, sizeof(tmp),
|
||||||
"../../../kernel/iommu_groups/%d", dev->iommuGroup) < 0) {
|
"../../../kernel/iommu_groups/%d", dev->iommuGroup) < 0) {
|
||||||
ABORT("@tmp overflow");
|
ABORT("@tmp overflow");
|
||||||
}
|
}
|
||||||
make_symlink(devpath, "iommu_group", tmp);
|
make_symlink(devpath, "iommu_group", tmp);
|
||||||
|
|
||||||
if (snprintf(tmp, sizeof(tmp),
|
if (g_snprintf(tmp, sizeof(tmp),
|
||||||
"../../../devices/pci%04x:%02x/%s",
|
"../../../devices/pci%04x:%02x/%s",
|
||||||
dev->addr.domain, dev->addr.bus, devid) < 0) {
|
dev->addr.domain, dev->addr.bus, devid) < 0) {
|
||||||
ABORT("@tmp overflow");
|
ABORT("@tmp overflow");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,9 +545,9 @@ pci_device_new_from_stub(const struct pciDevice *data)
|
|||||||
make_symlink(devsympath, devid, tmp);
|
make_symlink(devsympath, devid, tmp);
|
||||||
|
|
||||||
if (dev->physfn) {
|
if (dev->physfn) {
|
||||||
if (snprintf(tmp, sizeof(tmp),
|
if (g_snprintf(tmp, sizeof(tmp),
|
||||||
"%s%s/devices/%s", fakerootdir,
|
"%s%s/devices/%s", fakerootdir,
|
||||||
SYSFS_PCI_PREFIX, dev->physfn) < 0) {
|
SYSFS_PCI_PREFIX, dev->physfn) < 0) {
|
||||||
ABORT("@tmp overflow");
|
ABORT("@tmp overflow");
|
||||||
}
|
}
|
||||||
make_symlink(devpath, "physfn", tmp);
|
make_symlink(devpath, "physfn", tmp);
|
||||||
|
@ -564,8 +564,8 @@ testActivation(bool useNames)
|
|||||||
for (i = 0; i < nsockIP; i++)
|
for (i = 0; i < nsockIP; i++)
|
||||||
virBufferAddLit(&names, ":demo-ip.socket");
|
virBufferAddLit(&names, ":demo-ip.socket");
|
||||||
|
|
||||||
snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP);
|
g_snprintf(nfdstr, sizeof(nfdstr), "%zu", 1 + nsockIP);
|
||||||
snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid());
|
g_snprintf(pidstr, sizeof(pidstr), "%lld", (long long)getpid());
|
||||||
|
|
||||||
setenv("LISTEN_FDS", nfdstr, 1);
|
setenv("LISTEN_FDS", nfdstr, 1);
|
||||||
setenv("LISTEN_PID", pidstr, 1);
|
setenv("LISTEN_PID", pidstr, 1);
|
||||||
|
@ -2003,7 +2003,7 @@ cmdList(vshControl *ctl, const vshCmd *cmd)
|
|||||||
dom = list->domains[i];
|
dom = list->domains[i];
|
||||||
id = virDomainGetID(dom);
|
id = virDomainGetID(dom);
|
||||||
if (id != (unsigned int) -1)
|
if (id != (unsigned int) -1)
|
||||||
snprintf(id_buf, sizeof(id_buf), "%d", id);
|
g_snprintf(id_buf, sizeof(id_buf), "%d", id);
|
||||||
else
|
else
|
||||||
ignore_value(virStrcpyStatic(id_buf, "-"));
|
ignore_value(virStrcpyStatic(id_buf, "-"));
|
||||||
|
|
||||||
|
@ -12098,7 +12098,7 @@ virshDomainDetachInterface(char *doc,
|
|||||||
goto cleanup;
|
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);
|
obj = xmlXPathEval(BAD_CAST buf, ctxt);
|
||||||
if (obj == NULL || obj->type != XPATH_NODESET ||
|
if (obj == NULL || obj->type != XPATH_NODESET ||
|
||||||
obj->nodesetval == NULL || obj->nodesetval->nodeNr == 0) {
|
obj->nodesetval == NULL || obj->nodesetval->nodeNr == 0) {
|
||||||
|
@ -172,7 +172,7 @@ int virHostValidateNamespace(const char *hvname,
|
|||||||
virHostMsgCheck(hvname, "for namespace %s", ns_name);
|
virHostMsgCheck(hvname, "for namespace %s", ns_name);
|
||||||
char nspath[100];
|
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) {
|
if (access(nspath, F_OK) < 0) {
|
||||||
virHostMsgFail(level, "%s", hint);
|
virHostMsgFail(level, "%s", hint);
|
||||||
|
@ -227,7 +227,7 @@ vshTableSafeEncode(const char *s, size_t *width)
|
|||||||
while (p && *p) {
|
while (p && *p) {
|
||||||
if ((*p == '\\' && *(p + 1) == 'x') ||
|
if ((*p == '\\' && *(p + 1) == 'x') ||
|
||||||
c_iscntrl(*p)) {
|
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;
|
buf += HEX_ENCODE_LENGTH;
|
||||||
*width += HEX_ENCODE_LENGTH;
|
*width += HEX_ENCODE_LENGTH;
|
||||||
p++;
|
p++;
|
||||||
@ -245,7 +245,7 @@ vshTableSafeEncode(const char *s, size_t *width)
|
|||||||
* printable char according to the current locales.
|
* printable char according to the current locales.
|
||||||
*/
|
*/
|
||||||
if (!c_isprint(*p)) {
|
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;
|
buf += HEX_ENCODE_LENGTH;
|
||||||
*width += HEX_ENCODE_LENGTH;
|
*width += HEX_ENCODE_LENGTH;
|
||||||
} else {
|
} else {
|
||||||
@ -255,7 +255,7 @@ vshTableSafeEncode(const char *s, size_t *width)
|
|||||||
} else if (!iswprint(wc)) {
|
} else if (!iswprint(wc)) {
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < len; 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;
|
buf += HEX_ENCODE_LENGTH;
|
||||||
*width += HEX_ENCODE_LENGTH;
|
*width += HEX_ENCODE_LENGTH;
|
||||||
}
|
}
|
||||||
|
22
tools/vsh.c
22
tools/vsh.c
@ -719,24 +719,24 @@ vshCmddefHelp(vshControl *ctl, const vshCmdDef *def)
|
|||||||
for (opt = def->opts; opt->name; opt++) {
|
for (opt = def->opts; opt->name; opt++) {
|
||||||
switch (opt->type) {
|
switch (opt->type) {
|
||||||
case VSH_OT_BOOL:
|
case VSH_OT_BOOL:
|
||||||
snprintf(buf, sizeof(buf), "--%s", opt->name);
|
g_snprintf(buf, sizeof(buf), "--%s", opt->name);
|
||||||
break;
|
break;
|
||||||
case VSH_OT_INT:
|
case VSH_OT_INT:
|
||||||
snprintf(buf, sizeof(buf),
|
g_snprintf(buf, sizeof(buf),
|
||||||
(opt->flags & VSH_OFLAG_REQ) ? _("[--%s] <number>")
|
(opt->flags & VSH_OFLAG_REQ) ? _("[--%s] <number>")
|
||||||
: _("--%s <number>"), opt->name);
|
: _("--%s <number>"), opt->name);
|
||||||
break;
|
break;
|
||||||
case VSH_OT_STRING:
|
case VSH_OT_STRING:
|
||||||
snprintf(buf, sizeof(buf), _("--%s <string>"), opt->name);
|
g_snprintf(buf, sizeof(buf), _("--%s <string>"), opt->name);
|
||||||
break;
|
break;
|
||||||
case VSH_OT_DATA:
|
case VSH_OT_DATA:
|
||||||
snprintf(buf, sizeof(buf), _("[--%s] <string>"),
|
g_snprintf(buf, sizeof(buf), _("[--%s] <string>"),
|
||||||
opt->name);
|
opt->name);
|
||||||
break;
|
break;
|
||||||
case VSH_OT_ARGV:
|
case VSH_OT_ARGV:
|
||||||
snprintf(buf, sizeof(buf),
|
g_snprintf(buf, sizeof(buf),
|
||||||
shortopt ? _("[--%s] <string>") : _("<%s>"),
|
shortopt ? _("[--%s] <string>") : _("<%s>"),
|
||||||
opt->name);
|
opt->name);
|
||||||
break;
|
break;
|
||||||
case VSH_OT_ALIAS:
|
case VSH_OT_ALIAS:
|
||||||
continue;
|
continue;
|
||||||
@ -2690,7 +2690,7 @@ vshReadlineOptionsGenerator(const char *text,
|
|||||||
|
|
||||||
name_len = strlen(name);
|
name_len = strlen(name);
|
||||||
ret[ret_size] = vshMalloc(NULL, name_len + 3);
|
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++;
|
ret_size++;
|
||||||
/* Terminate the string list properly. */
|
/* Terminate the string list properly. */
|
||||||
ret[ret_size] = NULL;
|
ret[ret_size] = NULL;
|
||||||
|
@ -169,7 +169,7 @@ format_xdr_bytes(guint8 *bytes, guint32 length)
|
|||||||
for (i = 0; i < length; i++) {
|
for (i = 0; i < length; i++) {
|
||||||
/* We know that buf has enough size to contain
|
/* We know that buf has enough size to contain
|
||||||
2 * length + '\0' characters. */
|
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;
|
buf += 2;
|
||||||
}
|
}
|
||||||
return buf - length*2;
|
return buf - length*2;
|
||||||
|
Loading…
Reference in New Issue
Block a user