/* 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);
/* 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);
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'"),
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'"),
*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,
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,
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);
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"
#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;
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);
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);
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;
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;
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;
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;
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;
#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 */
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)
_("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 ++;
}
};
/* 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)
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)
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;
_("'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;
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;
}
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;
}
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:
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;
}
return -1;
}
- snprintf(flag, 3, "-%c", cmd);
+ g_snprintf(flag, 3, "-%c", cmd);
profile = g_strdup_printf("%s/%s", APPARMOR_DIR "/libvirt", profile_name);
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;
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) {
{
char portstr[32];
- snprintf(portstr, sizeof(portstr), "%d", port);
+ g_snprintf(portstr, sizeof(portstr), "%d", port);
portstr[sizeof(portstr) - 1] = '\0';
virFirewallAddRule(fw, layer,
{
char portstr[32];
- snprintf(portstr, sizeof(portstr), "%d", port);
+ g_snprintf(portstr, sizeof(portstr), "%d", port);
portstr[sizeof(portstr) - 1] = '\0';
virFirewallAddRule(fw, layer,
{
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,
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;
}
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);
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);
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;
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);
}
/* 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]);
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;
/* 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,
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;
}
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);
}
/* 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);
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;
}
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);
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);
PRUnichar *strUtf16 = NULL;
char s[24];
- snprintf(s, sizeof(s), "%d", n);
+ g_snprintf(s, sizeof(s), "%d", n);
pFuncs->pfnUtf8ToUtf16(s, &strUtf16);
#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)
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 {
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;
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);
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);
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);
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);
#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, \
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,
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,
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,
&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,
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,
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,
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;
}
{
/* 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);
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;
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;
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;
/* calculate length of the rest of the string */
len -= (virtTestCounterPrefixEndOffset - virtTestCounterStr);
- snprintf(virtTestCounterPrefixEndOffset, len, "%d", ++virtTestCounter);
+ g_snprintf(virtTestCounterPrefixEndOffset, len, "%d", ++virtTestCounter);
return virtTestCounterStr;
}
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)
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");
}
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);
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");
}
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);
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);
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, "-"));
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) {
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);
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++;
* 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 {
} 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;
}
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;
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;
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;