Skip to content

Commit

Permalink
NetKVM: DPrintf: Use variadic arguments and fmt
Browse files Browse the repository at this point in the history
This should be the appropriate for handling variadic arguments in a
MACRO.

Signed-off-by: Sameeh Jubran <sameeh@daynix.com>
  • Loading branch information
Sameeh Jubran authored and YanVugenfirer committed Dec 12, 2017
1 parent 15767b4 commit 699a3c6
Show file tree
Hide file tree
Showing 21 changed files with 301 additions and 301 deletions.
4 changes: 2 additions & 2 deletions NetKVM/Common/ParaNdis-AbstractPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ NDIS_STATUS CParaNdisAbstractPath::SetupMessageIndex(u16 vector)

if (val != vector)
{
DPrintf(0, ("[%s] - read/write mismatch, %u vs %u\n", val, vector));
DPrintf(0, "[%s] - read/write mismatch, %u vs %u\n", val, vector);
return NDIS_STATUS_DEVICE_FAILED;
}

Expand All @@ -25,7 +25,7 @@ ULONG CParaNdisAbstractPath::getCPUIndex()
ULONG number = ParaNdis_GetIndexFromAffinity(DPCAffinity.Mask);
if (number == INVALID_PROCESSOR_INDEX)
{
DPrintf(0, ("[%s] : bad in-group processor index: mask 0x%lx\n", __FUNCTION__, (ULONG)DPCAffinity.Mask));
DPrintf(0, "[%s] : bad in-group processor index: mask 0x%lx\n", __FUNCTION__, (ULONG)DPCAffinity.Mask);
NETKVM_ASSERT(FALSE);
return INVALID_PROCESSOR_INDEX;
}
Expand Down
16 changes: 8 additions & 8 deletions NetKVM/Common/ParaNdis-CX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ bool CParaNdisCX::Create(PPARANDIS_ADAPTER Context, UINT DeviceQueueIndex)

if (!ParaNdis_InitialAllocatePhysicalMemory(m_Context, 512, &m_ControlData))
{
DPrintf(0, ("CParaNdisCX::Create - ParaNdis_InitialAllocatePhysicalMemory failed for %u\n",
DeviceQueueIndex));
DPrintf(0, "CParaNdisCX::Create - ParaNdis_InitialAllocatePhysicalMemory failed for %u\n",
DeviceQueueIndex);
m_ControlData.Virtual = nullptr;
return false;
}
Expand Down Expand Up @@ -102,34 +102,34 @@ BOOLEAN CParaNdisCX::SendControlMessage(

if (len != sizeof(virtio_net_ctrl_ack))
{
DPrintf(0, ("%s - ERROR: wrong len %d\n", __FUNCTION__, len));
DPrintf(0, "%s - ERROR: wrong len %d\n", __FUNCTION__, len);
}
else if (*(virtio_net_ctrl_ack *)(pBase + offset) != VIRTIO_NET_OK)
{
DPrintf(0, ("%s - ERROR: error %d returned for class %d\n", __FUNCTION__, *(virtio_net_ctrl_ack *)(pBase + offset), cls));
DPrintf(0, "%s - ERROR: error %d returned for class %d\n", __FUNCTION__, *(virtio_net_ctrl_ack *)(pBase + offset), cls);
}
else
{
// everything is OK
DPrintf(levelIfOK, ("%s OK(%d.%d,buffers of %d and %d) \n", __FUNCTION__, cls, cmd, size1, size2));
DPrintf(levelIfOK, "%s OK(%d.%d,buffers of %d and %d) \n", __FUNCTION__, cls, cmd, size1, size2);
bOK = TRUE;
}
}
else
{
DPrintf(0, ("%s - ERROR: add_buf failed\n", __FUNCTION__));
DPrintf(0, "%s - ERROR: add_buf failed\n", __FUNCTION__);
}
}
else
{
DPrintf(0, ("%s (buffer %d,%d) - ERROR: message too LARGE\n", __FUNCTION__, size1, size2));
DPrintf(0, "%s (buffer %d,%d) - ERROR: message too LARGE\n", __FUNCTION__, size1, size2);
}
return bOK;
}

NDIS_STATUS CParaNdisCX::SetupMessageIndex(u16 vector)
{
DPrintf(0, ("[%s] Using message %u for controls\n", __FUNCTION__, vector));
DPrintf(0, "[%s] Using message %u for controls\n", __FUNCTION__, vector);

virtio_set_config_vector(&m_Context->IODevice, vector);

Expand Down
142 changes: 71 additions & 71 deletions NetKVM/Common/ParaNdis-Common.cpp

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions NetKVM/Common/ParaNdis-Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void ParaNdis_DebugInitialize()
BugCheckDeregisterCallback = (KeDeregisterBugCheckReasonCallbackType)pd;
}
res = BugCheckRegisterCallback(&CallbackRecord, ParaNdis_OnBugCheck, KbCallbackSecondaryDumpData, (const PUCHAR)"NetKvm");
DPrintf(0, ("[%s] Crash callback %sregistered\n", __FUNCTION__, res ? "" : "NOT "));
DPrintf(0, "[%s] Crash callback %sregistered\n", __FUNCTION__, res ? "" : "NOT ");
}

void ParaNdis_DebugCleanup(PDRIVER_OBJECT pDriverObject)
Expand Down Expand Up @@ -295,16 +295,16 @@ VOID ParaNdis_OnBugCheck(
pDump->OutBufferLength = dumpSize;
bNative = FALSE;
}
DPrintf(0, ("[%s] system buffer of %d, saving data for %d NIC\n", __FUNCTION__,pDump->InBufferLength, nSaved));
DPrintf(0, ("[%s] using %s buffer\n", __FUNCTION__, bNative ? "native" : "own"));
DPrintf(0, "[%s] system buffer of %d, saving data for %d NIC\n", __FUNCTION__,pDump->InBufferLength, nSaved);
DPrintf(0, "[%s] using %s buffer\n", __FUNCTION__, bNative ? "native" : "own");
}
else if (pDump->OutBuffer == pDump->InBuffer)
{
RtlCopyMemory(&pDump->Guid, &ParaNdis_CrashGuid, sizeof(pDump->Guid));
RtlCopyMemory(pDump->InBuffer, &BugCheckData.Location, dumpSize);
pDump->OutBufferLength = dumpSize;
DPrintf(0, ("[%s] written %d to %p\n", __FUNCTION__, (ULONG)BugCheckData.Location.Size, (UINT_PTR)BugCheckData.Location.Address ));
DPrintf(0, ("[%s] dump data (%d) at %p\n", __FUNCTION__, pDump->OutBufferLength, pDump->OutBuffer));
DPrintf(0, "[%s] written %d to %p\n", __FUNCTION__, (ULONG)BugCheckData.Location.Size, (UINT_PTR)BugCheckData.Location.Address );
DPrintf(0, "[%s] dump data (%d) at %p\n", __FUNCTION__, pDump->OutBufferLength, pDump->OutBuffer);
}
}
}
Expand Down
22 changes: 11 additions & 11 deletions NetKVM/Common/ParaNdis-Oid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ NDIS_STATUS ParaNdis_OnSetPacketFilter(PARANDIS_ADAPTER *pContext, tOidDesc *pOi
if (status == NDIS_STATUS_SUCCESS)
{
pContext->PacketFilter = newValue;
DPrintf(1, ("[%s] PACKET FILTER SET TO %x\n", __FUNCTION__, pContext->PacketFilter));
DPrintf(1, "[%s] PACKET FILTER SET TO %x\n", __FUNCTION__, pContext->PacketFilter);
ParaNdis_UpdateDeviceFilters(pContext);
}
return status;
Expand Down Expand Up @@ -396,7 +396,7 @@ NDIS_STATUS ParaNdis_OidQueryCommon(PARANDIS_ADAPTER *pContext, tOidDesc *pOid)
pContext->Statistics.ifHCInUcastPkts +
pContext->Statistics.ifHCInMulticastPkts +
pContext->Statistics.ifHCInBroadcastPkts);
DPrintf(4, ("[%s] Total frames %I64u\n", __FUNCTION__, u.ul64));
DPrintf(4, "[%s] Total frames %I64u\n", __FUNCTION__, u.ul64);
break;
case OID_GEN_XMIT_ERROR:
SETINFO(ul64, pContext->Statistics.ifOutErrors );
Expand Down Expand Up @@ -634,7 +634,7 @@ NDIS_STATUS ParaNdis_OnOidSetNetworkAddresses(PARANDIS_ADAPTER *pContext, tOidDe
pContext->guestAnnouncePackets.DestroyIPV6NBLs();
}
PUCHAR p = (PUCHAR)(&pnal->Address[0]);
DPrintf(2, ("Received %d addresses, type %d\n", pnal->AddressCount, pnal->AddressType));
DPrintf(2, "Received %d addresses, type %d\n", pnal->AddressCount, pnal->AddressType);
for (i = 0; i < (UINT)pnal->AddressCount; ++i)
{
NETWORK_ADDRESS *pna = (NETWORK_ADDRESS *)p;
Expand All @@ -644,11 +644,11 @@ NDIS_STATUS ParaNdis_OnOidSetNetworkAddresses(PARANDIS_ADAPTER *pContext, tOidDe
{
PNETWORK_ADDRESS_IP pIP = (PNETWORK_ADDRESS_IP)pna->Address;
pContext->guestAnnouncePackets.CreateNBL(pIP->in_addr);
DPrintf(0, ("Received IP address %d.%d.%d.%d\n",
DPrintf(0, "Received IP address %d.%d.%d.%d\n",
(pIP->in_addr >> 0) & 0xff,
(pIP->in_addr >> 8) & 0xff,
(pIP->in_addr >> 16) & 0xff,
(pIP->in_addr >> 24) & 0xff));
(pIP->in_addr >> 24) & 0xff);
} else
{
if (pna->AddressLength == sizeof(NETWORK_ADDRESS_IP6)
Expand All @@ -670,8 +670,8 @@ NDIS_STATUS ParaNdis_OnOidSetNetworkAddresses(PARANDIS_ADAPTER *pContext, tOidDe
TempString[j * 2 + 1] = hexdigit(digit);
}
}
DPrintf(0, ("address %d, type %d, len %d (%s)\n",
i, pna->AddressType, pna->AddressLength, TempString ? TempString : (const PUCHAR)"do not know"));
DPrintf(0, "address %d, type %d, len %d (%s)\n",
i, pna->AddressType, pna->AddressLength, TempString ? TempString : (const PUCHAR)"do not know");
if (TempString) NdisFreeMemory(TempString, 0, 0);
}
p += RTL_FIELD_SIZE(NETWORK_ADDRESS, AddressLength) + RTL_FIELD_SIZE(NETWORK_ADDRESS, AddressType);
Expand Down Expand Up @@ -699,9 +699,9 @@ static NDIS_STATUS ValidateWakeupPattern(PNDIS_PM_PACKET_PATTERN p, PULONG pVali
ULONG ul = p->PatternOffset + p->PatternSize;
if (*pValidSize >= ul) status = NDIS_STATUS_SUCCESS;
*pValidSize = ul;
DPrintf(2, ("[%s] pattern of %d at %d, mask %d (%s)\n",
DPrintf(2, "[%s] pattern of %d at %d, mask %d (%s)\n",
__FUNCTION__, p->PatternSize, p->PatternOffset, p->MaskSize,
status == NDIS_STATUS_SUCCESS ? "OK" : "Fail"));
status == NDIS_STATUS_SUCCESS ? "OK" : "Fail");
}
return status;
}
Expand Down Expand Up @@ -764,7 +764,7 @@ NDIS_STATUS ParaNdis_OnEnableWakeup(PARANDIS_ADAPTER *pContext, tOidDesc *pOid)
NDIS_STATUS status = ParaNdis_OidSetCopy(pOid, &pContext->ulEnableWakeup, sizeof(pContext->ulEnableWakeup));
if (status == NDIS_STATUS_SUCCESS)
{
DPrintf(0, ("[%s] new value %lX\n", __FUNCTION__, pContext->ulEnableWakeup));
DPrintf(0, "[%s] new value %lX\n", __FUNCTION__, pContext->ulEnableWakeup);
}
return status;
}
Expand All @@ -784,7 +784,7 @@ NDIS_STATUS ParaNdis_OnSetVlanId(PARANDIS_ADAPTER *pContext, tOidDesc *pOid)
{
status = ParaNdis_OidSetCopy(pOid, &pContext->VlanId, sizeof(pContext->VlanId));
pContext->VlanId &= 0xfff;
DPrintf(0, ("[%s] new value %d on MAC %X\n", __FUNCTION__, pContext->VlanId, pContext->CurrentMacAddress[5]));
DPrintf(0, "[%s] new value %d on MAC %X\n", __FUNCTION__, pContext->VlanId, pContext->CurrentMacAddress[5]);
ParaNdis_DeviceFiltersUpdateVlanId(pContext);
}
return status;
Expand Down
10 changes: 5 additions & 5 deletions NetKVM/Common/ParaNdis-RX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ int CParaNdisRX::PrepareReceiveBuffers()
}
/* TODO - NetMaxReceiveBuffers should take into account all queues */
m_Context->NetMaxReceiveBuffers = m_NetNofReceiveBuffers;
DPrintf(0, ("[%s] MaxReceiveBuffers %d\n", __FUNCTION__, m_Context->NetMaxReceiveBuffers));
DPrintf(0, "[%s] MaxReceiveBuffers %d\n", __FUNCTION__, m_Context->NetMaxReceiveBuffers);
m_Reinsert = true;

return nRet;
Expand Down Expand Up @@ -168,8 +168,8 @@ void CParaNdisRX::ReuseReceiveBufferNoLock(pRxNetDescriptor pBuffersDescriptor)

if (m_NetNofReceiveBuffers > m_Context->NetMaxReceiveBuffers)
{
DPrintf(0, (" Error: NetNofReceiveBuffers > NetMaxReceiveBuffers(%d>%d)\n",
m_NetNofReceiveBuffers, m_Context->NetMaxReceiveBuffers));
DPrintf(0, " Error: NetNofReceiveBuffers > NetMaxReceiveBuffers(%d>%d)\n",
m_NetNofReceiveBuffers, m_Context->NetMaxReceiveBuffers);
}

/* TODO - nReusedRXBuffers per queue or per context ?*/
Expand All @@ -182,7 +182,7 @@ void CParaNdisRX::ReuseReceiveBufferNoLock(pRxNetDescriptor pBuffersDescriptor)
else
{
/* TODO - NetMaxReceiveBuffers per queue or per context ?*/
DPrintf(0, ("FAILED TO REUSE THE BUFFER!!!!\n"));
DPrintf(0, "FAILED TO REUSE THE BUFFER!!!!\n");
ParaNdis_FreeRxBufferDescriptor(m_Context, pBuffersDescriptor);
m_Context->NetMaxReceiveBuffers--;
}
Expand Down Expand Up @@ -286,7 +286,7 @@ void CParaNdisRX::PopulateQueue()
else
{
/* TODO - NetMaxReceiveBuffers should take into account all queues */
DPrintf(0, ("FAILED TO REUSE THE BUFFER!!!!\n"));
DPrintf(0, "FAILED TO REUSE THE BUFFER!!!!\n");
ParaNdis_FreeRxBufferDescriptor(m_Context, pBufferDescriptor);
m_Context->NetMaxReceiveBuffers--;
}
Expand Down
16 changes: 8 additions & 8 deletions NetKVM/Common/ParaNdis-TX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool CNBL::ParsePriority()

if (priorityInfo.TagHeader.CanonicalFormatId || !IsValidVlanId(m_Context, priorityInfo.TagHeader.VlanId))
{
DPrintf(0, ("[%s] Discarded invalid priority tag %p\n", __FUNCTION__, priorityInfo.Value));
DPrintf(0, "[%s] Discarded invalid priority tag %p\n", __FUNCTION__, priorityInfo.Value);
return false;
}
else if (priorityInfo.Value)
Expand All @@ -63,7 +63,7 @@ bool CNBL::ParsePriority()
if (priorityInfo.Value)
{
m_TCI = static_cast<UINT16>(priorityInfo.TagHeader.UserPriority << 13 | priorityInfo.TagHeader.VlanId);
DPrintf(1, ("[%s] Populated priority tag %p\n", __FUNCTION__, priorityInfo.Value));
DPrintf(1, "[%s] Populated priority tag %p\n", __FUNCTION__, priorityInfo.Value);
}
}

Expand Down Expand Up @@ -104,7 +104,7 @@ bool CNBL::ParseBuffers()

if(m_MaxDataLength == 0)
{
DPrintf(0, ("Empty NBL (%p) dropped\n", __FUNCTION__, m_NBL));
DPrintf(0, "Empty NBL (%p) dropped\n", __FUNCTION__, m_NBL);
return false;
}

Expand Down Expand Up @@ -175,7 +175,7 @@ bool CNBL::ParseCSO(TClassPred IsClass, TOffloadPred IsOffload,
{
if(!IsSupported())
{
DPrintf(0, ("[%s] %s request when it is not supported\n", __FUNCTION__, OffloadName));
DPrintf(0, "[%s] %s request when it is not supported\n", __FUNCTION__, OffloadName);
#if FAIL_UNEXPECTED
// ignore unexpected CS requests while this passes WHQL
return false;
Expand Down Expand Up @@ -279,7 +279,7 @@ CParaNdisTX::~CParaNdisTX()

m_SendQueue.~CLockFreeQueue();

DPrintf(1, ("Pools state %d-> NB: %d, NBL: %d\n", m_queueIndex, m_nbPool.GetCount(), m_nblPool.GetCount()));
DPrintf(1, "Pools state %d-> NB: %d, NBL: %d\n", m_queueIndex, m_nbPool.GetCount(), m_nblPool.GetCount());
if (m_StateMachineRegistered)
{
m_Context->m_StateMachine.UnregisterFlow(m_StateMachine);
Expand Down Expand Up @@ -367,7 +367,7 @@ void CParaNdisTX::Send(PNET_BUFFER_LIST NBL)
{
CompleteOutstandingInternalNBL(NBL);
}
DPrintf(0, ("ERROR: Failed to allocate CNBL instance\n"));
DPrintf(0, "ERROR: Failed to allocate CNBL instance\n");
continue;
}

Expand Down Expand Up @@ -755,7 +755,7 @@ void CNB::PopulateIPLength(IPHeader *IpHeader, USHORT IpLength) const
}
else
{
DPrintf(0, ("[%s] ERROR: Bad version of IP header!\n", __FUNCTION__));
DPrintf(0, "[%s] ERROR: Bad version of IP header!\n", __FUNCTION__);
}
}

Expand Down Expand Up @@ -795,7 +795,7 @@ USHORT CNB::QueryL4HeaderOffset(PVOID PacketData, ULONG IpHeaderOffset) const
}
else
{
DPrintf(0, ("[%s] ERROR: NOT an IP packet - expected troubles!\n", __FUNCTION__));
DPrintf(0, "[%s] ERROR: NOT an IP packet - expected troubles!\n", __FUNCTION__);
Res = 0;
}
return Res;
Expand Down
2 changes: 1 addition & 1 deletion NetKVM/Common/ParaNdis-Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ void ParaNdis_PrintTable(int DebugPrintLevel, TTable table, size_t Size, LPCSTR

if (RtlStringCbCatA(FullFormat, sizeof(FullFormat), Format) != STATUS_SUCCESS)
{
DPrintf(0, ("[%s] - format concatenation failed for %s\n", __FUNCTION__, Format));
DPrintf(0, "[%s] - format concatenation failed for %s\n", __FUNCTION__, Format);
return;
}

Expand Down
Loading

0 comments on commit 699a3c6

Please sign in to comment.