[ovs-dev] [PATCH 39/40] datapath-windows: Fix static analysis warnings in OvsGetTcpPayloadLength

Alin Serdean aserdean at cloudbasesolutions.com
Fri Jul 14 04:40:58 UTC 2017


This fixes the static code analysis over the function
'OvsGetTcpPayloadLength'.

Signed-off-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>
---
 datapath-windows/ovsext/Conntrack.h | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/datapath-windows/ovsext/Conntrack.h b/datapath-windows/ovsext/Conntrack.h
index 04ca299..a8c64a1 100644
--- a/datapath-windows/ovsext/Conntrack.h
+++ b/datapath-windows/ovsext/Conntrack.h
@@ -154,20 +154,17 @@ static __inline UINT32
 OvsGetTcpPayloadLength(PNET_BUFFER_LIST nbl)
 {
     IPHdr *ipHdr;
-    char *ipBuf[sizeof(IPHdr)];
-    PNET_BUFFER curNb;
-    curNb = NET_BUFFER_LIST_FIRST_NB(nbl);
-    UINT32 hdrLen = sizeof(EthHdr);
-    NdisAdvanceNetBufferDataStart(curNb, hdrLen, FALSE, NULL);
-    ipHdr = NdisGetDataBuffer(curNb, sizeof *ipHdr, (PVOID) &ipBuf,
-                              1 /*no align*/, 0);
+    TCPHdr *tcp;
+    char *ipBuf[sizeof(EthHdr) + sizeof(IPHdr) + sizeof(TCPHdr)];
+
+    ipHdr = NdisGetDataBuffer(NET_BUFFER_LIST_FIRST_NB(nbl), sizeof *ipBuf,
+                              (PVOID)&ipBuf, 1 /*no align*/, 0);
     if (ipHdr == NULL) {
-        NdisRetreatNetBufferDataStart(curNb, hdrLen, 0, NULL);
         return 0;
     }
 
-    TCPHdr *tcp = (TCPHdr *)((PCHAR)ipHdr + ipHdr->ihl * 4);
-    NdisRetreatNetBufferDataStart(curNb, hdrLen, 0, NULL);
+    ipHdr = (IPHdr *)((PCHAR)ipHdr + sizeof(EthHdr));
+    tcp = (TCPHdr *)((PCHAR)ipHdr + ipHdr->ihl * 4);
 
     return (ntohs(ipHdr->tot_len) - (ipHdr->ihl * 4) - (TCP_HDR_LEN(tcp)));
 }
-- 
2.10.2.windows.1


More information about the dev mailing list