提交 0ca51d5c 编写于 作者: M Michal Privoznik

Adapt to VIR_STRDUP and VIR_STRNDUP in src/nwfilter/*

上级 e3221e64
......@@ -133,11 +133,11 @@ struct _virNWFilterSnoopReq {
virNWFilterTechDriverPtr techdriver;
char *ifname;
int ifindex;
const char *linkdev;
char *linkdev;
enum virDomainNetType nettype;
char ifkey[VIR_IFKEY_LEN];
virMacAddr macaddr;
const char *filtername;
char *filtername;
virNWFilterHashTablePtr vars;
virNWFilterDriverStatePtr driver;
/* start and end of lease list, ordered by lease time */
......@@ -1110,11 +1110,9 @@ virNWFilterSnoopDHCPOpen(const char *ifname, virMacAddr *mac,
* generate much more traffic than if we filtered by VM and
* braodcast MAC as well
*/
if (!(ext_filter = strdup(filter))) {
virReportOOMError();
if (VIR_STRDUP(ext_filter, filter) < 0)
return NULL;
}
}
handle = pcap_create(ifname, pcap_errbuf);
......@@ -1408,7 +1406,7 @@ virNWFilterDHCPSnoopThread(void *req0)
fds[i].fd = pcap_fileno(pcapConf[i].handle);
}
tmp = virNetDevGetIndex(req->ifname, &ifindex);
threadkey = strdup(req->threadkey);
ignore_value(VIR_STRDUP(threadkey, req->threadkey));
worker = virThreadPoolNew(1, 1, 0,
virNWFilterDHCPDecodeWorker,
req);
......@@ -1631,15 +1629,17 @@ virNWFilterDHCPSnoopReq(virNWFilterTechDriverPtr techdriver,
req->driver = driver;
req->techdriver = techdriver;
tmp = virNetDevGetIndex(ifname, &req->ifindex);
req->linkdev = linkdev ? strdup(linkdev) : NULL;
req->nettype = nettype;
req->ifname = strdup(ifname);
virMacAddrSet(&req->macaddr, macaddr);
req->filtername = strdup(filtername);
req->vars = virNWFilterHashTableCreate(0);
req->linkdev = NULL;
if (VIR_STRDUP(req->ifname, ifname) < 0 ||
VIR_STRDUP(req->filtername, filtername) < 0 ||
VIR_STRDUP(req->linkdev, linkdev) < 0)
goto exit_snoopreqput;
if (!req->ifname || !req->filtername || !req->vars || tmp < 0 ||
(linkdev != NULL && req->linkdev == NULL)) {
if (!req->vars || tmp < 0) {
virReportOOMError();
goto exit_snoopreqput;
}
......
......@@ -221,8 +221,8 @@ nwfilterStateInitialize(bool privileged,
goto error;
}
if ((base = strdup(SYSCONFDIR "/libvirt")) == NULL)
goto out_of_memory;
if (VIR_STRDUP(base, SYSCONFDIR "/libvirt") < 0)
goto error;
if (virAsprintf(&driverState->configDir,
"%s/nwfilter", base) == -1)
......@@ -454,9 +454,8 @@ nwfilterConnectListNWFilters(virConnectPtr conn,
nwfilterDriverLock(driver);
for (i = 0 ; i < driver->nwfilters.count && got < nnames ; i++) {
virNWFilterObjLock(driver->nwfilters.objs[i]);
if (!(names[got] = strdup(driver->nwfilters.objs[i]->def->name))) {
if (VIR_STRDUP(names[got], driver->nwfilters.objs[i]->def->name) < 0) {
virNWFilterObjUnlock(driver->nwfilters.objs[i]);
virReportOOMError();
goto cleanup;
}
got++;
......
......@@ -2982,7 +2982,7 @@ ebtablesCreateTmpSubChain(ebiptablesRuleInstPtr *inst,
switch (protoidx) {
case L2_PROTO_MAC_IDX:
protostr = strdup("");
ignore_value(VIR_STRDUP(protostr, ""));
break;
case L2_PROTO_STP_IDX:
ignore_value(virAsprintf(&protostr, "-d " NWFILTER_MAC_BGA " "));
......
......@@ -37,6 +37,7 @@
#include "nwfilter_learnipaddr.h"
#include "virnetdev.h"
#include "datatypes.h"
#include "virstring.h"
#define VIR_FROM_THIS VIR_FROM_NWFILTER
......@@ -866,9 +867,7 @@ __virNWFilterInstantiateFilter(const unsigned char *vmuuid,
}
virMacAddrFormat(macaddr, vmmacaddr);
str_macaddr = strdup(vmmacaddr);
if (!str_macaddr) {
virReportOOMError();
if (VIR_STRDUP(str_macaddr, vmmacaddr) < 0) {
rc = -1;
goto err_exit;
}
......
......@@ -705,11 +705,8 @@ virNWFilterLearnIPAddress(virNWFilterTechDriverPtr techdriver,
if (virNWFilterHashTablePutAll(filterparams, ht) < 0)
goto err_free_ht;
req->filtername = strdup(filtername);
if (req->filtername == NULL) {
virReportOOMError();
if (VIR_STRDUP(req->filtername, filtername) < 0)
goto err_free_ht;
}
if (virStrcpyStatic(req->ifname, ifname) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册