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:
Pavel Hrdina 2019-11-13 14:53:42 +01:00
parent 8addef2bef
commit 43b01ef2d6
39 changed files with 188 additions and 188 deletions

View File

@ -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);

View File

@ -418,12 +418,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'"),
@ -440,11 +440,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'"),

View File

@ -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,

View File

@ -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);

View File

@ -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;

View File

@ -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 */

View File

@ -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)

View File

@ -2225,61 +2225,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)
@ -2582,15 +2582,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;
@ -2601,8 +2601,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;

View File

@ -5106,8 +5106,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;
}
@ -5801,8 +5801,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;
}

View File

@ -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;
}

View File

@ -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);

View File

@ -3961,7 +3961,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;

View File

@ -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) {

View File

@ -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,

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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]);

View File

@ -67,7 +67,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,

View File

@ -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;
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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,

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

View File

@ -1187,7 +1187,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;
}

View File

@ -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)

View File

@ -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);

View File

@ -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);

View File

@ -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, "-"));

View File

@ -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) {

View File

@ -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);

View File

@ -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;
}

View File

@ -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;

View File

@ -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;