mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-22 04:25:18 +00:00
qemu: use g_auto() for all virBuffers
Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
28f7ddae05
commit
b8b58e22b9
@ -155,7 +155,7 @@ static char *
|
|||||||
qemuAgentEscapeNonPrintable(const char *text)
|
qemuAgentEscapeNonPrintable(const char *text)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
for (i = 0; text[i] != '\0'; i++) {
|
for (i = 0; text[i] != '\0'; i++) {
|
||||||
if (text[i] == '\\')
|
if (text[i] == '\\')
|
||||||
virBufferAddLit(&buf, "\\\\");
|
virBufferAddLit(&buf, "\\\\");
|
||||||
|
@ -3283,7 +3283,7 @@ qemuBlockStorageSourceNeedsStorageSliceLayer(const virStorageSource *src)
|
|||||||
char *
|
char *
|
||||||
qemuBlockStorageSourceGetCookieString(virStorageSourcePtr src)
|
qemuBlockStorageSourceGetCookieString(virStorageSourcePtr src)
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
for (i = 0; i < src->ncookies; i++) {
|
for (i = 0; i < src->ncookies; i++) {
|
||||||
|
@ -4604,7 +4604,7 @@ virQEMUCapsFormatSEVInfo(virQEMUCapsPtr qemuCaps, virBufferPtr buf)
|
|||||||
char *
|
char *
|
||||||
virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
|
virQEMUCapsFormatCache(virQEMUCapsPtr qemuCaps)
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
virBufferAddLit(&buf, "<qemuCaps>\n");
|
virBufferAddLit(&buf, "<qemuCaps>\n");
|
||||||
|
@ -5478,7 +5478,7 @@ qemuBuildRNGCommandLine(virLogManagerPtr logManager,
|
|||||||
|
|
||||||
for (i = 0; i < def->nrngs; i++) {
|
for (i = 0; i < def->nrngs; i++) {
|
||||||
g_autoptr(virJSONValue) props = NULL;
|
g_autoptr(virJSONValue) props = NULL;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
virDomainRNGDefPtr rng = def->rngs[i];
|
virDomainRNGDefPtr rng = def->rngs[i];
|
||||||
g_autofree char *chardev = NULL;
|
g_autofree char *chardev = NULL;
|
||||||
g_autofree char *devstr = NULL;
|
g_autofree char *devstr = NULL;
|
||||||
@ -6156,7 +6156,7 @@ qemuBuildBootCommandLine(virCommandPtr cmd,
|
|||||||
if (def->os.dtb)
|
if (def->os.dtb)
|
||||||
virCommandAddArgList(cmd, "-dtb", def->os.dtb, NULL);
|
virCommandAddArgList(cmd, "-dtb", def->os.dtb, NULL);
|
||||||
if (def->os.slic_table) {
|
if (def->os.slic_table) {
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
virCommandAddArg(cmd, "-acpitable");
|
virCommandAddArg(cmd, "-acpitable");
|
||||||
virBufferAddLit(&buf, "sig=SLIC,file=");
|
virBufferAddLit(&buf, "sig=SLIC,file=");
|
||||||
virQEMUBuildBufferEscapeComma(&buf, def->os.slic_table);
|
virQEMUBuildBufferEscapeComma(&buf, def->os.slic_table);
|
||||||
|
@ -100,7 +100,7 @@ qemuDBusGetAddress(virQEMUDriverPtr driver,
|
|||||||
static int
|
static int
|
||||||
qemuDBusWriteConfig(const char *filename, const char *path)
|
qemuDBusWriteConfig(const char *filename, const char *path)
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
g_autofree char *config = NULL;
|
g_autofree char *config = NULL;
|
||||||
|
|
||||||
virBufferAddLit(&buf, "<!DOCTYPE busconfig PUBLIC \"-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN\"\n");
|
virBufferAddLit(&buf, "<!DOCTYPE busconfig PUBLIC \"-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN\"\n");
|
||||||
|
@ -4838,7 +4838,7 @@ qemuDomainChrDefDropDefaultPath(virDomainChrDefPtr chr,
|
|||||||
virQEMUDriverPtr driver)
|
virQEMUDriverPtr driver)
|
||||||
{
|
{
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
g_autofree char *regexp = NULL;
|
g_autofree char *regexp = NULL;
|
||||||
|
|
||||||
if (chr->deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL ||
|
if (chr->deviceType != VIR_DOMAIN_CHR_DEVICE_TYPE_CHANNEL ||
|
||||||
@ -6019,7 +6019,7 @@ qemuDomainDefFormatXMLInternal(virQEMUDriverPtr driver,
|
|||||||
virCPUDefPtr origCPU,
|
virCPUDefPtr origCPU,
|
||||||
unsigned int flags)
|
unsigned int flags)
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
if (qemuDomainDefFormatBufInternal(driver, qemuCaps, def, origCPU, flags, &buf) < 0)
|
if (qemuDomainDefFormatBufInternal(driver, qemuCaps, def, origCPU, flags, &buf) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1272,7 +1272,7 @@ static char *
|
|||||||
qemuConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
|
qemuConnectGetSysinfo(virConnectPtr conn, unsigned int flags)
|
||||||
{
|
{
|
||||||
virQEMUDriverPtr driver = conn->privateData;
|
virQEMUDriverPtr driver = conn->privateData;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
virCheckFlags(0, NULL);
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
@ -14392,7 +14392,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
|
|||||||
virBitmapPtr created = NULL;
|
virBitmapPtr created = NULL;
|
||||||
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
g_autoptr(virQEMUDriverConfig) cfg = virQEMUDriverGetConfig(driver);
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
virDomainSnapshotDefPtr snapdef = virDomainSnapshotObjGetDef(snap);
|
virDomainSnapshotDefPtr snapdef = virDomainSnapshotObjGetDef(snap);
|
||||||
|
|
||||||
if (!(qemuImgPath = qemuFindQemuImgBinary(driver)))
|
if (!(qemuImgPath = qemuFindQemuImgBinary(driver)))
|
||||||
@ -14479,7 +14479,6 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
virCommandFree(cmd);
|
virCommandFree(cmd);
|
||||||
|
|
||||||
/* unlink images if creation has failed */
|
/* unlink images if creation has failed */
|
||||||
|
@ -178,7 +178,7 @@ qemuMigrationDstPrecreateDisk(virConnectPtr conn,
|
|||||||
virStorageVolPtr vol = NULL;
|
virStorageVolPtr vol = NULL;
|
||||||
char *volName = NULL, *basePath = NULL;
|
char *volName = NULL, *basePath = NULL;
|
||||||
char *volStr = NULL;
|
char *volStr = NULL;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
const char *format = NULL;
|
const char *format = NULL;
|
||||||
unsigned int flags = 0;
|
unsigned int flags = 0;
|
||||||
|
|
||||||
|
@ -869,12 +869,10 @@ qemuMigrationCookieXMLFormatStr(virQEMUDriverPtr driver,
|
|||||||
virQEMUCapsPtr qemuCaps,
|
virQEMUCapsPtr qemuCaps,
|
||||||
qemuMigrationCookiePtr mig)
|
qemuMigrationCookiePtr mig)
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
|
||||||
if (qemuMigrationCookieXMLFormat(driver, qemuCaps, &buf, mig) < 0) {
|
if (qemuMigrationCookieXMLFormat(driver, qemuCaps, &buf, mig) < 0)
|
||||||
virBufferFreeAndReset(&buf);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
return virBufferContentAndReset(&buf);
|
return virBufferContentAndReset(&buf);
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ static char *
|
|||||||
qemuMonitorEscapeNonPrintable(const char *text)
|
qemuMonitorEscapeNonPrintable(const char *text)
|
||||||
{
|
{
|
||||||
size_t i;
|
size_t i;
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
for (i = 0; text[i] != '\0'; i++) {
|
for (i = 0; text[i] != '\0'; i++) {
|
||||||
if (g_ascii_isprint(text[i]) ||
|
if (g_ascii_isprint(text[i]) ||
|
||||||
text[i] == '\n' ||
|
text[i] == '\n' ||
|
||||||
|
Loading…
x
Reference in New Issue
Block a user