$(_sc_search_regexp)
sc_prohibit_obj_free_apis_in_virsh:
- @prohibit='\bvir(Domain|DomainSnapshot|Interface|Network|NodeDevice|NWFilter|Secret|StoragePool|StorageVol)Free\b' \
+ @prohibit='\bvir(Domain|DomainSnapshot|Interface|Network|NodeDevice|NWFilter|Secret|StoragePool|StorageVol|Stream)Free\b' \
in_vc_files='virsh.*\.[ch]$$' \
exclude='sc_prohibit_obj_free_apis_in_virsh' \
halt='avoid using public virXXXFree in virsh, use virsh-prefixed wrappers instead' \
# include "internal.h"
# include "virsh.h"
# include "virsh-console.h"
+# include "virsh-util.h"
# include "virlog.h"
# include "virfile.h"
# include "viralloc.h"
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("cannot terminate console stream"));
}
- virStreamFree(con->st);
- con->st = NULL;
+
+ g_clear_pointer(&con->st, virshStreamFree);
}
VIR_FREE(con->streamToTerminal.data);
VIR_FREE(con->terminalToStream.data);
{
virConsole *con = obj;
- if (con->st)
- virStreamFree(con->st);
+ virshStreamFree(con->st);
virCondDestroy(&con->cond);
virResetError(&con->error);
const char *name = NULL;
char *file = NULL;
int fd = -1;
- virStreamPtr st = NULL;
+ g_autoptr(virshStream) st = NULL;
unsigned int screen = 0;
unsigned int flags = 0; /* currently unused */
bool ret = false;
unlink(file);
if (generated)
VIR_FREE(file);
- if (st)
- virStreamFree(st);
VIR_FORCE_CLOSE(fd);
VIR_FREE(mime);
return ret;
}
+
+void
+virshStreamFree(virStreamPtr stream)
+{
+ if (!stream)
+ return;
+
+ vshSaveLibvirtHelperError();
+ virStreamFree(stream); /* sc_prohibit_obj_free_apis_in_virsh */
+}
+
+
int
virshDomainGetXMLFromDom(vshControl *ctl,
virDomainPtr dom,
virshStorageVolFree(virStorageVolPtr vol);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virshStorageVol, virshStorageVolFree);
+typedef virStream virshStream;
+void
+virshStreamFree(virStreamPtr stream);
+G_DEFINE_AUTOPTR_CLEANUP_FUNC(virshStream, virshStreamFree);
+
int
virshDomainState(vshControl *ctl,
virDomainPtr dom,
g_autoptr(virshStorageVol) vol = NULL;
bool ret = false;
int fd = -1;
- virStreamPtr st = NULL;
+ g_autoptr(virshStream) st = NULL;
const char *name = NULL;
unsigned long long offset = 0, length = 0;
virshControl *priv = ctl->privData;
ret = true;
cleanup:
- if (st)
- virStreamFree(st);
VIR_FORCE_CLOSE(fd);
return ret;
}
g_autoptr(virshStorageVol) vol = NULL;
bool ret = false;
int fd = -1;
- virStreamPtr st = NULL;
+ g_autoptr(virshStream) st = NULL;
const char *name = NULL;
unsigned long long offset = 0, length = 0;
bool created = false;
VIR_FORCE_CLOSE(fd);
if (!ret && created)
unlink(file);
- if (st)
- virStreamFree(st);
return ret;
}