avifil32: Simplify comparing two unsigned ints (PVS-Studio).

Michael Stefaniuc mstefani at redhat.de
Mon Oct 27 14:03:33 CDT 2014


---
The old code was translating to This->nStreams != nr which happens to be
correct too due the the assert(nr < This->nStreams) and the
This->nStreams--. The chosen form requires less context though.


 dlls/avifil32/editstream.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/dlls/avifil32/editstream.c b/dlls/avifil32/editstream.c
index 6d38725..3aa8637 100644
--- a/dlls/avifil32/editstream.c
+++ b/dlls/avifil32/editstream.c
@@ -169,10 +169,9 @@ static HRESULT AVIFILE_RemoveStream(IAVIEditStreamImpl* const This, DWORD nr)
   /* remove part nr */
   IAVIStream_Release(This->pStreams[nr].pStream);
   This->nStreams--;
-  if (This->nStreams - nr > 0) {
-    memmove(This->pStreams + nr, This->pStreams + nr + 1,
-            (This->nStreams - nr) * sizeof(EditStreamTable));
-  }
+  if (nr < This->nStreams)
+    memmove(&This->pStreams[nr], &This->pStreams[nr + 1],
+            (This->nStreams - nr) * sizeof(This->pStreams[0]));
   This->pStreams[This->nStreams].pStream  = NULL;
   This->pStreams[This->nStreams].dwStart  = 0;
   This->pStreams[This->nStreams].dwLength = 0;
-- 
1.8.3.1



More information about the wine-patches mailing list